text
stringlengths
30
1.67M
<s> package org . eclipse . jdt . core . dom ; public class Message { private String message ; private int startPosition ; private int length ; public Message ( String message , int startPosition ) { if ( message == null ) { throw new IllegalArgumentException ( ) ; } if ( startPosition < - <NUM_LIT:1> ) { throw new IllegalArgumentException ( ) ; } this . message = message ; this . startPosition = startPosition ; this . length = <NUM_LIT:0> ; } public Message ( String message , int startPosition , int length ) { if ( message == null ) { throw new IllegalArgumentException ( ) ; } if ( startPosition < - <NUM_LIT:1> ) { throw new IllegalArgumentException ( ) ; } this . message = message ; this . startPosition = startPosition ; if ( length <= <NUM_LIT:0> ) { this . length = <NUM_LIT:0> ; } else { this . length = length ; } } public String getMessage ( ) { return this . message ; } public int getSourcePosition ( ) { return getStartPosition ( ) ; } public int getStartPosition ( ) { return this . startPosition ; } public int getLength ( ) { return this . length ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . Iterator ; import java . util . List ; public abstract class BodyDeclaration extends ASTNode { Javadoc optionalDocComment = null ; private int modifierFlags = Modifier . NONE ; ASTNode . NodeList modifiers = null ; abstract SimplePropertyDescriptor internalModifiersProperty ( ) ; abstract ChildListPropertyDescriptor internalModifiers2Property ( ) ; public final ChildListPropertyDescriptor getModifiersProperty ( ) { return internalModifiers2Property ( ) ; } abstract ChildPropertyDescriptor internalJavadocProperty ( ) ; public final ChildPropertyDescriptor getJavadocProperty ( ) { return internalJavadocProperty ( ) ; } static final ChildPropertyDescriptor internalJavadocPropertyFactory ( Class nodeClass ) { return new ChildPropertyDescriptor ( nodeClass , "<STR_LIT>" , Javadoc . class , OPTIONAL , NO_CYCLE_RISK ) ; } static final SimplePropertyDescriptor internalModifiersPropertyFactory ( Class nodeClass ) { return new SimplePropertyDescriptor ( nodeClass , "<STR_LIT>" , int . class , MANDATORY ) ; } static final ChildListPropertyDescriptor internalModifiers2PropertyFactory ( Class nodeClass ) { return new ChildListPropertyDescriptor ( nodeClass , "<STR_LIT>" , IExtendedModifier . class , CYCLE_RISK ) ; } BodyDeclaration ( AST ast ) { super ( ast ) ; if ( ast . apiLevel >= AST . JLS3 ) { this . modifiers = new ASTNode . NodeList ( internalModifiers2Property ( ) ) ; } } public Javadoc getJavadoc ( ) { return this . optionalDocComment ; } public void setJavadoc ( Javadoc docComment ) { ChildPropertyDescriptor p = internalJavadocProperty ( ) ; ASTNode oldChild = this . optionalDocComment ; preReplaceChild ( oldChild , docComment , p ) ; this . optionalDocComment = docComment ; postReplaceChild ( oldChild , docComment , p ) ; } public int getModifiers ( ) { if ( this . modifiers == null ) { return this . modifierFlags ; } else { int computedmodifierFlags = Modifier . NONE ; for ( Iterator it = modifiers ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Object x = it . next ( ) ; if ( x instanceof Modifier ) { computedmodifierFlags |= ( ( Modifier ) x ) . getKeyword ( ) . toFlagValue ( ) ; } } return computedmodifierFlags ; } } public void setModifiers ( int modifiers ) { internalSetModifiers ( modifiers ) ; } final void internalSetModifiers ( int pmodifiers ) { if ( this . modifiers != null ) { supportedOnlyIn2 ( ) ; } SimplePropertyDescriptor p = internalModifiersProperty ( ) ; preValueChange ( p ) ; this . modifierFlags = pmodifiers ; postValueChange ( p ) ; } public List modifiers ( ) { if ( this . modifiers == null ) { unsupportedIn2 ( ) ; } return this . modifiers ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:3> * <NUM_LIT:4> ; } } </s>
<s> package org . eclipse . jdt . core . dom ; public abstract class Name extends Expression implements IDocElement { static final int BASE_NAME_NODE_SIZE = BASE_NODE_SIZE + <NUM_LIT:1> * <NUM_LIT:4> ; int index ; Name ( AST ast ) { super ( ast ) ; } public final boolean isSimpleName ( ) { return ( this instanceof SimpleName ) ; } public final boolean isQualifiedName ( ) { return ( this instanceof QualifiedName ) ; } public final IBinding resolveBinding ( ) { return this . ast . getBindingResolver ( ) . resolveName ( this ) ; } public final String getFullyQualifiedName ( ) { if ( isSimpleName ( ) ) { return ( ( SimpleName ) this ) . getIdentifier ( ) ; } else { StringBuffer buffer = new StringBuffer ( <NUM_LIT> ) ; appendName ( buffer ) ; return new String ( buffer ) ; } } abstract void appendName ( StringBuffer buffer ) ; } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class LabeledStatement extends Statement { public static final ChildPropertyDescriptor LABEL_PROPERTY = new ChildPropertyDescriptor ( LabeledStatement . class , "<STR_LIT:label>" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor BODY_PROPERTY = new ChildPropertyDescriptor ( LabeledStatement . class , "<STR_LIT:body>" , Statement . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( LabeledStatement . class , propertyList ) ; addProperty ( LABEL_PROPERTY , propertyList ) ; addProperty ( BODY_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private SimpleName labelName = null ; private Statement body = null ; LabeledStatement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == LABEL_PROPERTY ) { if ( get ) { return getLabel ( ) ; } else { setLabel ( ( SimpleName ) child ) ; return null ; } } if ( property == BODY_PROPERTY ) { if ( get ) { return getBody ( ) ; } else { setBody ( ( Statement ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return LABELED_STATEMENT ; } ASTNode clone0 ( AST target ) { LabeledStatement result = new LabeledStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setLabel ( ( SimpleName ) ASTNode . copySubtree ( target , getLabel ( ) ) ) ; result . setBody ( ( Statement ) ASTNode . copySubtree ( target , getBody ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getLabel ( ) ) ; acceptChild ( visitor , getBody ( ) ) ; } visitor . endVisit ( this ) ; } public SimpleName getLabel ( ) { if ( this . labelName == null ) { synchronized ( this ) { if ( this . labelName == null ) { preLazyInit ( ) ; this . labelName = new SimpleName ( this . ast ) ; postLazyInit ( this . labelName , LABEL_PROPERTY ) ; } } } return this . labelName ; } public void setLabel ( SimpleName label ) { if ( label == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . labelName ; preReplaceChild ( oldChild , label , LABEL_PROPERTY ) ; this . labelName = label ; postReplaceChild ( oldChild , label , LABEL_PROPERTY ) ; } public Statement getBody ( ) { if ( this . body == null ) { synchronized ( this ) { if ( this . body == null ) { preLazyInit ( ) ; this . body = new EmptyStatement ( this . ast ) ; postLazyInit ( this . body , BODY_PROPERTY ) ; } } } return this . body ; } public void setBody ( Statement statement ) { if ( statement == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . body ; preReplaceChild ( oldChild , statement , BODY_PROPERTY ) ; this . body = statement ; postReplaceChild ( oldChild , statement , BODY_PROPERTY ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . labelName == null ? <NUM_LIT:0> : getLabel ( ) . treeSize ( ) ) + ( this . body == null ? <NUM_LIT:0> : getBody ( ) . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import org . eclipse . jdt . core . IAnnotatable ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IMember ; import org . eclipse . jdt . internal . compiler . lookup . ElementValuePair ; import org . eclipse . jdt . internal . compiler . lookup . MethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . TagBits ; import org . eclipse . jdt . internal . compiler . util . * ; class AnnotationBinding implements IAnnotationBinding { static final AnnotationBinding [ ] NoAnnotations = new AnnotationBinding [ <NUM_LIT:0> ] ; private org . eclipse . jdt . internal . compiler . lookup . AnnotationBinding binding ; private BindingResolver bindingResolver ; private String key ; AnnotationBinding ( org . eclipse . jdt . internal . compiler . lookup . AnnotationBinding annotation , BindingResolver resolver ) { if ( annotation == null ) throw new IllegalStateException ( ) ; this . binding = annotation ; this . bindingResolver = resolver ; } public IAnnotationBinding [ ] getAnnotations ( ) { return NoAnnotations ; } public ITypeBinding getAnnotationType ( ) { ITypeBinding typeBinding = this . bindingResolver . getTypeBinding ( this . binding . getAnnotationType ( ) ) ; if ( typeBinding == null ) return null ; return typeBinding ; } public IMemberValuePairBinding [ ] getDeclaredMemberValuePairs ( ) { ReferenceBinding typeBinding = this . binding . getAnnotationType ( ) ; if ( typeBinding == null || ( ( typeBinding . tagBits & TagBits . HasMissingType ) != <NUM_LIT:0> ) ) { return MemberValuePairBinding . NoPair ; } ElementValuePair [ ] internalPairs = this . binding . getElementValuePairs ( ) ; int length = internalPairs . length ; IMemberValuePairBinding [ ] pairs = length == <NUM_LIT:0> ? MemberValuePairBinding . NoPair : new MemberValuePairBinding [ length ] ; int counter = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { ElementValuePair valuePair = internalPairs [ i ] ; if ( valuePair . binding == null ) continue ; pairs [ counter ++ ] = this . bindingResolver . getMemberValuePairBinding ( valuePair ) ; } if ( counter == <NUM_LIT:0> ) return MemberValuePairBinding . NoPair ; if ( counter != length ) { System . arraycopy ( pairs , <NUM_LIT:0> , ( pairs = new MemberValuePairBinding [ counter ] ) , <NUM_LIT:0> , counter ) ; } return pairs ; } public IMemberValuePairBinding [ ] getAllMemberValuePairs ( ) { IMemberValuePairBinding [ ] pairs = getDeclaredMemberValuePairs ( ) ; ReferenceBinding typeBinding = this . binding . getAnnotationType ( ) ; if ( typeBinding == null || ( ( typeBinding . tagBits & TagBits . HasMissingType ) != <NUM_LIT:0> ) ) return pairs ; MethodBinding [ ] methods = typeBinding . availableMethods ( ) ; int methodLength = methods == null ? <NUM_LIT:0> : methods . length ; if ( methodLength == <NUM_LIT:0> ) return pairs ; int declaredLength = pairs . length ; if ( declaredLength == methodLength ) return pairs ; HashtableOfObject table = new HashtableOfObject ( declaredLength ) ; for ( int i = <NUM_LIT:0> ; i < declaredLength ; i ++ ) { char [ ] internalName = ( ( MemberValuePairBinding ) pairs [ i ] ) . internalName ( ) ; if ( internalName == null ) continue ; table . put ( internalName , pairs [ i ] ) ; } IMemberValuePairBinding [ ] allPairs = new IMemberValuePairBinding [ methodLength ] ; for ( int i = <NUM_LIT:0> ; i < methodLength ; i ++ ) { Object pair = table . get ( methods [ i ] . selector ) ; allPairs [ i ] = pair == null ? new DefaultValuePairBinding ( methods [ i ] , this . bindingResolver ) : ( IMemberValuePairBinding ) pair ; } return allPairs ; } public IJavaElement getJavaElement ( ) { if ( ! ( this . bindingResolver instanceof DefaultBindingResolver ) ) return null ; ASTNode node = ( ASTNode ) ( ( DefaultBindingResolver ) this . bindingResolver ) . bindingsToAstNodes . get ( this ) ; if ( ! ( node instanceof Annotation ) ) return null ; ASTNode parent = node . getParent ( ) ; IJavaElement parentElement = null ; switch ( parent . getNodeType ( ) ) { case ASTNode . PACKAGE_DECLARATION : IJavaElement cu = ( ( CompilationUnit ) parent . getParent ( ) ) . getJavaElement ( ) ; if ( cu instanceof ICompilationUnit ) { String pkgName = ( ( PackageDeclaration ) parent ) . getName ( ) . getFullyQualifiedName ( ) ; parentElement = ( ( ICompilationUnit ) cu ) . getPackageDeclaration ( pkgName ) ; } break ; case ASTNode . ENUM_DECLARATION : case ASTNode . TYPE_DECLARATION : case ASTNode . ANNOTATION_TYPE_DECLARATION : parentElement = ( ( AbstractTypeDeclaration ) parent ) . resolveBinding ( ) . getJavaElement ( ) ; break ; case ASTNode . FIELD_DECLARATION : VariableDeclarationFragment fragment = ( VariableDeclarationFragment ) ( ( FieldDeclaration ) parent ) . fragments ( ) . get ( <NUM_LIT:0> ) ; parentElement = fragment . resolveBinding ( ) . getJavaElement ( ) ; break ; case ASTNode . METHOD_DECLARATION : parentElement = ( ( MethodDeclaration ) parent ) . resolveBinding ( ) . getJavaElement ( ) ; break ; case ASTNode . VARIABLE_DECLARATION_STATEMENT : fragment = ( VariableDeclarationFragment ) ( ( VariableDeclarationStatement ) parent ) . fragments ( ) . get ( <NUM_LIT:0> ) ; parentElement = fragment . resolveBinding ( ) . getJavaElement ( ) ; break ; default : return null ; } if ( ! ( parentElement instanceof IAnnotatable ) ) return null ; if ( ( parentElement instanceof IMember ) && ( ( IMember ) parentElement ) . isBinary ( ) ) { return ( ( IAnnotatable ) parentElement ) . getAnnotation ( getAnnotationType ( ) . getQualifiedName ( ) ) ; } return ( ( IAnnotatable ) parentElement ) . getAnnotation ( getName ( ) ) ; } public String getKey ( ) { if ( this . key == null ) { String recipientKey = getRecipientKey ( ) ; this . key = new String ( this . binding . computeUniqueKey ( recipientKey . toCharArray ( ) ) ) ; } return this . key ; } private String getRecipientKey ( ) { if ( ! ( this . bindingResolver instanceof DefaultBindingResolver ) ) return "<STR_LIT>" ; DefaultBindingResolver resolver = ( DefaultBindingResolver ) this . bindingResolver ; ASTNode node = ( ASTNode ) resolver . bindingsToAstNodes . get ( this ) ; if ( node == null ) { return "<STR_LIT>" ; } ASTNode recipient = node . getParent ( ) ; switch ( recipient . getNodeType ( ) ) { case ASTNode . PACKAGE_DECLARATION : String pkgName = ( ( PackageDeclaration ) recipient ) . getName ( ) . getFullyQualifiedName ( ) ; return pkgName . replace ( '<CHAR_LIT:.>' , '<CHAR_LIT:/>' ) ; case ASTNode . TYPE_DECLARATION : return ( ( TypeDeclaration ) recipient ) . resolveBinding ( ) . getKey ( ) ; case ASTNode . FIELD_DECLARATION : VariableDeclarationFragment fragment = ( VariableDeclarationFragment ) ( ( FieldDeclaration ) recipient ) . fragments ( ) . get ( <NUM_LIT:0> ) ; return fragment . resolveBinding ( ) . getKey ( ) ; case ASTNode . METHOD_DECLARATION : return ( ( MethodDeclaration ) recipient ) . resolveBinding ( ) . getKey ( ) ; case ASTNode . VARIABLE_DECLARATION_STATEMENT : fragment = ( VariableDeclarationFragment ) ( ( VariableDeclarationStatement ) recipient ) . fragments ( ) . get ( <NUM_LIT:0> ) ; return fragment . resolveBinding ( ) . getKey ( ) ; default : return "<STR_LIT>" ; } } public int getKind ( ) { return IBinding . ANNOTATION ; } public int getModifiers ( ) { return Modifier . NONE ; } public String getName ( ) { ITypeBinding annotationType = getAnnotationType ( ) ; if ( annotationType == null ) { return new String ( this . binding . getAnnotationType ( ) . sourceName ( ) ) ; } else { return annotationType . getName ( ) ; } } public boolean isDeprecated ( ) { ReferenceBinding typeBinding = this . binding . getAnnotationType ( ) ; if ( typeBinding == null ) return false ; return typeBinding . isDeprecated ( ) ; } public boolean isEqualTo ( IBinding otherBinding ) { if ( this == otherBinding ) return true ; if ( otherBinding . getKind ( ) != IBinding . ANNOTATION ) return false ; IAnnotationBinding other = ( IAnnotationBinding ) otherBinding ; if ( ! getAnnotationType ( ) . isEqualTo ( other . getAnnotationType ( ) ) ) return false ; IMemberValuePairBinding [ ] memberValuePairs = getDeclaredMemberValuePairs ( ) ; IMemberValuePairBinding [ ] otherMemberValuePairs = other . getDeclaredMemberValuePairs ( ) ; if ( memberValuePairs . length != otherMemberValuePairs . length ) return false ; for ( int i = <NUM_LIT:0> , length = memberValuePairs . length ; i < length ; i ++ ) { if ( ! memberValuePairs [ i ] . isEqualTo ( otherMemberValuePairs [ i ] ) ) return false ; } return true ; } public boolean isRecovered ( ) { ReferenceBinding annotationType = this . binding . getAnnotationType ( ) ; return annotationType == null || ( annotationType . tagBits & TagBits . HasMissingType ) != <NUM_LIT:0> ; } public boolean isSynthetic ( ) { return false ; } public String toString ( ) { ITypeBinding type = getAnnotationType ( ) ; final StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( '<CHAR_LIT>' ) ; if ( type != null ) buffer . append ( type . getName ( ) ) ; buffer . append ( '<CHAR_LIT:(>' ) ; IMemberValuePairBinding [ ] pairs = getDeclaredMemberValuePairs ( ) ; for ( int i = <NUM_LIT:0> , len = pairs . length ; i < len ; i ++ ) { if ( i != <NUM_LIT:0> ) buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; buffer . append ( pairs [ i ] . toString ( ) ) ; } buffer . append ( '<CHAR_LIT:)>' ) ; return buffer . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; import org . eclipse . jdt . internal . compiler . util . Util ; class DefaultCommentMapper { Comment [ ] comments ; Scanner scanner ; int leadingPtr ; ASTNode [ ] leadingNodes ; long [ ] leadingIndexes ; int trailingPtr , lastTrailingPtr ; ASTNode [ ] trailingNodes ; long [ ] trailingIndexes ; static final int STORAGE_INCREMENT = <NUM_LIT:16> ; DefaultCommentMapper ( Comment [ ] table ) { this . comments = table ; } boolean hasSameTable ( Comment [ ] table ) { return this . comments == table ; } Comment getComment ( int position ) { if ( this . comments == null ) { return null ; } int size = this . comments . length ; if ( size == <NUM_LIT:0> ) { return null ; } int index = getCommentIndex ( <NUM_LIT:0> , position , <NUM_LIT:0> ) ; if ( index < <NUM_LIT:0> ) { return null ; } return this . comments [ index ] ; } private int getCommentIndex ( int start , int position , int exact ) { if ( position == <NUM_LIT:0> ) { if ( this . comments . length > <NUM_LIT:0> && this . comments [ <NUM_LIT:0> ] . getStartPosition ( ) == <NUM_LIT:0> ) { return <NUM_LIT:0> ; } return - <NUM_LIT:1> ; } int bottom = start , top = this . comments . length - <NUM_LIT:1> ; int i = <NUM_LIT:0> , index = - <NUM_LIT:1> ; Comment comment = null ; while ( bottom <= top ) { i = bottom + ( top - bottom ) / <NUM_LIT:2> ; comment = this . comments [ i ] ; int commentStart = comment . getStartPosition ( ) ; if ( position < commentStart ) { top = i - <NUM_LIT:1> ; } else if ( position >= ( commentStart + comment . getLength ( ) ) ) { bottom = i + <NUM_LIT:1> ; } else { index = i ; break ; } } if ( index < <NUM_LIT:0> && exact != <NUM_LIT:0> ) { comment = this . comments [ i ] ; if ( position < comment . getStartPosition ( ) ) { return exact < <NUM_LIT:0> ? i - <NUM_LIT:1> : i ; } else { return exact < <NUM_LIT:0> ? i : i + <NUM_LIT:1> ; } } return index ; } public int getExtendedStartPosition ( ASTNode node ) { if ( this . leadingPtr >= <NUM_LIT:0> ) { long range = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; range < <NUM_LIT:0> && i <= this . leadingPtr ; i ++ ) { if ( this . leadingNodes [ i ] == node ) range = this . leadingIndexes [ i ] ; } if ( range >= <NUM_LIT:0> ) { return this . comments [ ( int ) ( range > > <NUM_LIT:32> ) ] . getStartPosition ( ) ; } } return node . getStartPosition ( ) ; } public final int getLineNumber ( int position , int [ ] lineRange ) { int [ ] lineEnds = this . scanner . lineEnds ; int length = lineEnds . length ; return Util . getLineNumber ( position , lineEnds , ( lineRange [ <NUM_LIT:0> ] > length ? length : lineRange [ <NUM_LIT:0> ] ) - <NUM_LIT:1> , ( lineRange [ <NUM_LIT:1> ] > length ? length : lineRange [ <NUM_LIT:1> ] ) - <NUM_LIT:1> ) ; } public int getExtendedEnd ( ASTNode node ) { int end = node . getStartPosition ( ) + node . getLength ( ) ; if ( this . trailingPtr >= <NUM_LIT:0> ) { long range = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; range < <NUM_LIT:0> && i <= this . trailingPtr ; i ++ ) { if ( this . trailingNodes [ i ] == node ) range = this . trailingIndexes [ i ] ; } if ( range >= <NUM_LIT:0> ) { Comment lastComment = this . comments [ ( int ) range ] ; end = lastComment . getStartPosition ( ) + lastComment . getLength ( ) ; } } return end - <NUM_LIT:1> ; } public int getExtendedLength ( ASTNode node ) { return getExtendedEnd ( node ) - getExtendedStartPosition ( node ) + <NUM_LIT:1> ; } int firstLeadingCommentIndex ( ASTNode node ) { if ( this . leadingPtr >= <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i <= this . leadingPtr ; i ++ ) { if ( this . leadingNodes [ i ] == node ) { return ( int ) ( this . leadingIndexes [ i ] > > <NUM_LIT:32> ) ; } } } return - <NUM_LIT:1> ; } int lastTrailingCommentIndex ( ASTNode node ) { if ( this . trailingPtr >= <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> ; i <= this . trailingPtr ; i ++ ) { if ( this . trailingNodes [ i ] == node ) { return ( int ) this . trailingIndexes [ i ] ; } } } return - <NUM_LIT:1> ; } void initialize ( CompilationUnit unit , Scanner sc ) { this . leadingPtr = - <NUM_LIT:1> ; this . trailingPtr = - <NUM_LIT:1> ; this . comments = unit . optionalCommentTable ; if ( this . comments == null ) { return ; } int size = this . comments . length ; if ( size == <NUM_LIT:0> ) { return ; } this . scanner = sc ; this . scanner . tokenizeWhiteSpace = true ; DefaultASTVisitor commentVisitor = new CommentMapperVisitor ( ) ; unit . accept ( commentVisitor ) ; int leadingCount = this . leadingPtr + <NUM_LIT:1> ; if ( leadingCount > <NUM_LIT:0> && leadingCount < this . leadingIndexes . length ) { System . arraycopy ( this . leadingNodes , <NUM_LIT:0> , this . leadingNodes = new ASTNode [ leadingCount ] , <NUM_LIT:0> , leadingCount ) ; System . arraycopy ( this . leadingIndexes , <NUM_LIT:0> , this . leadingIndexes = new long [ leadingCount ] , <NUM_LIT:0> , leadingCount ) ; } if ( this . trailingPtr >= <NUM_LIT:0> ) { while ( this . trailingIndexes [ this . trailingPtr ] == - <NUM_LIT:1> ) { this . trailingPtr -- ; if ( this . trailingPtr < <NUM_LIT:0> ) { this . trailingIndexes = null ; this . trailingNodes = null ; break ; } } int trailingCount = this . trailingPtr + <NUM_LIT:1> ; if ( trailingCount > <NUM_LIT:0> && trailingCount < this . trailingIndexes . length ) { System . arraycopy ( this . trailingNodes , <NUM_LIT:0> , this . trailingNodes = new ASTNode [ trailingCount ] , <NUM_LIT:0> , trailingCount ) ; System . arraycopy ( this . trailingIndexes , <NUM_LIT:0> , this . trailingIndexes = new long [ trailingCount ] , <NUM_LIT:0> , trailingCount ) ; } } this . scanner = null ; } int storeLeadingComments ( ASTNode node , int previousEnd , int [ ] parentLineRange ) { int nodeStart = node . getStartPosition ( ) ; int extended = nodeStart ; int previousEndLine = getLineNumber ( previousEnd , parentLineRange ) ; int nodeStartLine = getLineNumber ( nodeStart , parentLineRange ) ; int idx = getCommentIndex ( <NUM_LIT:0> , nodeStart , - <NUM_LIT:1> ) ; if ( idx == - <NUM_LIT:1> ) { return nodeStart ; } int startIdx = - <NUM_LIT:1> ; int endIdx = idx ; int previousStart = nodeStart ; while ( idx >= <NUM_LIT:0> && previousStart >= previousEnd ) { Comment comment = this . comments [ idx ] ; int commentStart = comment . getStartPosition ( ) ; int end = commentStart + comment . getLength ( ) - <NUM_LIT:1> ; int commentLine = getLineNumber ( commentStart , parentLineRange ) ; if ( end <= previousEnd || ( commentLine == previousEndLine && commentLine != nodeStartLine ) ) { break ; } else if ( ( end + <NUM_LIT:1> ) < previousStart ) { this . scanner . resetTo ( end + <NUM_LIT:1> , previousStart ) ; try { int token = this . scanner . getNextToken ( ) ; if ( token != TerminalTokens . TokenNameWHITESPACE || this . scanner . currentPosition != previousStart ) { if ( idx == endIdx ) { return nodeStart ; } break ; } } catch ( InvalidInputException e ) { return nodeStart ; } char [ ] gap = this . scanner . getCurrentIdentifierSource ( ) ; int nbrLine = <NUM_LIT:0> ; int pos = - <NUM_LIT:1> ; while ( ( pos = CharOperation . indexOf ( '<STR_LIT:\n>' , gap , pos + <NUM_LIT:1> ) ) >= <NUM_LIT:0> ) { nbrLine ++ ; } if ( nbrLine > <NUM_LIT:1> ) { break ; } } previousStart = commentStart ; startIdx = idx -- ; } if ( startIdx != - <NUM_LIT:1> ) { int commentStart = this . comments [ startIdx ] . getStartPosition ( ) ; if ( previousEnd < commentStart && previousEndLine != nodeStartLine ) { int lastTokenEnd = previousEnd ; this . scanner . resetTo ( previousEnd , commentStart ) ; try { while ( this . scanner . currentPosition < commentStart ) { if ( this . scanner . getNextToken ( ) != TerminalTokens . TokenNameWHITESPACE ) { lastTokenEnd = this . scanner . getCurrentTokenEndPosition ( ) ; } } } catch ( InvalidInputException e ) { } int lastTokenLine = getLineNumber ( lastTokenEnd , parentLineRange ) ; int length = this . comments . length ; while ( startIdx < length && lastTokenLine == getLineNumber ( this . comments [ startIdx ] . getStartPosition ( ) , parentLineRange ) && nodeStartLine != lastTokenLine ) { startIdx ++ ; } } if ( startIdx <= endIdx ) { if ( ++ this . leadingPtr == <NUM_LIT:0> ) { this . leadingNodes = new ASTNode [ STORAGE_INCREMENT ] ; this . leadingIndexes = new long [ STORAGE_INCREMENT ] ; } else if ( this . leadingPtr == this . leadingNodes . length ) { int newLength = ( this . leadingPtr * <NUM_LIT:3> / <NUM_LIT:2> ) + STORAGE_INCREMENT ; System . arraycopy ( this . leadingNodes , <NUM_LIT:0> , this . leadingNodes = new ASTNode [ newLength ] , <NUM_LIT:0> , this . leadingPtr ) ; System . arraycopy ( this . leadingIndexes , <NUM_LIT:0> , this . leadingIndexes = new long [ newLength ] , <NUM_LIT:0> , this . leadingPtr ) ; } this . leadingNodes [ this . leadingPtr ] = node ; this . leadingIndexes [ this . leadingPtr ] = ( ( ( long ) startIdx ) << <NUM_LIT:32> ) + endIdx ; extended = this . comments [ endIdx ] . getStartPosition ( ) ; } } return extended ; } int storeTrailingComments ( ASTNode node , int nextStart , boolean lastChild , int [ ] parentLineRange ) { int nodeEnd = node . getStartPosition ( ) + node . getLength ( ) - <NUM_LIT:1> ; if ( nodeEnd == nextStart ) { if ( ++ this . trailingPtr == <NUM_LIT:0> ) { this . trailingNodes = new ASTNode [ STORAGE_INCREMENT ] ; this . trailingIndexes = new long [ STORAGE_INCREMENT ] ; this . lastTrailingPtr = - <NUM_LIT:1> ; } else if ( this . trailingPtr == this . trailingNodes . length ) { int newLength = ( this . trailingPtr * <NUM_LIT:3> / <NUM_LIT:2> ) + STORAGE_INCREMENT ; System . arraycopy ( this . trailingNodes , <NUM_LIT:0> , this . trailingNodes = new ASTNode [ newLength ] , <NUM_LIT:0> , this . trailingPtr ) ; System . arraycopy ( this . trailingIndexes , <NUM_LIT:0> , this . trailingIndexes = new long [ newLength ] , <NUM_LIT:0> , this . trailingPtr ) ; } this . trailingNodes [ this . trailingPtr ] = node ; this . trailingIndexes [ this . trailingPtr ] = - <NUM_LIT:1> ; return nodeEnd ; } int extended = nodeEnd ; int nodeEndLine = getLineNumber ( nodeEnd , parentLineRange ) ; int idx = getCommentIndex ( <NUM_LIT:0> , nodeEnd , <NUM_LIT:1> ) ; if ( idx == - <NUM_LIT:1> ) { return nodeEnd ; } int startIdx = idx ; int endIdx = - <NUM_LIT:1> ; int length = this . comments . length ; int commentStart = extended + <NUM_LIT:1> ; int previousEnd = nodeEnd + <NUM_LIT:1> ; int sameLineIdx = - <NUM_LIT:1> ; while ( idx < length && commentStart < nextStart ) { Comment comment = this . comments [ idx ] ; commentStart = comment . getStartPosition ( ) ; if ( commentStart >= nextStart ) { break ; } else if ( previousEnd < commentStart ) { this . scanner . resetTo ( previousEnd , commentStart ) ; try { int token = this . scanner . getNextToken ( ) ; if ( token != TerminalTokens . TokenNameWHITESPACE || this . scanner . currentPosition != commentStart ) { if ( idx == startIdx ) { return nodeEnd ; } break ; } } catch ( InvalidInputException e ) { return nodeEnd ; } char [ ] gap = this . scanner . getCurrentIdentifierSource ( ) ; int nbrLine = <NUM_LIT:0> ; int pos = - <NUM_LIT:1> ; while ( ( pos = CharOperation . indexOf ( '<STR_LIT:\n>' , gap , pos + <NUM_LIT:1> ) ) >= <NUM_LIT:0> ) { nbrLine ++ ; } if ( nbrLine > <NUM_LIT:1> ) { break ; } } int commentLine = getLineNumber ( commentStart , parentLineRange ) ; if ( commentLine == nodeEndLine ) { sameLineIdx = idx ; } previousEnd = commentStart + comment . getLength ( ) ; endIdx = idx ++ ; } if ( endIdx != - <NUM_LIT:1> ) { if ( ! lastChild ) { int nextLine = getLineNumber ( nextStart , parentLineRange ) ; int previousLine = getLineNumber ( previousEnd , parentLineRange ) ; if ( ( nextLine - previousLine ) <= <NUM_LIT:1> ) { if ( sameLineIdx == - <NUM_LIT:1> ) return nodeEnd ; endIdx = sameLineIdx ; } } if ( ++ this . trailingPtr == <NUM_LIT:0> ) { this . trailingNodes = new ASTNode [ STORAGE_INCREMENT ] ; this . trailingIndexes = new long [ STORAGE_INCREMENT ] ; this . lastTrailingPtr = - <NUM_LIT:1> ; } else if ( this . trailingPtr == this . trailingNodes . length ) { int newLength = ( this . trailingPtr * <NUM_LIT:3> / <NUM_LIT:2> ) + STORAGE_INCREMENT ; System . arraycopy ( this . trailingNodes , <NUM_LIT:0> , this . trailingNodes = new ASTNode [ newLength ] , <NUM_LIT:0> , this . trailingPtr ) ; System . arraycopy ( this . trailingIndexes , <NUM_LIT:0> , this . trailingIndexes = new long [ newLength ] , <NUM_LIT:0> , this . trailingPtr ) ; } this . trailingNodes [ this . trailingPtr ] = node ; long nodeRange = ( ( ( long ) startIdx ) << <NUM_LIT:32> ) + endIdx ; this . trailingIndexes [ this . trailingPtr ] = nodeRange ; extended = this . comments [ endIdx ] . getStartPosition ( ) + this . comments [ endIdx ] . getLength ( ) - <NUM_LIT:1> ; ASTNode previousNode = node ; int ptr = this . trailingPtr - <NUM_LIT:1> ; while ( ptr >= <NUM_LIT:0> ) { long range = this . trailingIndexes [ ptr ] ; if ( range != - <NUM_LIT:1> ) break ; ASTNode unresolved = this . trailingNodes [ ptr ] ; if ( previousNode != unresolved . getParent ( ) ) break ; this . trailingIndexes [ ptr ] = nodeRange ; previousNode = unresolved ; ptr -- ; } if ( ptr > this . lastTrailingPtr ) { int offset = ptr - this . lastTrailingPtr ; for ( int i = ptr + <NUM_LIT:1> ; i <= this . trailingPtr ; i ++ ) { this . trailingNodes [ i - offset ] = this . trailingNodes [ i ] ; this . trailingIndexes [ i - offset ] = this . trailingIndexes [ i ] ; } this . trailingPtr -= offset ; } this . lastTrailingPtr = this . trailingPtr ; } return extended ; } class CommentMapperVisitor extends DefaultASTVisitor { ASTNode topSiblingParent = null ; ASTNode [ ] siblings = new ASTNode [ <NUM_LIT:10> ] ; int [ ] [ ] parentLineRange = new int [ <NUM_LIT:10> ] [ ] ; int siblingPtr = - <NUM_LIT:1> ; protected boolean visitNode ( ASTNode node ) { ASTNode parent = node . getParent ( ) ; int previousEnd = parent . getStartPosition ( ) ; ASTNode sibling = parent == this . topSiblingParent ? ( ASTNode ) this . siblings [ this . siblingPtr ] : null ; if ( sibling != null ) { try { previousEnd = storeTrailingComments ( sibling , node . getStartPosition ( ) , false , this . parentLineRange [ this . siblingPtr ] ) ; } catch ( Exception ex ) { } } if ( ( node . typeAndFlags & ASTNode . MALFORMED ) != <NUM_LIT:0> ) { return false ; } int [ ] previousLineRange = this . siblingPtr > - <NUM_LIT:1> ? this . parentLineRange [ this . siblingPtr ] : new int [ ] { <NUM_LIT:1> , DefaultCommentMapper . this . scanner . linePtr + <NUM_LIT:1> } ; try { storeLeadingComments ( node , previousEnd , previousLineRange ) ; } catch ( Exception ex ) { } if ( this . topSiblingParent != parent ) { if ( this . siblings . length == ++ this . siblingPtr ) { System . arraycopy ( this . siblings , <NUM_LIT:0> , this . siblings = new ASTNode [ this . siblingPtr * <NUM_LIT:2> ] , <NUM_LIT:0> , this . siblingPtr ) ; System . arraycopy ( this . parentLineRange , <NUM_LIT:0> , this . parentLineRange = new int [ this . siblingPtr * <NUM_LIT:2> ] [ ] , <NUM_LIT:0> , this . siblingPtr ) ; } if ( this . topSiblingParent == null ) { this . parentLineRange [ this . siblingPtr ] = previousLineRange ; } else { int parentStart = parent . getStartPosition ( ) ; int firstLine = getLineNumber ( parentStart , previousLineRange ) ; int lastLine = getLineNumber ( parentStart + parent . getLength ( ) - <NUM_LIT:1> , previousLineRange ) ; if ( this . parentLineRange [ this . siblingPtr ] == null ) { this . parentLineRange [ this . siblingPtr ] = new int [ ] { firstLine , lastLine } ; } else { int [ ] lineRange = this . parentLineRange [ this . siblingPtr ] ; lineRange [ <NUM_LIT:0> ] = firstLine ; lineRange [ <NUM_LIT:1> ] = lastLine ; } } this . topSiblingParent = parent ; } this . siblings [ this . siblingPtr ] = node ; return true ; } protected void endVisitNode ( ASTNode node ) { ASTNode sibling = this . topSiblingParent == node ? ( ASTNode ) this . siblings [ this . siblingPtr ] : null ; if ( sibling != null ) { try { storeTrailingComments ( sibling , node . getStartPosition ( ) + node . getLength ( ) - <NUM_LIT:1> , true , this . parentLineRange [ this . siblingPtr ] ) ; } catch ( Exception ex ) { } } if ( this . topSiblingParent != null && this . topSiblingParent == node ) { this . siblingPtr -- ; this . topSiblingParent = node . getParent ( ) ; } } public boolean visit ( CompilationUnit node ) { return true ; } } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . Hashtable ; import java . util . List ; import java . util . Map ; import org . eclipse . text . edits . MultiTextEdit ; import org . eclipse . text . edits . TextEdit ; import org . eclipse . jface . text . IDocument ; import org . eclipse . jface . text . TextUtilities ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . dom . SimplePropertyDescriptor ; import org . eclipse . jdt . core . dom . StructuralPropertyDescriptor ; import org . eclipse . jdt . core . dom . rewrite . TargetSourceRangeComputer ; import org . eclipse . jdt . internal . compiler . parser . RecoveryScannerData ; import org . eclipse . jdt . internal . core . dom . rewrite . ASTRewriteAnalyzer ; import org . eclipse . jdt . internal . core . dom . rewrite . LineInformation ; import org . eclipse . jdt . internal . core . dom . rewrite . ListRewriteEvent ; import org . eclipse . jdt . internal . core . dom . rewrite . NodeInfoStore ; import org . eclipse . jdt . internal . core . dom . rewrite . NodeRewriteEvent ; import org . eclipse . jdt . internal . core . dom . rewrite . RewriteEventStore ; import org . eclipse . jdt . internal . core . dom . rewrite . RewriteEventStore . CopySourceInfo ; import org . eclipse . jdt . internal . core . dom . rewrite . RewriteEventStore . PropertyLocation ; class InternalASTRewrite extends NodeEventHandler { private CompilationUnit root ; protected final RewriteEventStore eventStore ; protected final NodeInfoStore nodeStore ; protected final Hashtable clonedNodes ; int cloneDepth = <NUM_LIT:0> ; public InternalASTRewrite ( CompilationUnit root ) { this . root = root ; this . eventStore = new RewriteEventStore ( ) ; this . nodeStore = new NodeInfoStore ( root . getAST ( ) ) ; this . clonedNodes = new Hashtable ( ) ; } public TextEdit rewriteAST ( IDocument document , Map options ) { TextEdit result = new MultiTextEdit ( ) ; final CompilationUnit rootNode = getRootNode ( ) ; if ( rootNode != null ) { TargetSourceRangeComputer xsrComputer = new TargetSourceRangeComputer ( ) { public SourceRange computeSourceRange ( ASTNode node ) { int extendedStartPosition = rootNode . getExtendedStartPosition ( node ) ; int extendedLength = rootNode . getExtendedLength ( node ) ; return new SourceRange ( extendedStartPosition , extendedLength ) ; } } ; char [ ] content = document . get ( ) . toCharArray ( ) ; LineInformation lineInfo = LineInformation . create ( document ) ; String lineDelim = TextUtilities . getDefaultLineDelimiter ( document ) ; List comments = rootNode . getCommentList ( ) ; Map currentOptions = options == null ? JavaCore . getOptions ( ) : options ; ASTRewriteAnalyzer visitor = new ASTRewriteAnalyzer ( content , lineInfo , lineDelim , result , this . eventStore , this . nodeStore , comments , currentOptions , xsrComputer , ( RecoveryScannerData ) rootNode . getStatementsRecoveryData ( ) ) ; rootNode . accept ( visitor ) ; } return result ; } private void markAsMoveOrCopyTarget ( ASTNode node , ASTNode newChild ) { ASTNode source = ( ASTNode ) this . clonedNodes . get ( newChild ) ; if ( source != null ) { if ( this . cloneDepth == <NUM_LIT:0> ) { PropertyLocation propertyLocation = this . eventStore . getPropertyLocation ( source , RewriteEventStore . ORIGINAL ) ; CopySourceInfo sourceInfo = this . eventStore . markAsCopySource ( propertyLocation . getParent ( ) , propertyLocation . getProperty ( ) , source , false ) ; this . nodeStore . markAsCopyTarget ( newChild , sourceInfo ) ; } } else if ( ( newChild . getFlags ( ) & ASTNode . ORIGINAL ) != <NUM_LIT:0> ) { PropertyLocation propertyLocation = this . eventStore . getPropertyLocation ( newChild , RewriteEventStore . ORIGINAL ) ; CopySourceInfo sourceInfo = this . eventStore . markAsCopySource ( propertyLocation . getParent ( ) , propertyLocation . getProperty ( ) , newChild , true ) ; this . nodeStore . markAsCopyTarget ( newChild , sourceInfo ) ; } } private CompilationUnit getRootNode ( ) { return this . root ; } public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; buf . append ( "<STR_LIT>" ) ; buf . append ( this . eventStore . toString ( ) ) ; return buf . toString ( ) ; } void preValueChangeEvent ( ASTNode node , SimplePropertyDescriptor property ) { getNodeEvent ( node , property ) ; } void postValueChangeEvent ( ASTNode node , SimplePropertyDescriptor property ) { NodeRewriteEvent event = getNodeEvent ( node , property ) ; event . setNewValue ( node . getStructuralProperty ( property ) ) ; } void preAddChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { if ( property . isChildProperty ( ) ) { NodeRewriteEvent event = getNodeEvent ( node , property ) ; event . setNewValue ( child ) ; if ( child != null ) { markAsMoveOrCopyTarget ( node , child ) ; } } else if ( property . isChildListProperty ( ) ) { getListEvent ( node , property ) ; } } void postAddChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { if ( property . isChildListProperty ( ) ) { ListRewriteEvent event = getListEvent ( node , property ) ; List list = ( List ) node . getStructuralProperty ( property ) ; int i = list . indexOf ( child ) ; int s = list . size ( ) ; int index ; if ( i + <NUM_LIT:1> < s ) { ASTNode nextNode = ( ASTNode ) list . get ( i + <NUM_LIT:1> ) ; index = event . getIndex ( nextNode , ListRewriteEvent . NEW ) ; } else { index = - <NUM_LIT:1> ; } event . insert ( child , index ) ; if ( child != null ) { markAsMoveOrCopyTarget ( node , child ) ; } } } void preRemoveChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { if ( property . isChildProperty ( ) ) { NodeRewriteEvent event = getNodeEvent ( node , property ) ; event . setNewValue ( null ) ; } else if ( property . isChildListProperty ( ) ) { ListRewriteEvent event = getListEvent ( node , property ) ; int i = event . getIndex ( child , ListRewriteEvent . NEW ) ; NodeRewriteEvent nodeEvent = ( NodeRewriteEvent ) event . getChildren ( ) [ i ] ; if ( nodeEvent . getOriginalValue ( ) == null ) { event . revertChange ( nodeEvent ) ; } else { nodeEvent . setNewValue ( null ) ; } } } void preReplaceChildEvent ( ASTNode node , ASTNode child , ASTNode newChild , StructuralPropertyDescriptor property ) { if ( property . isChildProperty ( ) ) { NodeRewriteEvent event = getNodeEvent ( node , property ) ; event . setNewValue ( newChild ) ; if ( newChild != null ) { markAsMoveOrCopyTarget ( node , newChild ) ; } } else if ( property . isChildListProperty ( ) ) { ListRewriteEvent event = getListEvent ( node , property ) ; int i = event . getIndex ( child , ListRewriteEvent . NEW ) ; NodeRewriteEvent nodeEvent = ( NodeRewriteEvent ) event . getChildren ( ) [ i ] ; nodeEvent . setNewValue ( newChild ) ; if ( newChild != null ) { markAsMoveOrCopyTarget ( node , newChild ) ; } } } void preCloneNodeEvent ( ASTNode node ) { this . cloneDepth ++ ; } void postCloneNodeEvent ( ASTNode node , ASTNode clone ) { if ( node . ast == this . root . ast && clone . ast == this . root . ast ) { if ( ( node . getFlags ( ) & ASTNode . ORIGINAL ) != <NUM_LIT:0> ) { this . clonedNodes . put ( clone , node ) ; } else { Object original = this . clonedNodes . get ( node ) ; if ( original != null ) { this . clonedNodes . put ( clone , original ) ; } } } this . cloneDepth -- ; } private NodeRewriteEvent getNodeEvent ( ASTNode node , StructuralPropertyDescriptor property ) { return this . eventStore . getNodeEvent ( node , property , true ) ; } private ListRewriteEvent getListEvent ( ASTNode node , StructuralPropertyDescriptor property ) { return this . eventStore . getListEvent ( node , property , true ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class SuperFieldAccess extends Expression { public static final ChildPropertyDescriptor QUALIFIER_PROPERTY = new ChildPropertyDescriptor ( SuperFieldAccess . class , "<STR_LIT>" , Name . class , OPTIONAL , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( SuperFieldAccess . class , "<STR_LIT:name>" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( SuperFieldAccess . class , propertyList ) ; addProperty ( QUALIFIER_PROPERTY , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Name optionalQualifier = null ; private SimpleName fieldName = null ; SuperFieldAccess ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == QUALIFIER_PROPERTY ) { if ( get ) { return getQualifier ( ) ; } else { setQualifier ( ( Name ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return SUPER_FIELD_ACCESS ; } ASTNode clone0 ( AST target ) { SuperFieldAccess result = new SuperFieldAccess ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setName ( ( SimpleName ) ASTNode . copySubtree ( target , getName ( ) ) ) ; result . setQualifier ( ( Name ) ASTNode . copySubtree ( target , getQualifier ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getQualifier ( ) ) ; acceptChild ( visitor , getName ( ) ) ; } visitor . endVisit ( this ) ; } public Name getQualifier ( ) { return this . optionalQualifier ; } public void setQualifier ( Name name ) { ASTNode oldChild = this . optionalQualifier ; preReplaceChild ( oldChild , name , QUALIFIER_PROPERTY ) ; this . optionalQualifier = name ; postReplaceChild ( oldChild , name , QUALIFIER_PROPERTY ) ; } public SimpleName getName ( ) { if ( this . fieldName == null ) { synchronized ( this ) { if ( this . fieldName == null ) { preLazyInit ( ) ; this . fieldName = new SimpleName ( this . ast ) ; postLazyInit ( this . fieldName , NAME_PROPERTY ) ; } } } return this . fieldName ; } public IVariableBinding resolveFieldBinding ( ) { return this . ast . getBindingResolver ( ) . resolveField ( this ) ; } public void setName ( SimpleName fieldName ) { if ( fieldName == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . fieldName ; preReplaceChild ( oldChild , fieldName , NAME_PROPERTY ) ; this . fieldName = fieldName ; postReplaceChild ( oldChild , fieldName , NAME_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalQualifier == null ? <NUM_LIT:0> : getQualifier ( ) . treeSize ( ) ) + ( this . fieldName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; public class Javadoc extends Comment { public static final SimplePropertyDescriptor COMMENT_PROPERTY = new SimplePropertyDescriptor ( Javadoc . class , "<STR_LIT>" , String . class , MANDATORY ) ; public static final ChildListPropertyDescriptor TAGS_PROPERTY = new ChildListPropertyDescriptor ( Javadoc . class , "<STR_LIT>" , TagElement . class , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List properyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( Javadoc . class , properyList ) ; addProperty ( COMMENT_PROPERTY , properyList ) ; addProperty ( TAGS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( properyList ) ; properyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( Javadoc . class , properyList ) ; addProperty ( TAGS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private static final String MINIMAL_DOC_COMMENT = "<STR_LIT>" ; private String comment = MINIMAL_DOC_COMMENT ; private ASTNode . NodeList tags = new ASTNode . NodeList ( TAGS_PROPERTY ) ; Javadoc ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final Object internalGetSetObjectProperty ( SimplePropertyDescriptor property , boolean get , Object value ) { if ( property == COMMENT_PROPERTY ) { if ( get ) { return getComment ( ) ; } else { setComment ( ( String ) value ) ; return null ; } } return super . internalGetSetObjectProperty ( property , get , value ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == TAGS_PROPERTY ) { return tags ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return JAVADOC ; } ASTNode clone0 ( AST target ) { Javadoc result = new Javadoc ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { result . setComment ( getComment ( ) ) ; } result . tags ( ) . addAll ( ASTNode . copySubtrees ( target , tags ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChildren ( visitor , this . tags ) ; } visitor . endVisit ( this ) ; } public String getComment ( ) { supportedOnlyIn2 ( ) ; return this . comment ; } public void setComment ( String docComment ) { supportedOnlyIn2 ( ) ; if ( docComment == null ) { throw new IllegalArgumentException ( ) ; } char [ ] source = docComment . toCharArray ( ) ; Scanner scanner = this . ast . scanner ; scanner . resetTo ( <NUM_LIT:0> , source . length ) ; scanner . setSource ( source ) ; try { int token ; boolean onlyOneComment = false ; while ( ( token = scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameCOMMENT_JAVADOC : if ( onlyOneComment ) { throw new IllegalArgumentException ( ) ; } onlyOneComment = true ; break ; default : onlyOneComment = false ; } } if ( ! onlyOneComment ) { throw new IllegalArgumentException ( ) ; } } catch ( InvalidInputException e ) { throw new IllegalArgumentException ( ) ; } preValueChange ( COMMENT_PROPERTY ) ; this . comment = docComment ; postValueChange ( COMMENT_PROPERTY ) ; } public List tags ( ) { return this . tags ; } int memSize ( ) { int size = super . memSize ( ) + <NUM_LIT:2> * <NUM_LIT:4> ; if ( this . comment != MINIMAL_DOC_COMMENT ) { size += stringSize ( this . comment ) ; } return size ; } int treeSize ( ) { return memSize ( ) + this . tags . listSize ( ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; public final class ChildPropertyDescriptor extends StructuralPropertyDescriptor { private final Class childClass ; private final boolean mandatory ; final boolean cycleRisk ; ChildPropertyDescriptor ( Class nodeClass , String propertyId , Class childType , boolean mandatory , boolean cycleRisk ) { super ( nodeClass , propertyId ) ; if ( childType == null || ! ASTNode . class . isAssignableFrom ( childType ) ) { throw new IllegalArgumentException ( ) ; } this . childClass = childType ; this . mandatory = mandatory ; this . cycleRisk = cycleRisk ; } public final Class getChildType ( ) { return this . childClass ; } public final boolean isMandatory ( ) { return this . mandatory ; } public final boolean cycleRisk ( ) { return this . cycleRisk ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public final class SingleMemberAnnotation extends Annotation { public static final ChildPropertyDescriptor TYPE_NAME_PROPERTY = internalTypeNamePropertyFactory ( SingleMemberAnnotation . class ) ; public static final ChildPropertyDescriptor VALUE_PROPERTY = new ChildPropertyDescriptor ( SingleMemberAnnotation . class , "<STR_LIT:value>" , Expression . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( SingleMemberAnnotation . class , propertyList ) ; addProperty ( TYPE_NAME_PROPERTY , propertyList ) ; addProperty ( VALUE_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Expression value = null ; SingleMemberAnnotation ( AST ast ) { super ( ast ) ; unsupportedIn2 ( ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == TYPE_NAME_PROPERTY ) { if ( get ) { return getTypeName ( ) ; } else { setTypeName ( ( Name ) child ) ; return null ; } } if ( property == VALUE_PROPERTY ) { if ( get ) { return getValue ( ) ; } else { setValue ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final ChildPropertyDescriptor internalTypeNameProperty ( ) { return TYPE_NAME_PROPERTY ; } final int getNodeType0 ( ) { return SINGLE_MEMBER_ANNOTATION ; } ASTNode clone0 ( AST target ) { SingleMemberAnnotation result = new SingleMemberAnnotation ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setTypeName ( ( Name ) ASTNode . copySubtree ( target , getTypeName ( ) ) ) ; result . setValue ( ( Expression ) ASTNode . copySubtree ( target , getValue ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getTypeName ( ) ) ; acceptChild ( visitor , getValue ( ) ) ; } visitor . endVisit ( this ) ; } public Expression getValue ( ) { if ( this . value == null ) { synchronized ( this ) { if ( this . value == null ) { preLazyInit ( ) ; this . value = new SimpleName ( this . ast ) ; postLazyInit ( this . value , VALUE_PROPERTY ) ; } } } return this . value ; } public void setValue ( Expression value ) { if ( value == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . value ; preReplaceChild ( oldChild , value , VALUE_PROPERTY ) ; this . value = value ; postReplaceChild ( oldChild , value , VALUE_PROPERTY ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:1> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . typeName == null ? <NUM_LIT:0> : getTypeName ( ) . treeSize ( ) ) + ( this . value == null ? <NUM_LIT:0> : getValue ( ) . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class QualifiedName extends Name { public static final ChildPropertyDescriptor QUALIFIER_PROPERTY = new ChildPropertyDescriptor ( QualifiedName . class , "<STR_LIT>" , Name . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( QualifiedName . class , "<STR_LIT:name>" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( QualifiedName . class , propertyList ) ; addProperty ( QUALIFIER_PROPERTY , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Name qualifier = null ; private SimpleName name = null ; QualifiedName ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == QUALIFIER_PROPERTY ) { if ( get ) { return getQualifier ( ) ; } else { setQualifier ( ( Name ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return QUALIFIED_NAME ; } ASTNode clone0 ( AST target ) { QualifiedName result = new QualifiedName ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setQualifier ( ( Name ) getQualifier ( ) . clone ( target ) ) ; result . setName ( ( SimpleName ) getName ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getQualifier ( ) ) ; acceptChild ( visitor , getName ( ) ) ; } visitor . endVisit ( this ) ; } public Name getQualifier ( ) { if ( this . qualifier == null ) { synchronized ( this ) { if ( this . qualifier == null ) { preLazyInit ( ) ; this . qualifier = new SimpleName ( this . ast ) ; postLazyInit ( this . qualifier , QUALIFIER_PROPERTY ) ; } } } return this . qualifier ; } public void setQualifier ( Name qualifier ) { if ( qualifier == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . qualifier ; preReplaceChild ( oldChild , qualifier , QUALIFIER_PROPERTY ) ; this . qualifier = qualifier ; postReplaceChild ( oldChild , qualifier , QUALIFIER_PROPERTY ) ; } public SimpleName getName ( ) { if ( this . name == null ) { synchronized ( this ) { if ( this . name == null ) { preLazyInit ( ) ; this . name = new SimpleName ( this . ast ) ; postLazyInit ( this . name , NAME_PROPERTY ) ; } } } return this . name ; } public void setName ( SimpleName name ) { if ( name == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . name ; preReplaceChild ( oldChild , name , NAME_PROPERTY ) ; this . name = name ; postReplaceChild ( oldChild , name , NAME_PROPERTY ) ; } void appendName ( StringBuffer buffer ) { getQualifier ( ) . appendName ( buffer ) ; buffer . append ( '<CHAR_LIT:.>' ) ; getName ( ) . appendName ( buffer ) ; } int memSize ( ) { return BASE_NAME_NODE_SIZE + <NUM_LIT:3> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . name == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) + ( this . qualifier == null ? <NUM_LIT:0> : getQualifier ( ) . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class TypeDeclarationStatement extends Statement { public static final ChildPropertyDescriptor TYPE_DECLARATION_PROPERTY = new ChildPropertyDescriptor ( TypeDeclarationStatement . class , "<STR_LIT>" , TypeDeclaration . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor DECLARATION_PROPERTY = new ChildPropertyDescriptor ( TypeDeclarationStatement . class , "<STR_LIT>" , AbstractTypeDeclaration . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List propertyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( TypeDeclarationStatement . class , propertyList ) ; addProperty ( TYPE_DECLARATION_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( propertyList ) ; propertyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( TypeDeclarationStatement . class , propertyList ) ; addProperty ( DECLARATION_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private AbstractTypeDeclaration typeDecl = null ; private ChildPropertyDescriptor typeDeclProperty ( ) { if ( getAST ( ) . apiLevel ( ) == AST . JLS2_INTERNAL ) { return TYPE_DECLARATION_PROPERTY ; } else { return DECLARATION_PROPERTY ; } } TypeDeclarationStatement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == TYPE_DECLARATION_PROPERTY ) { if ( get ) { return getTypeDeclaration ( ) ; } else { setTypeDeclaration ( ( TypeDeclaration ) child ) ; return null ; } } if ( property == DECLARATION_PROPERTY ) { if ( get ) { return getDeclaration ( ) ; } else { setDeclaration ( ( AbstractTypeDeclaration ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return TYPE_DECLARATION_STATEMENT ; } ASTNode clone0 ( AST target ) { TypeDeclarationStatement result = new TypeDeclarationStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; result . setDeclaration ( ( AbstractTypeDeclaration ) getDeclaration ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getDeclaration ( ) ) ; } visitor . endVisit ( this ) ; } public AbstractTypeDeclaration getDeclaration ( ) { if ( this . typeDecl == null ) { synchronized ( this ) { if ( this . typeDecl == null ) { preLazyInit ( ) ; this . typeDecl = new TypeDeclaration ( this . ast ) ; postLazyInit ( this . typeDecl , typeDeclProperty ( ) ) ; } } } return this . typeDecl ; } public void setDeclaration ( AbstractTypeDeclaration decl ) { if ( decl == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . typeDecl ; ChildPropertyDescriptor typeDeclProperty = typeDeclProperty ( ) ; preReplaceChild ( oldChild , decl , typeDeclProperty ) ; this . typeDecl = decl ; postReplaceChild ( oldChild , decl , typeDeclProperty ) ; } public TypeDeclaration getTypeDeclaration ( ) { return internalGetTypeDeclaration ( ) ; } final TypeDeclaration internalGetTypeDeclaration ( ) { supportedOnlyIn2 ( ) ; return ( TypeDeclaration ) getDeclaration ( ) ; } public void setTypeDeclaration ( TypeDeclaration decl ) { internalSetTypeDeclaration ( decl ) ; } final void internalSetTypeDeclaration ( TypeDeclaration decl ) { supportedOnlyIn2 ( ) ; setDeclaration ( decl ) ; } public ITypeBinding resolveBinding ( ) { AbstractTypeDeclaration d = getDeclaration ( ) ; if ( d instanceof TypeDeclaration ) { return ( ( TypeDeclaration ) d ) . resolveBinding ( ) ; } else if ( d instanceof AnnotationTypeDeclaration ) { return ( ( AnnotationTypeDeclaration ) d ) . resolveBinding ( ) ; } else { return null ; } } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:1> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . typeDecl == null ? <NUM_LIT:0> : getDeclaration ( ) . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class ArrayAccess extends Expression { public static final ChildPropertyDescriptor ARRAY_PROPERTY = new ChildPropertyDescriptor ( ArrayAccess . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor INDEX_PROPERTY = new ChildPropertyDescriptor ( ArrayAccess . class , "<STR_LIT:index>" , Expression . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( ArrayAccess . class , properyList ) ; addProperty ( ARRAY_PROPERTY , properyList ) ; addProperty ( INDEX_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Expression arrayExpression = null ; private Expression indexExpression = null ; ArrayAccess ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == ARRAY_PROPERTY ) { if ( get ) { return getArray ( ) ; } else { setArray ( ( Expression ) child ) ; return null ; } } if ( property == INDEX_PROPERTY ) { if ( get ) { return getIndex ( ) ; } else { setIndex ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return ARRAY_ACCESS ; } ASTNode clone0 ( AST target ) { ArrayAccess result = new ArrayAccess ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setArray ( ( Expression ) getArray ( ) . clone ( target ) ) ; result . setIndex ( ( Expression ) getIndex ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getArray ( ) ) ; acceptChild ( visitor , getIndex ( ) ) ; } visitor . endVisit ( this ) ; } public Expression getArray ( ) { if ( this . arrayExpression == null ) { synchronized ( this ) { if ( this . arrayExpression == null ) { preLazyInit ( ) ; this . arrayExpression = new SimpleName ( this . ast ) ; postLazyInit ( this . arrayExpression , ARRAY_PROPERTY ) ; } } } return this . arrayExpression ; } public void setArray ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . arrayExpression ; preReplaceChild ( oldChild , expression , ARRAY_PROPERTY ) ; this . arrayExpression = expression ; postReplaceChild ( oldChild , expression , ARRAY_PROPERTY ) ; } public Expression getIndex ( ) { if ( this . indexExpression == null ) { synchronized ( this ) { if ( this . indexExpression == null ) { preLazyInit ( ) ; this . indexExpression = new SimpleName ( this . ast ) ; postLazyInit ( this . indexExpression , INDEX_PROPERTY ) ; } } } return this . indexExpression ; } public void setIndex ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . indexExpression ; preReplaceChild ( oldChild , expression , INDEX_PROPERTY ) ; this . indexExpression = expression ; postReplaceChild ( oldChild , expression , INDEX_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . arrayExpression == null ? <NUM_LIT:0> : getArray ( ) . treeSize ( ) ) + ( this . indexExpression == null ? <NUM_LIT:0> : getIndex ( ) . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class IfStatement extends Statement { public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( IfStatement . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor THEN_STATEMENT_PROPERTY = new ChildPropertyDescriptor ( IfStatement . class , "<STR_LIT>" , Statement . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor ELSE_STATEMENT_PROPERTY = new ChildPropertyDescriptor ( IfStatement . class , "<STR_LIT>" , Statement . class , OPTIONAL , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( IfStatement . class , properyList ) ; addProperty ( EXPRESSION_PROPERTY , properyList ) ; addProperty ( THEN_STATEMENT_PROPERTY , properyList ) ; addProperty ( ELSE_STATEMENT_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Expression expression = null ; private Statement thenStatement = null ; private Statement optionalElseStatement = null ; IfStatement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } if ( property == THEN_STATEMENT_PROPERTY ) { if ( get ) { return getThenStatement ( ) ; } else { setThenStatement ( ( Statement ) child ) ; return null ; } } if ( property == ELSE_STATEMENT_PROPERTY ) { if ( get ) { return getElseStatement ( ) ; } else { setElseStatement ( ( Statement ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return IF_STATEMENT ; } ASTNode clone0 ( AST target ) { IfStatement result = new IfStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; result . setExpression ( ( Expression ) getExpression ( ) . clone ( target ) ) ; result . setThenStatement ( ( Statement ) getThenStatement ( ) . clone ( target ) ) ; result . setElseStatement ( ( Statement ) ASTNode . copySubtree ( target , getElseStatement ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getExpression ( ) ) ; acceptChild ( visitor , getThenStatement ( ) ) ; acceptChild ( visitor , getElseStatement ( ) ) ; } visitor . endVisit ( this ) ; } public Expression getExpression ( ) { if ( this . expression == null ) { synchronized ( this ) { if ( this . expression == null ) { preLazyInit ( ) ; this . expression = new SimpleName ( this . ast ) ; postLazyInit ( this . expression , EXPRESSION_PROPERTY ) ; } } } return this . expression ; } public void setExpression ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . expression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . expression = expression ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } public Statement getThenStatement ( ) { if ( this . thenStatement == null ) { synchronized ( this ) { if ( this . thenStatement == null ) { preLazyInit ( ) ; this . thenStatement = new Block ( this . ast ) ; postLazyInit ( this . thenStatement , THEN_STATEMENT_PROPERTY ) ; } } } return this . thenStatement ; } public void setThenStatement ( Statement statement ) { if ( statement == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . thenStatement ; preReplaceChild ( oldChild , statement , THEN_STATEMENT_PROPERTY ) ; this . thenStatement = statement ; postReplaceChild ( oldChild , statement , THEN_STATEMENT_PROPERTY ) ; } public Statement getElseStatement ( ) { return this . optionalElseStatement ; } public void setElseStatement ( Statement statement ) { ASTNode oldChild = this . optionalElseStatement ; preReplaceChild ( oldChild , statement , ELSE_STATEMENT_PROPERTY ) ; this . optionalElseStatement = statement ; postReplaceChild ( oldChild , statement , ELSE_STATEMENT_PROPERTY ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:3> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . expression == null ? <NUM_LIT:0> : getExpression ( ) . treeSize ( ) ) + ( this . thenStatement == null ? <NUM_LIT:0> : getThenStatement ( ) . treeSize ( ) ) + ( this . optionalElseStatement == null ? <NUM_LIT:0> : getElseStatement ( ) . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; public interface IVariableBinding extends IBinding { public boolean isField ( ) ; public boolean isEnumConstant ( ) ; public boolean isParameter ( ) ; public String getName ( ) ; public ITypeBinding getDeclaringClass ( ) ; public ITypeBinding getType ( ) ; public int getVariableId ( ) ; public Object getConstantValue ( ) ; public IMethodBinding getDeclaringMethod ( ) ; public IVariableBinding getVariableDeclaration ( ) ; } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class ParenthesizedExpression extends Expression { public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( ParenthesizedExpression . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( ParenthesizedExpression . class , propertyList ) ; addProperty ( EXPRESSION_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Expression expression = null ; ParenthesizedExpression ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return PARENTHESIZED_EXPRESSION ; } ASTNode clone0 ( AST target ) { ParenthesizedExpression result = new ParenthesizedExpression ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setExpression ( ( Expression ) getExpression ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getExpression ( ) ) ; } visitor . endVisit ( this ) ; } public Expression getExpression ( ) { if ( this . expression == null ) { synchronized ( this ) { if ( this . expression == null ) { preLazyInit ( ) ; this . expression = new SimpleName ( this . ast ) ; postLazyInit ( this . expression , EXPRESSION_PROPERTY ) ; } } } return this . expression ; } public void setExpression ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . expression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . expression = expression ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:1> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . expression == null ? <NUM_LIT:0> : getExpression ( ) . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class FieldDeclaration extends BodyDeclaration { public static final ChildPropertyDescriptor JAVADOC_PROPERTY = internalJavadocPropertyFactory ( FieldDeclaration . class ) ; public static final SimplePropertyDescriptor MODIFIERS_PROPERTY = internalModifiersPropertyFactory ( FieldDeclaration . class ) ; public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY = internalModifiers2PropertyFactory ( FieldDeclaration . class ) ; public static final ChildPropertyDescriptor TYPE_PROPERTY = new ChildPropertyDescriptor ( FieldDeclaration . class , "<STR_LIT:type>" , Type . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor FRAGMENTS_PROPERTY = new ChildListPropertyDescriptor ( FieldDeclaration . class , "<STR_LIT>" , VariableDeclarationFragment . class , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List properyList = new ArrayList ( <NUM_LIT:5> ) ; createPropertyList ( FieldDeclaration . class , properyList ) ; addProperty ( JAVADOC_PROPERTY , properyList ) ; addProperty ( MODIFIERS_PROPERTY , properyList ) ; addProperty ( TYPE_PROPERTY , properyList ) ; addProperty ( FRAGMENTS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( properyList ) ; properyList = new ArrayList ( <NUM_LIT:5> ) ; createPropertyList ( FieldDeclaration . class , properyList ) ; addProperty ( JAVADOC_PROPERTY , properyList ) ; addProperty ( MODIFIERS2_PROPERTY , properyList ) ; addProperty ( TYPE_PROPERTY , properyList ) ; addProperty ( FRAGMENTS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private Type baseType = null ; private ASTNode . NodeList variableDeclarationFragments = new ASTNode . NodeList ( FRAGMENTS_PROPERTY ) ; FieldDeclaration ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final int internalGetSetIntProperty ( SimplePropertyDescriptor property , boolean get , int value ) { if ( property == MODIFIERS_PROPERTY ) { if ( get ) { return getModifiers ( ) ; } else { internalSetModifiers ( value ) ; return <NUM_LIT:0> ; } } return super . internalGetSetIntProperty ( property , get , value ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == JAVADOC_PROPERTY ) { if ( get ) { return getJavadoc ( ) ; } else { setJavadoc ( ( Javadoc ) child ) ; return null ; } } if ( property == TYPE_PROPERTY ) { if ( get ) { return getType ( ) ; } else { setType ( ( Type ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == MODIFIERS2_PROPERTY ) { return modifiers ( ) ; } if ( property == FRAGMENTS_PROPERTY ) { return fragments ( ) ; } return super . internalGetChildListProperty ( property ) ; } final ChildPropertyDescriptor internalJavadocProperty ( ) { return JAVADOC_PROPERTY ; } final SimplePropertyDescriptor internalModifiersProperty ( ) { return MODIFIERS_PROPERTY ; } final ChildListPropertyDescriptor internalModifiers2Property ( ) { return MODIFIERS2_PROPERTY ; } final int getNodeType0 ( ) { return FIELD_DECLARATION ; } ASTNode clone0 ( AST target ) { FieldDeclaration result = new FieldDeclaration ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setJavadoc ( ( Javadoc ) ASTNode . copySubtree ( target , getJavadoc ( ) ) ) ; if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { result . internalSetModifiers ( getModifiers ( ) ) ; } if ( this . ast . apiLevel >= AST . JLS3 ) { result . modifiers ( ) . addAll ( ASTNode . copySubtrees ( target , modifiers ( ) ) ) ; } result . setType ( ( Type ) getType ( ) . clone ( target ) ) ; result . fragments ( ) . addAll ( ASTNode . copySubtrees ( target , fragments ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getJavadoc ( ) ) ; if ( this . ast . apiLevel >= AST . JLS3 ) { acceptChildren ( visitor , this . modifiers ) ; } acceptChild ( visitor , getType ( ) ) ; acceptChildren ( visitor , this . variableDeclarationFragments ) ; } visitor . endVisit ( this ) ; } public Type getType ( ) { if ( this . baseType == null ) { synchronized ( this ) { if ( this . baseType == null ) { preLazyInit ( ) ; this . baseType = this . ast . newPrimitiveType ( PrimitiveType . INT ) ; postLazyInit ( this . baseType , TYPE_PROPERTY ) ; } } } return this . baseType ; } public void setType ( Type type ) { if ( type == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . baseType ; preReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; this . baseType = type ; postReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; } public List fragments ( ) { return this . variableDeclarationFragments ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalDocComment == null ? <NUM_LIT:0> : getJavadoc ( ) . treeSize ( ) ) + ( this . modifiers == null ? <NUM_LIT:0> : this . modifiers . listSize ( ) ) + ( this . baseType == null ? <NUM_LIT:0> : getType ( ) . treeSize ( ) ) + this . variableDeclarationFragments . listSize ( ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . List ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . lookup . ArrayBinding ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . CompilationUnitScope ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . compiler . util . Util ; import org . eclipse . jdt . internal . core . PackageFragment ; class RecoveredTypeBinding implements ITypeBinding { private VariableDeclaration variableDeclaration ; private Type currentType ; private BindingResolver resolver ; private int dimensions ; private RecoveredTypeBinding innerTypeBinding ; private ITypeBinding [ ] typeArguments ; private org . eclipse . jdt . internal . compiler . lookup . TypeBinding binding ; RecoveredTypeBinding ( BindingResolver resolver , VariableDeclaration variableDeclaration ) { this . variableDeclaration = variableDeclaration ; this . resolver = resolver ; this . currentType = getType ( ) ; this . dimensions = variableDeclaration . getExtraDimensions ( ) ; if ( this . currentType . isArrayType ( ) ) { this . dimensions += ( ( ArrayType ) this . currentType ) . getDimensions ( ) ; } } RecoveredTypeBinding ( BindingResolver resolver , org . eclipse . jdt . internal . compiler . lookup . TypeBinding typeBinding ) { this . resolver = resolver ; this . dimensions = typeBinding . dimensions ( ) ; this . binding = typeBinding ; } RecoveredTypeBinding ( BindingResolver resolver , Type type ) { this . currentType = type ; this . resolver = resolver ; this . dimensions = <NUM_LIT:0> ; if ( type . isArrayType ( ) ) { this . dimensions += ( ( ArrayType ) type ) . getDimensions ( ) ; } } RecoveredTypeBinding ( BindingResolver resolver , RecoveredTypeBinding typeBinding , int dimensions ) { this . innerTypeBinding = typeBinding ; this . dimensions = typeBinding . getDimensions ( ) + dimensions ; this . resolver = resolver ; } public ITypeBinding createArrayType ( int dims ) { return this . resolver . getTypeBinding ( this , dims ) ; } public String getBinaryName ( ) { return null ; } public ITypeBinding getBound ( ) { return null ; } public ITypeBinding getGenericTypeOfWildcardType ( ) { return null ; } public int getRank ( ) { return - <NUM_LIT:1> ; } public ITypeBinding getComponentType ( ) { if ( this . dimensions == <NUM_LIT:0> ) return null ; return this . resolver . getTypeBinding ( this , - <NUM_LIT:1> ) ; } public IVariableBinding [ ] getDeclaredFields ( ) { return TypeBinding . NO_VARIABLE_BINDINGS ; } public IMethodBinding [ ] getDeclaredMethods ( ) { return TypeBinding . NO_METHOD_BINDINGS ; } public int getDeclaredModifiers ( ) { return <NUM_LIT:0> ; } public ITypeBinding [ ] getDeclaredTypes ( ) { return TypeBinding . NO_TYPE_BINDINGS ; } public ITypeBinding getDeclaringClass ( ) { return null ; } public IMethodBinding getDeclaringMethod ( ) { return null ; } public int getDimensions ( ) { return this . dimensions ; } public ITypeBinding getElementType ( ) { if ( this . binding != null ) { if ( this . binding . isArrayType ( ) ) { ArrayBinding arrayBinding = ( ArrayBinding ) this . binding ; return new RecoveredTypeBinding ( this . resolver , arrayBinding . leafComponentType ) ; } else { return new RecoveredTypeBinding ( this . resolver , this . binding ) ; } } if ( this . innerTypeBinding != null ) { return this . innerTypeBinding . getElementType ( ) ; } if ( this . currentType != null && this . currentType . isArrayType ( ) ) { return this . resolver . getTypeBinding ( ( ( ArrayType ) this . currentType ) . getElementType ( ) ) ; } if ( this . variableDeclaration != null && this . variableDeclaration . getExtraDimensions ( ) != <NUM_LIT:0> ) { return this . resolver . getTypeBinding ( getType ( ) ) ; } return null ; } public ITypeBinding getErasure ( ) { return this ; } public ITypeBinding [ ] getInterfaces ( ) { return TypeBinding . NO_TYPE_BINDINGS ; } public int getModifiers ( ) { return Modifier . NONE ; } public String getName ( ) { char [ ] brackets = new char [ this . dimensions * <NUM_LIT:2> ] ; for ( int i = this . dimensions * <NUM_LIT:2> - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -= <NUM_LIT:2> ) { brackets [ i ] = '<CHAR_LIT:]>' ; brackets [ i - <NUM_LIT:1> ] = '<CHAR_LIT:[>' ; } StringBuffer buffer = new StringBuffer ( getInternalName ( ) ) ; buffer . append ( brackets ) ; return String . valueOf ( buffer ) ; } private String getInternalName ( ) { if ( this . innerTypeBinding != null ) { return this . innerTypeBinding . getInternalName ( ) ; } ReferenceBinding referenceBinding = getReferenceBinding ( ) ; if ( referenceBinding != null ) { return new String ( referenceBinding . compoundName [ referenceBinding . compoundName . length - <NUM_LIT:1> ] ) ; } return getTypeNameFrom ( getType ( ) ) ; } public IPackageBinding getPackage ( ) { if ( this . binding != null ) { switch ( this . binding . kind ( ) ) { case Binding . BASE_TYPE : case Binding . ARRAY_TYPE : case Binding . TYPE_PARAMETER : case Binding . WILDCARD_TYPE : case Binding . INTERSECTION_TYPE : return null ; } IPackageBinding packageBinding = this . resolver . getPackageBinding ( this . binding . getPackage ( ) ) ; if ( packageBinding != null ) return packageBinding ; } if ( this . innerTypeBinding != null && this . dimensions > <NUM_LIT:0> ) { return null ; } CompilationUnitScope scope = this . resolver . scope ( ) ; if ( scope != null ) { return this . resolver . getPackageBinding ( scope . getCurrentPackage ( ) ) ; } return null ; } public String getQualifiedName ( ) { ReferenceBinding referenceBinding = getReferenceBinding ( ) ; if ( referenceBinding != null ) { StringBuffer buffer = new StringBuffer ( ) ; char [ ] brackets = new char [ this . dimensions * <NUM_LIT:2> ] ; for ( int i = this . dimensions * <NUM_LIT:2> - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -= <NUM_LIT:2> ) { brackets [ i ] = '<CHAR_LIT:]>' ; brackets [ i - <NUM_LIT:1> ] = '<CHAR_LIT:[>' ; } buffer . append ( CharOperation . toString ( referenceBinding . compoundName ) ) ; buffer . append ( brackets ) ; return String . valueOf ( buffer ) ; } else { return getName ( ) ; } } private ReferenceBinding getReferenceBinding ( ) { if ( this . binding != null ) { if ( this . binding . isArrayType ( ) ) { ArrayBinding arrayBinding = ( ArrayBinding ) this . binding ; if ( arrayBinding . leafComponentType instanceof ReferenceBinding ) { return ( ReferenceBinding ) arrayBinding . leafComponentType ; } } else if ( this . binding instanceof ReferenceBinding ) { return ( ReferenceBinding ) this . binding ; } } else if ( this . innerTypeBinding != null ) { return this . innerTypeBinding . getReferenceBinding ( ) ; } return null ; } public ITypeBinding getSuperclass ( ) { if ( getQualifiedName ( ) . equals ( "<STR_LIT>" ) ) { return null ; } return this . resolver . resolveWellKnownType ( "<STR_LIT>" ) ; } public ITypeBinding [ ] getTypeArguments ( ) { if ( this . binding != null ) { return this . typeArguments = TypeBinding . NO_TYPE_BINDINGS ; } if ( this . typeArguments != null ) { return this . typeArguments ; } if ( this . innerTypeBinding != null ) { return this . innerTypeBinding . getTypeArguments ( ) ; } if ( this . currentType . isParameterizedType ( ) ) { ParameterizedType parameterizedType = ( ParameterizedType ) this . currentType ; List typeArgumentsList = parameterizedType . typeArguments ( ) ; int size = typeArgumentsList . size ( ) ; ITypeBinding [ ] temp = new ITypeBinding [ size ] ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { ITypeBinding currentTypeBinding = ( ( Type ) typeArgumentsList . get ( i ) ) . resolveBinding ( ) ; if ( currentTypeBinding == null ) { return this . typeArguments = TypeBinding . NO_TYPE_BINDINGS ; } temp [ i ] = currentTypeBinding ; } return this . typeArguments = temp ; } return this . typeArguments = TypeBinding . NO_TYPE_BINDINGS ; } public ITypeBinding [ ] getTypeBounds ( ) { return TypeBinding . NO_TYPE_BINDINGS ; } public ITypeBinding getTypeDeclaration ( ) { return this ; } public ITypeBinding [ ] getTypeParameters ( ) { return TypeBinding . NO_TYPE_BINDINGS ; } public ITypeBinding getWildcard ( ) { return null ; } public boolean isAnnotation ( ) { return false ; } public boolean isAnonymous ( ) { return false ; } public boolean isArray ( ) { return false ; } public boolean isAssignmentCompatible ( ITypeBinding typeBinding ) { if ( "<STR_LIT>" . equals ( typeBinding . getQualifiedName ( ) ) ) { return true ; } return isEqualTo ( typeBinding ) ; } public boolean isCapture ( ) { return false ; } public boolean isCastCompatible ( ITypeBinding typeBinding ) { if ( "<STR_LIT>" . equals ( typeBinding . getQualifiedName ( ) ) ) { return true ; } return isEqualTo ( typeBinding ) ; } public boolean isClass ( ) { return true ; } public boolean isEnum ( ) { return false ; } public boolean isFromSource ( ) { return false ; } public boolean isGenericType ( ) { return false ; } public boolean isInterface ( ) { return false ; } public boolean isLocal ( ) { return false ; } public boolean isMember ( ) { return false ; } public boolean isNested ( ) { return false ; } public boolean isNullType ( ) { return false ; } public boolean isParameterizedType ( ) { if ( this . innerTypeBinding != null ) { return this . innerTypeBinding . isParameterizedType ( ) ; } if ( this . currentType != null ) { return this . currentType . isParameterizedType ( ) ; } return false ; } public boolean isPrimitive ( ) { return false ; } public boolean isRawType ( ) { return false ; } public boolean isSubTypeCompatible ( ITypeBinding typeBinding ) { if ( "<STR_LIT>" . equals ( typeBinding . getQualifiedName ( ) ) ) { return true ; } return isEqualTo ( typeBinding ) ; } public boolean isTopLevel ( ) { return true ; } public boolean isTypeVariable ( ) { return false ; } public boolean isUpperbound ( ) { return false ; } public boolean isWildcardType ( ) { return false ; } public IAnnotationBinding [ ] getAnnotations ( ) { return AnnotationBinding . NoAnnotations ; } public IJavaElement getJavaElement ( ) { IPackageBinding packageBinding = getPackage ( ) ; if ( packageBinding != null ) { final IJavaElement javaElement = packageBinding . getJavaElement ( ) ; if ( javaElement != null && javaElement . getElementType ( ) == IJavaElement . PACKAGE_FRAGMENT ) { return ( ( PackageFragment ) javaElement ) . getCompilationUnit ( getInternalName ( ) + SuffixConstants . SUFFIX_STRING_java ) ; } } return null ; } public String getKey ( ) { StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( "<STR_LIT>" ) ; if ( this . innerTypeBinding != null ) { buffer . append ( "<STR_LIT>" ) . append ( this . innerTypeBinding . getKey ( ) ) ; } else if ( this . currentType != null ) { buffer . append ( "<STR_LIT>" ) . append ( this . currentType . toString ( ) ) ; } else if ( this . binding != null ) { buffer . append ( "<STR_LIT>" ) . append ( this . binding . computeUniqueKey ( ) ) ; } else if ( this . variableDeclaration != null ) { buffer . append ( "<STR_LIT>" ) . append ( this . variableDeclaration . getClass ( ) ) . append ( this . variableDeclaration . getName ( ) . getIdentifier ( ) ) . append ( this . variableDeclaration . getExtraDimensions ( ) ) ; } buffer . append ( getDimensions ( ) ) ; if ( this . typeArguments != null ) { buffer . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> , max = this . typeArguments . length ; i < max ; i ++ ) { if ( i != <NUM_LIT:0> ) { buffer . append ( '<CHAR_LIT:U+002C>' ) ; } buffer . append ( this . typeArguments [ i ] . getKey ( ) ) ; } buffer . append ( '<CHAR_LIT:>>' ) ; } return String . valueOf ( buffer ) ; } public int getKind ( ) { return IBinding . TYPE ; } public boolean isDeprecated ( ) { return false ; } public boolean isEqualTo ( IBinding other ) { if ( ! other . isRecovered ( ) || other . getKind ( ) != IBinding . TYPE ) return false ; return getKey ( ) . equals ( other . getKey ( ) ) ; } public boolean isRecovered ( ) { return true ; } public boolean isSynthetic ( ) { return false ; } private String getTypeNameFrom ( Type type ) { if ( type == null ) return Util . EMPTY_STRING ; switch ( type . getNodeType0 ( ) ) { case ASTNode . ARRAY_TYPE : ArrayType arrayType = ( ArrayType ) type ; type = arrayType . getElementType ( ) ; return getTypeNameFrom ( type ) ; case ASTNode . PARAMETERIZED_TYPE : ParameterizedType parameterizedType = ( ParameterizedType ) type ; StringBuffer buffer = new StringBuffer ( getTypeNameFrom ( parameterizedType . getType ( ) ) ) ; ITypeBinding [ ] tArguments = getTypeArguments ( ) ; final int typeArgumentsLength = tArguments . length ; if ( typeArgumentsLength != <NUM_LIT:0> ) { buffer . append ( '<CHAR_LIT>' ) ; for ( int i = <NUM_LIT:0> ; i < typeArgumentsLength ; i ++ ) { if ( i > <NUM_LIT:0> ) { buffer . append ( '<CHAR_LIT:U+002C>' ) ; } buffer . append ( tArguments [ i ] . getName ( ) ) ; } buffer . append ( '<CHAR_LIT:>>' ) ; } return String . valueOf ( buffer ) ; case ASTNode . PRIMITIVE_TYPE : PrimitiveType primitiveType = ( PrimitiveType ) type ; return primitiveType . getPrimitiveTypeCode ( ) . toString ( ) ; case ASTNode . QUALIFIED_TYPE : QualifiedType qualifiedType = ( QualifiedType ) type ; return qualifiedType . getName ( ) . getIdentifier ( ) ; case ASTNode . SIMPLE_TYPE : SimpleType simpleType = ( SimpleType ) type ; Name name = simpleType . getName ( ) ; if ( name . isQualifiedName ( ) ) { QualifiedName qualifiedName = ( QualifiedName ) name ; return qualifiedName . getName ( ) . getIdentifier ( ) ; } return ( ( SimpleName ) name ) . getIdentifier ( ) ; } return Util . EMPTY_STRING ; } private Type getType ( ) { if ( this . currentType != null ) { return this . currentType ; } if ( this . variableDeclaration == null ) return null ; switch ( this . variableDeclaration . getNodeType ( ) ) { case ASTNode . SINGLE_VARIABLE_DECLARATION : SingleVariableDeclaration singleVariableDeclaration = ( SingleVariableDeclaration ) this . variableDeclaration ; return singleVariableDeclaration . getType ( ) ; default : ASTNode parent = this . variableDeclaration . getParent ( ) ; switch ( parent . getNodeType ( ) ) { case ASTNode . VARIABLE_DECLARATION_EXPRESSION : VariableDeclarationExpression variableDeclarationExpression = ( VariableDeclarationExpression ) parent ; return variableDeclarationExpression . getType ( ) ; case ASTNode . VARIABLE_DECLARATION_STATEMENT : VariableDeclarationStatement statement = ( VariableDeclarationStatement ) parent ; return statement . getType ( ) ; case ASTNode . FIELD_DECLARATION : FieldDeclaration fieldDeclaration = ( FieldDeclaration ) parent ; return fieldDeclaration . getType ( ) ; } } return null ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class ThisExpression extends Expression { public static final ChildPropertyDescriptor QUALIFIER_PROPERTY = new ChildPropertyDescriptor ( ThisExpression . class , "<STR_LIT>" , Name . class , OPTIONAL , NO_CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( ThisExpression . class , propertyList ) ; addProperty ( QUALIFIER_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Name optionalQualifier = null ; ThisExpression ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == QUALIFIER_PROPERTY ) { if ( get ) { return getQualifier ( ) ; } else { setQualifier ( ( Name ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return THIS_EXPRESSION ; } ASTNode clone0 ( AST target ) { ThisExpression result = new ThisExpression ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setQualifier ( ( Name ) ASTNode . copySubtree ( target , getQualifier ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getQualifier ( ) ) ; } visitor . endVisit ( this ) ; } public Name getQualifier ( ) { return this . optionalQualifier ; } public void setQualifier ( Name name ) { ASTNode oldChild = this . optionalQualifier ; preReplaceChild ( oldChild , name , QUALIFIER_PROPERTY ) ; this . optionalQualifier = name ; postReplaceChild ( oldChild , name , QUALIFIER_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:1> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalQualifier == null ? <NUM_LIT:0> : getQualifier ( ) . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class TryStatement extends Statement { public static final ChildPropertyDescriptor BODY_PROPERTY = new ChildPropertyDescriptor ( TryStatement . class , "<STR_LIT:body>" , Block . class , MANDATORY , CYCLE_RISK ) ; public static final ChildListPropertyDescriptor CATCH_CLAUSES_PROPERTY = new ChildListPropertyDescriptor ( TryStatement . class , "<STR_LIT>" , CatchClause . class , CYCLE_RISK ) ; public static final ChildPropertyDescriptor FINALLY_PROPERTY = new ChildPropertyDescriptor ( TryStatement . class , "<STR_LIT>" , Block . class , OPTIONAL , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( TryStatement . class , propertyList ) ; addProperty ( BODY_PROPERTY , propertyList ) ; addProperty ( CATCH_CLAUSES_PROPERTY , propertyList ) ; addProperty ( FINALLY_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Block body = null ; private ASTNode . NodeList catchClauses = new ASTNode . NodeList ( CATCH_CLAUSES_PROPERTY ) ; private Block optionalFinallyBody = null ; TryStatement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == BODY_PROPERTY ) { if ( get ) { return getBody ( ) ; } else { setBody ( ( Block ) child ) ; return null ; } } if ( property == FINALLY_PROPERTY ) { if ( get ) { return getFinally ( ) ; } else { setFinally ( ( Block ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == CATCH_CLAUSES_PROPERTY ) { return catchClauses ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return TRY_STATEMENT ; } ASTNode clone0 ( AST target ) { TryStatement result = new TryStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; result . setBody ( ( Block ) getBody ( ) . clone ( target ) ) ; result . catchClauses ( ) . addAll ( ASTNode . copySubtrees ( target , catchClauses ( ) ) ) ; result . setFinally ( ( Block ) ASTNode . copySubtree ( target , getFinally ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getBody ( ) ) ; acceptChildren ( visitor , this . catchClauses ) ; acceptChild ( visitor , getFinally ( ) ) ; } visitor . endVisit ( this ) ; } public Block getBody ( ) { if ( this . body == null ) { synchronized ( this ) { if ( this . body == null ) { preLazyInit ( ) ; this . body = new Block ( this . ast ) ; postLazyInit ( this . body , BODY_PROPERTY ) ; } } } return this . body ; } public void setBody ( Block body ) { if ( body == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . body ; preReplaceChild ( oldChild , body , BODY_PROPERTY ) ; this . body = body ; postReplaceChild ( oldChild , body , BODY_PROPERTY ) ; } public List catchClauses ( ) { return this . catchClauses ; } public Block getFinally ( ) { return this . optionalFinallyBody ; } public void setFinally ( Block block ) { ASTNode oldChild = this . optionalFinallyBody ; preReplaceChild ( oldChild , block , FINALLY_PROPERTY ) ; this . optionalFinallyBody = block ; postReplaceChild ( oldChild , block , FINALLY_PROPERTY ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:3> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . body == null ? <NUM_LIT:0> : getBody ( ) . treeSize ( ) ) + this . catchClauses . listSize ( ) + ( this . optionalFinallyBody == null ? <NUM_LIT:0> : getFinally ( ) . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class AnonymousClassDeclaration extends ASTNode { public static final ChildListPropertyDescriptor BODY_DECLARATIONS_PROPERTY = new ChildListPropertyDescriptor ( AnonymousClassDeclaration . class , "<STR_LIT>" , BodyDeclaration . class , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( AnonymousClassDeclaration . class , properyList ) ; addProperty ( BODY_DECLARATIONS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private ASTNode . NodeList bodyDeclarations = new ASTNode . NodeList ( BODY_DECLARATIONS_PROPERTY ) ; AnonymousClassDeclaration ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == BODY_DECLARATIONS_PROPERTY ) { return bodyDeclarations ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return ANONYMOUS_CLASS_DECLARATION ; } ASTNode clone0 ( AST target ) { AnonymousClassDeclaration result = new AnonymousClassDeclaration ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . bodyDeclarations ( ) . addAll ( ASTNode . copySubtrees ( target , bodyDeclarations ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChildren ( visitor , this . bodyDeclarations ) ; } visitor . endVisit ( this ) ; } public List bodyDeclarations ( ) { return this . bodyDeclarations ; } public ITypeBinding resolveBinding ( ) { return this . ast . getBindingResolver ( ) . resolveType ( this ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + this . bodyDeclarations . listSize ( ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class FieldAccess extends Expression { public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( FieldAccess . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( FieldAccess . class , "<STR_LIT:name>" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( FieldAccess . class , properyList ) ; addProperty ( EXPRESSION_PROPERTY , properyList ) ; addProperty ( NAME_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Expression expression = null ; private SimpleName fieldName = null ; FieldAccess ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return FIELD_ACCESS ; } ASTNode clone0 ( AST target ) { FieldAccess result = new FieldAccess ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setExpression ( ( Expression ) getExpression ( ) . clone ( target ) ) ; result . setName ( ( SimpleName ) getName ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getExpression ( ) ) ; acceptChild ( visitor , getName ( ) ) ; } visitor . endVisit ( this ) ; } public Expression getExpression ( ) { if ( this . expression == null ) { synchronized ( this ) { if ( this . expression == null ) { preLazyInit ( ) ; this . expression = new SimpleName ( this . ast ) ; postLazyInit ( this . expression , EXPRESSION_PROPERTY ) ; } } } return this . expression ; } public void setExpression ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . expression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . expression = expression ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } public SimpleName getName ( ) { if ( this . fieldName == null ) { synchronized ( this ) { if ( this . fieldName == null ) { preLazyInit ( ) ; this . fieldName = new SimpleName ( this . ast ) ; postLazyInit ( this . fieldName , NAME_PROPERTY ) ; } } } return this . fieldName ; } public void setName ( SimpleName fieldName ) { if ( fieldName == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . fieldName ; preReplaceChild ( oldChild , fieldName , NAME_PROPERTY ) ; this . fieldName = fieldName ; postReplaceChild ( oldChild , fieldName , NAME_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:2> * <NUM_LIT:4> ; } public IVariableBinding resolveFieldBinding ( ) { return this . ast . getBindingResolver ( ) . resolveField ( this ) ; } int treeSize ( ) { return memSize ( ) + ( this . expression == null ? <NUM_LIT:0> : getExpression ( ) . treeSize ( ) ) + ( this . fieldName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class MethodDeclaration extends BodyDeclaration { public static final ChildPropertyDescriptor JAVADOC_PROPERTY = internalJavadocPropertyFactory ( MethodDeclaration . class ) ; public static final SimplePropertyDescriptor MODIFIERS_PROPERTY = internalModifiersPropertyFactory ( MethodDeclaration . class ) ; public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY = internalModifiers2PropertyFactory ( MethodDeclaration . class ) ; public static final SimplePropertyDescriptor CONSTRUCTOR_PROPERTY = new SimplePropertyDescriptor ( MethodDeclaration . class , "<STR_LIT>" , boolean . class , MANDATORY ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( MethodDeclaration . class , "<STR_LIT:name>" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor RETURN_TYPE_PROPERTY = new ChildPropertyDescriptor ( MethodDeclaration . class , "<STR_LIT>" , Type . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor RETURN_TYPE2_PROPERTY = new ChildPropertyDescriptor ( MethodDeclaration . class , "<STR_LIT>" , Type . class , OPTIONAL , NO_CYCLE_RISK ) ; public static final SimplePropertyDescriptor EXTRA_DIMENSIONS_PROPERTY = new SimplePropertyDescriptor ( MethodDeclaration . class , "<STR_LIT>" , int . class , MANDATORY ) ; public static final ChildListPropertyDescriptor TYPE_PARAMETERS_PROPERTY = new ChildListPropertyDescriptor ( MethodDeclaration . class , "<STR_LIT>" , TypeParameter . class , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor PARAMETERS_PROPERTY = new ChildListPropertyDescriptor ( MethodDeclaration . class , "<STR_LIT>" , SingleVariableDeclaration . class , CYCLE_RISK ) ; public static final ChildListPropertyDescriptor THROWN_EXCEPTIONS_PROPERTY = new ChildListPropertyDescriptor ( MethodDeclaration . class , "<STR_LIT>" , Name . class , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor BODY_PROPERTY = new ChildPropertyDescriptor ( MethodDeclaration . class , "<STR_LIT:body>" , Block . class , OPTIONAL , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List propertyList = new ArrayList ( <NUM_LIT:10> ) ; createPropertyList ( MethodDeclaration . class , propertyList ) ; addProperty ( JAVADOC_PROPERTY , propertyList ) ; addProperty ( MODIFIERS_PROPERTY , propertyList ) ; addProperty ( CONSTRUCTOR_PROPERTY , propertyList ) ; addProperty ( RETURN_TYPE_PROPERTY , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; addProperty ( PARAMETERS_PROPERTY , propertyList ) ; addProperty ( EXTRA_DIMENSIONS_PROPERTY , propertyList ) ; addProperty ( THROWN_EXCEPTIONS_PROPERTY , propertyList ) ; addProperty ( BODY_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( propertyList ) ; propertyList = new ArrayList ( <NUM_LIT:11> ) ; createPropertyList ( MethodDeclaration . class , propertyList ) ; addProperty ( JAVADOC_PROPERTY , propertyList ) ; addProperty ( MODIFIERS2_PROPERTY , propertyList ) ; addProperty ( CONSTRUCTOR_PROPERTY , propertyList ) ; addProperty ( TYPE_PARAMETERS_PROPERTY , propertyList ) ; addProperty ( RETURN_TYPE2_PROPERTY , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; addProperty ( PARAMETERS_PROPERTY , propertyList ) ; addProperty ( EXTRA_DIMENSIONS_PROPERTY , propertyList ) ; addProperty ( THROWN_EXCEPTIONS_PROPERTY , propertyList ) ; addProperty ( BODY_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private boolean isConstructor = false ; private SimpleName methodName = null ; private ASTNode . NodeList parameters = new ASTNode . NodeList ( PARAMETERS_PROPERTY ) ; private Type returnType = null ; private boolean returnType2Initialized = false ; private ASTNode . NodeList typeParameters = null ; private int extraArrayDimensions = <NUM_LIT:0> ; private ASTNode . NodeList thrownExceptions = new ASTNode . NodeList ( THROWN_EXCEPTIONS_PROPERTY ) ; private Block optionalBody = null ; MethodDeclaration ( AST ast ) { super ( ast ) ; if ( ast . apiLevel >= AST . JLS3 ) { this . typeParameters = new ASTNode . NodeList ( TYPE_PARAMETERS_PROPERTY ) ; } } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final int internalGetSetIntProperty ( SimplePropertyDescriptor property , boolean get , int value ) { if ( property == MODIFIERS_PROPERTY ) { if ( get ) { return getModifiers ( ) ; } else { internalSetModifiers ( value ) ; return <NUM_LIT:0> ; } } if ( property == EXTRA_DIMENSIONS_PROPERTY ) { if ( get ) { return getExtraDimensions ( ) ; } else { setExtraDimensions ( value ) ; return <NUM_LIT:0> ; } } return super . internalGetSetIntProperty ( property , get , value ) ; } final boolean internalGetSetBooleanProperty ( SimplePropertyDescriptor property , boolean get , boolean value ) { if ( property == CONSTRUCTOR_PROPERTY ) { if ( get ) { return isConstructor ( ) ; } else { setConstructor ( value ) ; return false ; } } return super . internalGetSetBooleanProperty ( property , get , value ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == JAVADOC_PROPERTY ) { if ( get ) { return getJavadoc ( ) ; } else { setJavadoc ( ( Javadoc ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } if ( property == RETURN_TYPE_PROPERTY ) { if ( get ) { return getReturnType ( ) ; } else { setReturnType ( ( Type ) child ) ; return null ; } } if ( property == RETURN_TYPE2_PROPERTY ) { if ( get ) { return getReturnType2 ( ) ; } else { setReturnType2 ( ( Type ) child ) ; return null ; } } if ( property == BODY_PROPERTY ) { if ( get ) { return getBody ( ) ; } else { setBody ( ( Block ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == MODIFIERS2_PROPERTY ) { return modifiers ( ) ; } if ( property == TYPE_PARAMETERS_PROPERTY ) { return typeParameters ( ) ; } if ( property == PARAMETERS_PROPERTY ) { return parameters ( ) ; } if ( property == THROWN_EXCEPTIONS_PROPERTY ) { return thrownExceptions ( ) ; } return super . internalGetChildListProperty ( property ) ; } final ChildPropertyDescriptor internalJavadocProperty ( ) { return JAVADOC_PROPERTY ; } final ChildListPropertyDescriptor internalModifiers2Property ( ) { return MODIFIERS2_PROPERTY ; } final SimplePropertyDescriptor internalModifiersProperty ( ) { return MODIFIERS_PROPERTY ; } final int getNodeType0 ( ) { return METHOD_DECLARATION ; } ASTNode clone0 ( AST target ) { MethodDeclaration result = new MethodDeclaration ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setJavadoc ( ( Javadoc ) ASTNode . copySubtree ( target , getJavadoc ( ) ) ) ; if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { result . internalSetModifiers ( getModifiers ( ) ) ; result . setReturnType ( ( Type ) ASTNode . copySubtree ( target , getReturnType ( ) ) ) ; } if ( this . ast . apiLevel >= AST . JLS3 ) { result . modifiers ( ) . addAll ( ASTNode . copySubtrees ( target , modifiers ( ) ) ) ; result . typeParameters ( ) . addAll ( ASTNode . copySubtrees ( target , typeParameters ( ) ) ) ; result . setReturnType2 ( ( Type ) ASTNode . copySubtree ( target , getReturnType2 ( ) ) ) ; } result . setConstructor ( isConstructor ( ) ) ; result . setExtraDimensions ( getExtraDimensions ( ) ) ; result . setName ( ( SimpleName ) getName ( ) . clone ( target ) ) ; result . parameters ( ) . addAll ( ASTNode . copySubtrees ( target , parameters ( ) ) ) ; result . thrownExceptions ( ) . addAll ( ASTNode . copySubtrees ( target , thrownExceptions ( ) ) ) ; result . setBody ( ( Block ) ASTNode . copySubtree ( target , getBody ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getJavadoc ( ) ) ; if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { acceptChild ( visitor , getReturnType ( ) ) ; } else { acceptChildren ( visitor , this . modifiers ) ; acceptChildren ( visitor , this . typeParameters ) ; acceptChild ( visitor , getReturnType2 ( ) ) ; } acceptChild ( visitor , getName ( ) ) ; acceptChildren ( visitor , this . parameters ) ; acceptChildren ( visitor , this . thrownExceptions ) ; acceptChild ( visitor , getBody ( ) ) ; } visitor . endVisit ( this ) ; } public boolean isConstructor ( ) { return this . isConstructor ; } public void setConstructor ( boolean isConstructor ) { preValueChange ( CONSTRUCTOR_PROPERTY ) ; this . isConstructor = isConstructor ; postValueChange ( CONSTRUCTOR_PROPERTY ) ; } public List typeParameters ( ) { if ( this . typeParameters == null ) { unsupportedIn2 ( ) ; } return this . typeParameters ; } public SimpleName getName ( ) { if ( this . methodName == null ) { synchronized ( this ) { if ( this . methodName == null ) { preLazyInit ( ) ; this . methodName = new SimpleName ( this . ast ) ; postLazyInit ( this . methodName , NAME_PROPERTY ) ; } } } return this . methodName ; } public void setName ( SimpleName methodName ) { if ( methodName == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . methodName ; preReplaceChild ( oldChild , methodName , NAME_PROPERTY ) ; this . methodName = methodName ; postReplaceChild ( oldChild , methodName , NAME_PROPERTY ) ; } public List parameters ( ) { return this . parameters ; } public boolean isVarargs ( ) { if ( this . modifiers == null ) { unsupportedIn2 ( ) ; } if ( parameters ( ) . isEmpty ( ) ) { return false ; } else { SingleVariableDeclaration v = ( SingleVariableDeclaration ) parameters ( ) . get ( parameters ( ) . size ( ) - <NUM_LIT:1> ) ; return v . isVarargs ( ) ; } } public List thrownExceptions ( ) { return this . thrownExceptions ; } public Type getReturnType ( ) { return internalGetReturnType ( ) ; } final Type internalGetReturnType ( ) { supportedOnlyIn2 ( ) ; if ( this . returnType == null ) { synchronized ( this ) { if ( this . returnType == null ) { preLazyInit ( ) ; this . returnType = this . ast . newPrimitiveType ( PrimitiveType . VOID ) ; postLazyInit ( this . returnType , RETURN_TYPE_PROPERTY ) ; } } } return this . returnType ; } public void setReturnType ( Type type ) { internalSetReturnType ( type ) ; } void internalSetReturnType ( Type type ) { supportedOnlyIn2 ( ) ; if ( type == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . returnType ; preReplaceChild ( oldChild , type , RETURN_TYPE_PROPERTY ) ; this . returnType = type ; postReplaceChild ( oldChild , type , RETURN_TYPE_PROPERTY ) ; } public Type getReturnType2 ( ) { unsupportedIn2 ( ) ; if ( this . returnType == null && ! this . returnType2Initialized ) { synchronized ( this ) { if ( this . returnType == null && ! this . returnType2Initialized ) { preLazyInit ( ) ; this . returnType = this . ast . newPrimitiveType ( PrimitiveType . VOID ) ; this . returnType2Initialized = true ; postLazyInit ( this . returnType , RETURN_TYPE2_PROPERTY ) ; } } } return this . returnType ; } public void setReturnType2 ( Type type ) { unsupportedIn2 ( ) ; this . returnType2Initialized = true ; ASTNode oldChild = this . returnType ; preReplaceChild ( oldChild , type , RETURN_TYPE2_PROPERTY ) ; this . returnType = type ; postReplaceChild ( oldChild , type , RETURN_TYPE2_PROPERTY ) ; } public int getExtraDimensions ( ) { return this . extraArrayDimensions ; } public void setExtraDimensions ( int dimensions ) { if ( dimensions < <NUM_LIT:0> ) { throw new IllegalArgumentException ( ) ; } preValueChange ( EXTRA_DIMENSIONS_PROPERTY ) ; this . extraArrayDimensions = dimensions ; postValueChange ( EXTRA_DIMENSIONS_PROPERTY ) ; } public Block getBody ( ) { return this . optionalBody ; } public void setBody ( Block body ) { ASTNode oldChild = this . optionalBody ; preReplaceChild ( oldChild , body , BODY_PROPERTY ) ; this . optionalBody = body ; postReplaceChild ( oldChild , body , BODY_PROPERTY ) ; } public IMethodBinding resolveBinding ( ) { return this . ast . getBindingResolver ( ) . resolveMethod ( this ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:9> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalDocComment == null ? <NUM_LIT:0> : getJavadoc ( ) . treeSize ( ) ) + ( this . modifiers == null ? <NUM_LIT:0> : this . modifiers . listSize ( ) ) + ( this . typeParameters == null ? <NUM_LIT:0> : this . typeParameters . listSize ( ) ) + ( this . methodName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) + ( this . returnType == null ? <NUM_LIT:0> : this . returnType . treeSize ( ) ) + this . parameters . listSize ( ) + this . thrownExceptions . listSize ( ) + ( this . optionalBody == null ? <NUM_LIT:0> : getBody ( ) . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . util . IModifierConstants ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Initializer ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . impl . Constant ; import org . eclipse . jdt . internal . compiler . impl . ReferenceContext ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . FieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . LocalVariableBinding ; import org . eclipse . jdt . internal . compiler . lookup . TagBits ; import org . eclipse . jdt . internal . compiler . lookup . TypeIds ; import org . eclipse . jdt . internal . core . JavaElement ; import org . eclipse . jdt . internal . core . LocalVariable ; import org . eclipse . jdt . internal . core . util . Util ; class VariableBinding implements IVariableBinding { private static final int VALID_MODIFIERS = Modifier . PUBLIC | Modifier . PROTECTED | Modifier . PRIVATE | Modifier . STATIC | Modifier . FINAL | Modifier . TRANSIENT | Modifier . VOLATILE ; private org . eclipse . jdt . internal . compiler . lookup . VariableBinding binding ; private ITypeBinding declaringClass ; private String key ; private String name ; private BindingResolver resolver ; private ITypeBinding type ; private IAnnotationBinding [ ] annotations ; VariableBinding ( BindingResolver resolver , org . eclipse . jdt . internal . compiler . lookup . VariableBinding binding ) { this . resolver = resolver ; this . binding = binding ; } public IAnnotationBinding [ ] getAnnotations ( ) { if ( this . annotations != null ) { return this . annotations ; } org . eclipse . jdt . internal . compiler . lookup . AnnotationBinding [ ] internalAnnotations = this . binding . getAnnotations ( ) ; int length = internalAnnotations == null ? <NUM_LIT:0> : internalAnnotations . length ; if ( length != <NUM_LIT:0> ) { IAnnotationBinding [ ] tempAnnotations = new IAnnotationBinding [ length ] ; int convertedAnnotationCount = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { org . eclipse . jdt . internal . compiler . lookup . AnnotationBinding internalAnnotation = internalAnnotations [ i ] ; final IAnnotationBinding annotationInstance = this . resolver . getAnnotationInstance ( internalAnnotation ) ; if ( annotationInstance == null ) { continue ; } tempAnnotations [ convertedAnnotationCount ++ ] = annotationInstance ; } if ( convertedAnnotationCount != length ) { if ( convertedAnnotationCount == <NUM_LIT:0> ) { return this . annotations = AnnotationBinding . NoAnnotations ; } System . arraycopy ( tempAnnotations , <NUM_LIT:0> , ( tempAnnotations = new IAnnotationBinding [ convertedAnnotationCount ] ) , <NUM_LIT:0> , convertedAnnotationCount ) ; } return this . annotations = tempAnnotations ; } return this . annotations = AnnotationBinding . NoAnnotations ; } public Object getConstantValue ( ) { Constant c = this . binding . constant ( ) ; if ( c == null || c == Constant . NotAConstant ) return null ; switch ( c . typeID ( ) ) { case TypeIds . T_boolean : return Boolean . valueOf ( c . booleanValue ( ) ) ; case TypeIds . T_byte : return new Byte ( c . byteValue ( ) ) ; case TypeIds . T_char : return new Character ( c . charValue ( ) ) ; case TypeIds . T_double : return new Double ( c . doubleValue ( ) ) ; case TypeIds . T_float : return new Float ( c . floatValue ( ) ) ; case TypeIds . T_int : return new Integer ( c . intValue ( ) ) ; case TypeIds . T_long : return new Long ( c . longValue ( ) ) ; case TypeIds . T_short : return new Short ( c . shortValue ( ) ) ; case TypeIds . T_JavaLangString : return c . stringValue ( ) ; } return null ; } public ITypeBinding getDeclaringClass ( ) { if ( isField ( ) ) { if ( this . declaringClass == null ) { FieldBinding fieldBinding = ( FieldBinding ) this . binding ; this . declaringClass = this . resolver . getTypeBinding ( fieldBinding . declaringClass ) ; } return this . declaringClass ; } else { return null ; } } public IMethodBinding getDeclaringMethod ( ) { if ( ! isField ( ) ) { ASTNode node = this . resolver . findDeclaringNode ( this ) ; while ( true ) { if ( node == null ) { if ( this . binding instanceof LocalVariableBinding ) { LocalVariableBinding localVariableBinding = ( LocalVariableBinding ) this . binding ; BlockScope blockScope = localVariableBinding . declaringScope ; if ( blockScope != null ) { ReferenceContext referenceContext = blockScope . referenceContext ( ) ; if ( referenceContext instanceof Initializer ) { return null ; } if ( referenceContext instanceof AbstractMethodDeclaration ) { return this . resolver . getMethodBinding ( ( ( AbstractMethodDeclaration ) referenceContext ) . binding ) ; } } } return null ; } switch ( node . getNodeType ( ) ) { case ASTNode . INITIALIZER : return null ; case ASTNode . METHOD_DECLARATION : MethodDeclaration methodDeclaration = ( MethodDeclaration ) node ; return methodDeclaration . resolveBinding ( ) ; default : node = node . getParent ( ) ; } } } return null ; } public IJavaElement getJavaElement ( ) { JavaElement element = getUnresolvedJavaElement ( ) ; if ( element == null ) return null ; return element . resolved ( this . binding ) ; } public String getKey ( ) { if ( this . key == null ) { this . key = new String ( this . binding . computeUniqueKey ( ) ) ; } return this . key ; } public int getKind ( ) { return IBinding . VARIABLE ; } public int getModifiers ( ) { if ( isField ( ) ) { return ( ( FieldBinding ) this . binding ) . getAccessFlags ( ) & VALID_MODIFIERS ; } if ( this . binding . isFinal ( ) ) { return IModifierConstants . ACC_FINAL ; } return Modifier . NONE ; } public String getName ( ) { if ( this . name == null ) { this . name = new String ( this . binding . name ) ; } return this . name ; } public ITypeBinding getType ( ) { if ( this . type == null ) { this . type = this . resolver . getTypeBinding ( this . binding . type ) ; } return this . type ; } private JavaElement getUnresolvedJavaElement ( ) { if ( JavaCore . getPlugin ( ) == null ) { return null ; } if ( isField ( ) ) { if ( this . resolver instanceof DefaultBindingResolver ) { DefaultBindingResolver defaultBindingResolver = ( DefaultBindingResolver ) this . resolver ; if ( ! defaultBindingResolver . fromJavaProject ) return null ; return Util . getUnresolvedJavaElement ( ( FieldBinding ) this . binding , defaultBindingResolver . workingCopyOwner , defaultBindingResolver . getBindingsToNodesMap ( ) ) ; } return null ; } if ( ! ( this . resolver instanceof DefaultBindingResolver ) ) return null ; DefaultBindingResolver defaultBindingResolver = ( DefaultBindingResolver ) this . resolver ; if ( ! defaultBindingResolver . fromJavaProject ) return null ; VariableDeclaration localVar = ( VariableDeclaration ) defaultBindingResolver . bindingsToAstNodes . get ( this ) ; if ( localVar == null ) return null ; int nameStart ; int nameLength ; int sourceStart ; int sourceLength ; if ( localVar instanceof SingleVariableDeclaration ) { sourceStart = localVar . getStartPosition ( ) ; sourceLength = localVar . getLength ( ) ; SimpleName simpleName = ( ( SingleVariableDeclaration ) localVar ) . getName ( ) ; nameStart = simpleName . getStartPosition ( ) ; nameLength = simpleName . getLength ( ) ; } else { nameStart = localVar . getStartPosition ( ) ; nameLength = localVar . getLength ( ) ; ASTNode node = localVar . getParent ( ) ; sourceStart = node . getStartPosition ( ) ; sourceLength = node . getLength ( ) ; } int sourceEnd = sourceStart + sourceLength - <NUM_LIT:1> ; char [ ] typeSig = this . binding . type . genericTypeSignature ( ) ; JavaElement parent = null ; IMethodBinding declaringMethod = getDeclaringMethod ( ) ; if ( declaringMethod == null ) { ReferenceContext referenceContext = ( ( LocalVariableBinding ) this . binding ) . declaringScope . referenceContext ( ) ; if ( referenceContext instanceof TypeDeclaration ) { TypeDeclaration typeDeclaration = ( TypeDeclaration ) referenceContext ; JavaElement typeHandle = null ; typeHandle = Util . getUnresolvedJavaElement ( typeDeclaration . binding , defaultBindingResolver . workingCopyOwner , defaultBindingResolver . getBindingsToNodesMap ( ) ) ; parent = Util . getUnresolvedJavaElement ( sourceStart , sourceEnd , typeHandle ) ; } else { return null ; } } else { parent = ( JavaElement ) declaringMethod . getJavaElement ( ) ; } if ( parent == null ) return null ; return new LocalVariable ( parent , localVar . getName ( ) . getIdentifier ( ) , sourceStart , sourceEnd , nameStart , nameStart + nameLength - <NUM_LIT:1> , new String ( typeSig ) , ( ( LocalVariableBinding ) this . binding ) . declaration . annotations ) ; } public IVariableBinding getVariableDeclaration ( ) { if ( isField ( ) ) { FieldBinding fieldBinding = ( FieldBinding ) this . binding ; return this . resolver . getVariableBinding ( fieldBinding . original ( ) ) ; } return this ; } public int getVariableId ( ) { return this . binding . id ; } public boolean isParameter ( ) { return ( this . binding . tagBits & TagBits . IsArgument ) != <NUM_LIT:0> ; } public boolean isDeprecated ( ) { if ( isField ( ) ) { return ( ( FieldBinding ) this . binding ) . isDeprecated ( ) ; } return false ; } public boolean isEnumConstant ( ) { return ( this . binding . modifiers & ClassFileConstants . AccEnum ) != <NUM_LIT:0> ; } public boolean isEqualTo ( IBinding other ) { if ( other == this ) { return true ; } if ( other == null ) { return false ; } if ( ! ( other instanceof VariableBinding ) ) { return false ; } org . eclipse . jdt . internal . compiler . lookup . VariableBinding otherBinding = ( ( VariableBinding ) other ) . binding ; if ( this . binding instanceof FieldBinding ) { if ( otherBinding instanceof FieldBinding ) { return BindingComparator . isEqual ( ( FieldBinding ) this . binding , ( FieldBinding ) otherBinding ) ; } else { return false ; } } else { if ( BindingComparator . isEqual ( this . binding , otherBinding ) ) { IMethodBinding declaringMethod = getDeclaringMethod ( ) ; IMethodBinding otherDeclaringMethod = ( ( VariableBinding ) other ) . getDeclaringMethod ( ) ; if ( declaringMethod == null ) { if ( otherDeclaringMethod != null ) { return false ; } return true ; } return declaringMethod . isEqualTo ( otherDeclaringMethod ) ; } return false ; } } public boolean isField ( ) { return this . binding instanceof FieldBinding ; } public boolean isSynthetic ( ) { if ( isField ( ) ) { return ( ( FieldBinding ) this . binding ) . isSynthetic ( ) ; } return false ; } public boolean isRecovered ( ) { return false ; } public String toString ( ) { return this . binding . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class EmptyStatement extends Statement { private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:1> ) ; createPropertyList ( EmptyStatement . class , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } EmptyStatement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final int getNodeType0 ( ) { return EMPTY_STATEMENT ; } ASTNode clone0 ( AST target ) { EmptyStatement result = new EmptyStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { visitor . visit ( this ) ; visitor . endVisit ( this ) ; } int treeSize ( ) { return memSize ( ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class SwitchCase extends Statement { public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( SwitchCase . class , "<STR_LIT>" , Expression . class , OPTIONAL , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( SwitchCase . class , propertyList ) ; addProperty ( EXPRESSION_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Expression optionalExpression = null ; private boolean expressionInitialized = false ; SwitchCase ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return SWITCH_CASE ; } ASTNode clone0 ( AST target ) { SwitchCase result = new SwitchCase ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; result . setExpression ( ( Expression ) ASTNode . copySubtree ( target , getExpression ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getExpression ( ) ) ; } visitor . endVisit ( this ) ; } public Expression getExpression ( ) { if ( ! this . expressionInitialized ) { synchronized ( this ) { if ( ! this . expressionInitialized ) { preLazyInit ( ) ; this . optionalExpression = new SimpleName ( this . ast ) ; this . expressionInitialized = true ; postLazyInit ( this . optionalExpression , EXPRESSION_PROPERTY ) ; } } } return this . optionalExpression ; } public void setExpression ( Expression expression ) { ASTNode oldChild = this . optionalExpression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . optionalExpression = expression ; this . expressionInitialized = true ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } public boolean isDefault ( ) { return getExpression ( ) == null ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalExpression == null ? <NUM_LIT:0> : this . optionalExpression . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class MethodRef extends ASTNode implements IDocElement { public static final ChildPropertyDescriptor QUALIFIER_PROPERTY = new ChildPropertyDescriptor ( MethodRef . class , "<STR_LIT>" , Name . class , OPTIONAL , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( MethodRef . class , "<STR_LIT:name>" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor PARAMETERS_PROPERTY = new ChildListPropertyDescriptor ( MethodRef . class , "<STR_LIT>" , MethodRefParameter . class , NO_CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( MethodRef . class , properyList ) ; addProperty ( QUALIFIER_PROPERTY , properyList ) ; addProperty ( NAME_PROPERTY , properyList ) ; addProperty ( PARAMETERS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Name optionalQualifier = null ; private SimpleName methodName = null ; private ASTNode . NodeList parameters = new ASTNode . NodeList ( PARAMETERS_PROPERTY ) ; MethodRef ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == QUALIFIER_PROPERTY ) { if ( get ) { return getQualifier ( ) ; } else { setQualifier ( ( Name ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == PARAMETERS_PROPERTY ) { return parameters ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return METHOD_REF ; } ASTNode clone0 ( AST target ) { MethodRef result = new MethodRef ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setQualifier ( ( Name ) ASTNode . copySubtree ( target , getQualifier ( ) ) ) ; result . setName ( ( SimpleName ) ASTNode . copySubtree ( target , getName ( ) ) ) ; result . parameters ( ) . addAll ( ASTNode . copySubtrees ( target , parameters ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getQualifier ( ) ) ; acceptChild ( visitor , getName ( ) ) ; acceptChildren ( visitor , this . parameters ) ; } visitor . endVisit ( this ) ; } public Name getQualifier ( ) { return this . optionalQualifier ; } public void setQualifier ( Name name ) { ASTNode oldChild = this . optionalQualifier ; preReplaceChild ( oldChild , name , QUALIFIER_PROPERTY ) ; this . optionalQualifier = name ; postReplaceChild ( oldChild , name , QUALIFIER_PROPERTY ) ; } public SimpleName getName ( ) { if ( this . methodName == null ) { synchronized ( this ) { if ( this . methodName == null ) { preLazyInit ( ) ; this . methodName = new SimpleName ( this . ast ) ; postLazyInit ( this . methodName , NAME_PROPERTY ) ; } } } return this . methodName ; } public void setName ( SimpleName name ) { if ( name == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . methodName ; preReplaceChild ( oldChild , name , NAME_PROPERTY ) ; this . methodName = name ; postReplaceChild ( oldChild , name , NAME_PROPERTY ) ; } public List parameters ( ) { return this . parameters ; } public final IBinding resolveBinding ( ) { return this . ast . getBindingResolver ( ) . resolveReference ( this ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:3> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalQualifier == null ? <NUM_LIT:0> : getQualifier ( ) . treeSize ( ) ) + ( this . methodName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) + this . parameters . listSize ( ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; public class CharacterLiteral extends Expression { public static final SimplePropertyDescriptor ESCAPED_VALUE_PROPERTY = new SimplePropertyDescriptor ( CharacterLiteral . class , "<STR_LIT>" , String . class , MANDATORY ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( CharacterLiteral . class , properyList ) ; addProperty ( ESCAPED_VALUE_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private String escapedValue = "<STR_LIT>" ; CharacterLiteral ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final Object internalGetSetObjectProperty ( SimplePropertyDescriptor property , boolean get , Object value ) { if ( property == ESCAPED_VALUE_PROPERTY ) { if ( get ) { return getEscapedValue ( ) ; } else { setEscapedValue ( ( String ) value ) ; return null ; } } return super . internalGetSetObjectProperty ( property , get , value ) ; } final int getNodeType0 ( ) { return CHARACTER_LITERAL ; } ASTNode clone0 ( AST target ) { CharacterLiteral result = new CharacterLiteral ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setEscapedValue ( getEscapedValue ( ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { visitor . visit ( this ) ; visitor . endVisit ( this ) ; } public String getEscapedValue ( ) { return this . escapedValue ; } public void setEscapedValue ( String value ) { if ( value == null ) { throw new IllegalArgumentException ( ) ; } Scanner scanner = this . ast . scanner ; char [ ] source = value . toCharArray ( ) ; scanner . setSource ( source ) ; scanner . resetTo ( <NUM_LIT:0> , source . length ) ; try { int tokenType = scanner . getNextToken ( ) ; switch ( tokenType ) { case TerminalTokens . TokenNameCharacterLiteral : break ; default : throw new IllegalArgumentException ( ) ; } } catch ( InvalidInputException e ) { throw new IllegalArgumentException ( ) ; } preValueChange ( ESCAPED_VALUE_PROPERTY ) ; this . escapedValue = value ; postValueChange ( ESCAPED_VALUE_PROPERTY ) ; } void internalSetEscapedValue ( String value ) { preValueChange ( ESCAPED_VALUE_PROPERTY ) ; this . escapedValue = value ; postValueChange ( ESCAPED_VALUE_PROPERTY ) ; } public char charValue ( ) { Scanner scanner = this . ast . scanner ; char [ ] source = this . escapedValue . toCharArray ( ) ; scanner . setSource ( source ) ; scanner . resetTo ( <NUM_LIT:0> , source . length ) ; int firstChar = scanner . getNextChar ( ) ; int secondChar = scanner . getNextChar ( ) ; if ( firstChar == - <NUM_LIT:1> || firstChar != '<STR_LIT>' ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } char value = ( char ) secondChar ; int nextChar = scanner . getNextChar ( ) ; if ( secondChar == '<STR_LIT:\\>' ) { if ( nextChar == - <NUM_LIT:1> ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } switch ( nextChar ) { case '<CHAR_LIT:b>' : value = '<STR_LIT>' ; break ; case '<CHAR_LIT>' : value = '<STR_LIT:\t>' ; break ; case '<CHAR_LIT>' : value = '<STR_LIT:\n>' ; break ; case '<CHAR_LIT>' : value = '<STR_LIT>' ; break ; case '<CHAR_LIT>' : value = '<STR_LIT>' ; break ; case '<STR_LIT:\">' : value = '<STR_LIT:\">' ; break ; case '<STR_LIT>' : value = '<STR_LIT>' ; break ; case '<STR_LIT:\\>' : value = '<STR_LIT:\\>' ; break ; default : try { if ( ScannerHelper . isDigit ( ( char ) nextChar ) ) { int number = ScannerHelper . getNumericValue ( ( char ) nextChar ) ; nextChar = scanner . getNextChar ( ) ; if ( nextChar == - <NUM_LIT:1> ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } if ( nextChar != '<STR_LIT>' ) { if ( ! ScannerHelper . isDigit ( ( char ) nextChar ) ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } number = ( number * <NUM_LIT:8> ) + ScannerHelper . getNumericValue ( ( char ) nextChar ) ; nextChar = scanner . getNextChar ( ) ; if ( nextChar == - <NUM_LIT:1> ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } if ( nextChar != '<STR_LIT>' ) { if ( ! ScannerHelper . isDigit ( ( char ) nextChar ) ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } number = ( number * <NUM_LIT:8> ) + ScannerHelper . getNumericValue ( ( char ) nextChar ) ; } } return ( char ) number ; } else { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } } catch ( InvalidInputException e ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } } nextChar = scanner . getNextChar ( ) ; if ( nextChar == - <NUM_LIT:1> ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } } if ( nextChar == - <NUM_LIT:1> || nextChar != '<STR_LIT>' ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } return value ; } public void setCharValue ( char value ) { StringBuffer b = new StringBuffer ( <NUM_LIT:3> ) ; b . append ( '<STR_LIT>' ) ; switch ( value ) { case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT:\t>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT:\n>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT:\">' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT:\\>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; case '<STR_LIT>' : b . append ( "<STR_LIT>" ) ; break ; default : b . append ( value ) ; } b . append ( '<STR_LIT>' ) ; setEscapedValue ( b . toString ( ) ) ; } int memSize ( ) { int size = BASE_NODE_SIZE + <NUM_LIT:1> * <NUM_LIT:4> + stringSize ( this . escapedValue ) ; return size ; } int treeSize ( ) { return memSize ( ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public final class LineComment extends Comment { private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:1> ) ; createPropertyList ( LineComment . class , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } LineComment ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final int getNodeType0 ( ) { return LINE_COMMENT ; } ASTNode clone0 ( AST target ) { LineComment result = new LineComment ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { visitor . visit ( this ) ; visitor . endVisit ( this ) ; } int memSize ( ) { return super . memSize ( ) ; } int treeSize ( ) { return memSize ( ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class WildcardType extends Type { public static final ChildPropertyDescriptor BOUND_PROPERTY = new ChildPropertyDescriptor ( WildcardType . class , "<STR_LIT>" , Type . class , OPTIONAL , CYCLE_RISK ) ; public static final SimplePropertyDescriptor UPPER_BOUND_PROPERTY = new SimplePropertyDescriptor ( WildcardType . class , "<STR_LIT>" , boolean . class , MANDATORY ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( WildcardType . class , propertyList ) ; addProperty ( BOUND_PROPERTY , propertyList ) ; addProperty ( UPPER_BOUND_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Type optionalBound = null ; private boolean isUpperBound = true ; WildcardType ( AST ast ) { super ( ast ) ; unsupportedIn2 ( ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final boolean internalGetSetBooleanProperty ( SimplePropertyDescriptor property , boolean get , boolean value ) { if ( property == UPPER_BOUND_PROPERTY ) { if ( get ) { return isUpperBound ( ) ; } else { setUpperBound ( value ) ; return false ; } } return super . internalGetSetBooleanProperty ( property , get , value ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == BOUND_PROPERTY ) { if ( get ) { return getBound ( ) ; } else { setBound ( ( Type ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return WILDCARD_TYPE ; } ASTNode clone0 ( AST target ) { WildcardType result = new WildcardType ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setBound ( ( Type ) ASTNode . copySubtree ( target , getBound ( ) ) , isUpperBound ( ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getBound ( ) ) ; } visitor . endVisit ( this ) ; } public boolean isUpperBound ( ) { return this . isUpperBound ; } public Type getBound ( ) { return this . optionalBound ; } public void setBound ( Type type , boolean isUpperBound ) { setBound ( type ) ; setUpperBound ( isUpperBound ) ; } public void setBound ( Type type ) { ASTNode oldChild = this . optionalBound ; preReplaceChild ( oldChild , type , BOUND_PROPERTY ) ; this . optionalBound = type ; postReplaceChild ( oldChild , type , BOUND_PROPERTY ) ; } public void setUpperBound ( boolean isUpperBound ) { preValueChange ( UPPER_BOUND_PROPERTY ) ; this . isUpperBound = isUpperBound ; postValueChange ( UPPER_BOUND_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalBound == null ? <NUM_LIT:0> : getBound ( ) . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . List ; import java . util . Vector ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . compiler . IProblem ; import org . eclipse . jdt . internal . compiler . parser . RecoveryScanner ; import org . eclipse . jdt . internal . compiler . parser . RecoveryScannerData ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObjectToIntArray ; class ASTRecoveryPropagator extends DefaultASTVisitor { private static final int NOTHING = - <NUM_LIT:1> ; HashtableOfObjectToIntArray endingTokens = new HashtableOfObjectToIntArray ( ) ; { this . endingTokens . put ( AnonymousClassDeclaration . class , new int [ ] { TerminalTokens . TokenNameRBRACE } ) ; this . endingTokens . put ( ArrayAccess . class , new int [ ] { TerminalTokens . TokenNameRBRACKET } ) ; this . endingTokens . put ( ArrayCreation . class , new int [ ] { NOTHING , TerminalTokens . TokenNameRBRACKET } ) ; this . endingTokens . put ( ArrayInitializer . class , new int [ ] { TerminalTokens . TokenNameRBRACE } ) ; this . endingTokens . put ( ArrayType . class , new int [ ] { TerminalTokens . TokenNameRBRACKET } ) ; this . endingTokens . put ( AssertStatement . class , new int [ ] { TerminalTokens . TokenNameSEMICOLON } ) ; this . endingTokens . put ( Block . class , new int [ ] { TerminalTokens . TokenNameRBRACE } ) ; this . endingTokens . put ( BooleanLiteral . class , new int [ ] { TerminalTokens . TokenNamefalse , TerminalTokens . TokenNametrue } ) ; this . endingTokens . put ( BreakStatement . class , new int [ ] { TerminalTokens . TokenNameSEMICOLON } ) ; this . endingTokens . put ( CharacterLiteral . class , new int [ ] { TerminalTokens . TokenNameCharacterLiteral } ) ; this . endingTokens . put ( ClassInstanceCreation . class , new int [ ] { TerminalTokens . TokenNameRBRACE , TerminalTokens . TokenNameRPAREN } ) ; this . endingTokens . put ( ConstructorInvocation . class , new int [ ] { TerminalTokens . TokenNameSEMICOLON } ) ; this . endingTokens . put ( ContinueStatement . class , new int [ ] { TerminalTokens . TokenNameSEMICOLON } ) ; this . endingTokens . put ( DoStatement . class , new int [ ] { TerminalTokens . TokenNameRPAREN } ) ; this . endingTokens . put ( EmptyStatement . class , new int [ ] { TerminalTokens . TokenNameSEMICOLON } ) ; this . endingTokens . put ( ExpressionStatement . class , new int [ ] { TerminalTokens . TokenNameSEMICOLON } ) ; this . endingTokens . put ( FieldDeclaration . class , new int [ ] { TerminalTokens . TokenNameSEMICOLON } ) ; this . endingTokens . put ( ImportDeclaration . class , new int [ ] { TerminalTokens . TokenNameSEMICOLON } ) ; this . endingTokens . put ( Initializer . class , new int [ ] { TerminalTokens . TokenNameRBRACE } ) ; this . endingTokens . put ( MethodDeclaration . class , new int [ ] { NOTHING , TerminalTokens . TokenNameSEMICOLON } ) ; this . endingTokens . put ( MethodInvocation . class , new int [ ] { TerminalTokens . TokenNameRPAREN } ) ; this . endingTokens . put ( NullLiteral . class , new int [ ] { TerminalTokens . TokenNamenull } ) ; this . endingTokens . put ( NumberLiteral . class , new int [ ] { TerminalTokens . TokenNameIntegerLiteral , TerminalTokens . TokenNameLongLiteral , TerminalTokens . TokenNameFloatingPointLiteral , TerminalTokens . TokenNameDoubleLiteral } ) ; this . endingTokens . put ( PackageDeclaration . class , new int [ ] { TerminalTokens . TokenNameSEMICOLON } ) ; this . endingTokens . put ( ParenthesizedExpression . class , new int [ ] { TerminalTokens . TokenNameRPAREN } ) ; this . endingTokens . put ( PostfixExpression . class , new int [ ] { TerminalTokens . TokenNamePLUS_PLUS , TerminalTokens . TokenNameMINUS_MINUS } ) ; this . endingTokens . put ( PrimitiveType . class , new int [ ] { TerminalTokens . TokenNamebyte , TerminalTokens . TokenNameshort , TerminalTokens . TokenNamechar , TerminalTokens . TokenNameint , TerminalTokens . TokenNamelong , TerminalTokens . TokenNamefloat , TerminalTokens . TokenNameboolean , TerminalTokens . TokenNamedouble , TerminalTokens . TokenNamevoid } ) ; this . endingTokens . put ( ReturnStatement . class , new int [ ] { TerminalTokens . TokenNameSEMICOLON } ) ; this . endingTokens . put ( SimpleName . class , new int [ ] { TerminalTokens . TokenNameIdentifier } ) ; this . endingTokens . put ( SingleVariableDeclaration . class , new int [ ] { TerminalTokens . TokenNameSEMICOLON } ) ; this . endingTokens . put ( StringLiteral . class , new int [ ] { TerminalTokens . TokenNameStringLiteral } ) ; this . endingTokens . put ( SuperConstructorInvocation . class , new int [ ] { TerminalTokens . TokenNameSEMICOLON } ) ; this . endingTokens . put ( SuperMethodInvocation . class , new int [ ] { TerminalTokens . TokenNameRPAREN } ) ; this . endingTokens . put ( SwitchCase . class , new int [ ] { TerminalTokens . TokenNameCOLON } ) ; this . endingTokens . put ( SwitchStatement . class , new int [ ] { TerminalTokens . TokenNameRBRACE } ) ; this . endingTokens . put ( SynchronizedStatement . class , new int [ ] { TerminalTokens . TokenNameRBRACE } ) ; this . endingTokens . put ( ThisExpression . class , new int [ ] { TerminalTokens . TokenNamethis } ) ; this . endingTokens . put ( ThrowStatement . class , new int [ ] { TerminalTokens . TokenNameSEMICOLON } ) ; this . endingTokens . put ( TypeDeclaration . class , new int [ ] { TerminalTokens . TokenNameRBRACE } ) ; this . endingTokens . put ( TypeLiteral . class , new int [ ] { TerminalTokens . TokenNameclass } ) ; this . endingTokens . put ( VariableDeclarationStatement . class , new int [ ] { TerminalTokens . TokenNameSEMICOLON } ) ; } private CategorizedProblem [ ] problems ; private boolean [ ] usedOrIrrelevantProblems ; private RecoveryScannerData data ; private int blockDepth = <NUM_LIT:0> ; private int lastEnd ; private int [ ] insertedTokensKind ; private int [ ] insertedTokensPosition ; private boolean [ ] insertedTokensFlagged ; private boolean [ ] removedTokensFlagged ; private boolean [ ] replacedTokensFlagged ; private Vector stack = new Vector ( ) ; ASTRecoveryPropagator ( CategorizedProblem [ ] problems , RecoveryScannerData data ) { this . problems = problems ; this . usedOrIrrelevantProblems = new boolean [ problems . length ] ; this . data = data ; if ( this . data != null ) { int length = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < data . insertedTokensPtr + <NUM_LIT:1> ; i ++ ) { length += data . insertedTokens [ i ] . length ; } this . insertedTokensKind = new int [ length ] ; this . insertedTokensPosition = new int [ length ] ; this . insertedTokensFlagged = new boolean [ length ] ; int tokenCount = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < data . insertedTokensPtr + <NUM_LIT:1> ; i ++ ) { for ( int j = <NUM_LIT:0> ; j < data . insertedTokens [ i ] . length ; j ++ ) { this . insertedTokensKind [ tokenCount ] = data . insertedTokens [ i ] [ j ] ; this . insertedTokensPosition [ tokenCount ] = data . insertedTokensPosition [ i ] ; tokenCount ++ ; } } if ( data . removedTokensPtr != - <NUM_LIT:1> ) { this . removedTokensFlagged = new boolean [ data . removedTokensPtr + <NUM_LIT:1> ] ; } if ( data . replacedTokensPtr != - <NUM_LIT:1> ) { this . replacedTokensFlagged = new boolean [ data . replacedTokensPtr + <NUM_LIT:1> ] ; } } } public void endVisit ( Block node ) { this . blockDepth -- ; if ( this . blockDepth <= <NUM_LIT:0> ) { flagNodeWithInsertedTokens ( ) ; } super . endVisit ( node ) ; } public boolean visit ( Block node ) { boolean visitChildren = super . visit ( node ) ; this . blockDepth ++ ; return visitChildren ; } protected boolean visitNode ( ASTNode node ) { if ( this . blockDepth > <NUM_LIT:0> ) { int start = node . getStartPosition ( ) ; int end = start + node . getLength ( ) - <NUM_LIT:1> ; if ( this . insertedTokensFlagged != null ) { for ( int i = <NUM_LIT:0> ; i < this . insertedTokensFlagged . length ; i ++ ) { if ( this . insertedTokensPosition [ i ] >= start && this . insertedTokensPosition [ i ] <= end ) { return true ; } } } if ( this . removedTokensFlagged != null ) { for ( int i = <NUM_LIT:0> ; i <= this . data . removedTokensPtr ; i ++ ) { if ( this . data . removedTokensStart [ i ] >= start && this . data . removedTokensEnd [ i ] <= end ) { return true ; } } } if ( this . replacedTokensFlagged != null ) { for ( int i = <NUM_LIT:0> ; i <= this . data . replacedTokensPtr ; i ++ ) { if ( this . data . replacedTokensStart [ i ] >= start && this . data . replacedTokensEnd [ i ] <= end ) { return true ; } } } return false ; } return true ; } protected void endVisitNode ( ASTNode node ) { int start = node . getStartPosition ( ) ; int end = start + node . getLength ( ) - <NUM_LIT:1> ; if ( this . blockDepth < <NUM_LIT:1> ) { switch ( node . getNodeType ( ) ) { case ASTNode . ANNOTATION_TYPE_DECLARATION : case ASTNode . COMPILATION_UNIT : case ASTNode . ENUM_DECLARATION : case ASTNode . FIELD_DECLARATION : case ASTNode . IMPORT_DECLARATION : case ASTNode . INITIALIZER : case ASTNode . METHOD_DECLARATION : case ASTNode . PACKAGE_DECLARATION : case ASTNode . TYPE_DECLARATION : case ASTNode . MARKER_ANNOTATION : case ASTNode . NORMAL_ANNOTATION : case ASTNode . SINGLE_MEMBER_ANNOTATION : case ASTNode . BLOCK : if ( markIncludedProblems ( start , end ) ) { node . setFlags ( node . getFlags ( ) | ASTNode . RECOVERED ) ; } break ; } } else { markIncludedProblems ( start , end ) ; if ( this . insertedTokensFlagged != null ) { if ( this . lastEnd != end ) { flagNodeWithInsertedTokens ( ) ; } this . stack . add ( node ) ; } if ( this . removedTokensFlagged != null ) { for ( int i = <NUM_LIT:0> ; i <= this . data . removedTokensPtr ; i ++ ) { if ( ! this . removedTokensFlagged [ i ] && this . data . removedTokensStart [ i ] >= start && this . data . removedTokensEnd [ i ] <= end ) { node . setFlags ( node . getFlags ( ) | ASTNode . RECOVERED ) ; this . removedTokensFlagged [ i ] = true ; } } } if ( this . replacedTokensFlagged != null ) { for ( int i = <NUM_LIT:0> ; i <= this . data . replacedTokensPtr ; i ++ ) { if ( ! this . replacedTokensFlagged [ i ] && this . data . replacedTokensStart [ i ] >= start && this . data . replacedTokensEnd [ i ] <= end ) { node . setFlags ( node . getFlags ( ) | ASTNode . RECOVERED ) ; this . replacedTokensFlagged [ i ] = true ; } } } } this . lastEnd = end ; } private void flagNodeWithInsertedTokens ( ) { if ( this . insertedTokensKind != null && this . insertedTokensKind . length > <NUM_LIT:0> ) { int s = this . stack . size ( ) ; for ( int i = s - <NUM_LIT:1> ; i > - <NUM_LIT:1> ; i -- ) { flagNodesWithInsertedTokensAtEnd ( ( ASTNode ) this . stack . get ( i ) ) ; } for ( int i = <NUM_LIT:0> ; i < s ; i ++ ) { flagNodesWithInsertedTokensInside ( ( ASTNode ) this . stack . get ( i ) ) ; } this . stack = new Vector ( ) ; } } private boolean flagNodesWithInsertedTokensAtEnd ( ASTNode node ) { int [ ] expectedEndingToken = this . endingTokens . get ( node . getClass ( ) ) ; if ( expectedEndingToken != null ) { int start = node . getStartPosition ( ) ; int end = start + node . getLength ( ) - <NUM_LIT:1> ; boolean flagParent = false ; done : for ( int i = this . insertedTokensKind . length - <NUM_LIT:1> ; i > - <NUM_LIT:1> ; i -- ) { if ( ! this . insertedTokensFlagged [ i ] && this . insertedTokensPosition [ i ] == end ) { this . insertedTokensFlagged [ i ] = true ; for ( int j = <NUM_LIT:0> ; j < expectedEndingToken . length ; j ++ ) { if ( expectedEndingToken [ j ] == this . insertedTokensKind [ i ] ) { node . setFlags ( node . getFlags ( ) | ASTNode . RECOVERED ) ; break done ; } } flagParent = true ; } } if ( flagParent ) { ASTNode parent = node . getParent ( ) ; while ( parent != null ) { parent . setFlags ( node . getFlags ( ) | ASTNode . RECOVERED ) ; if ( ( parent . getStartPosition ( ) + parent . getLength ( ) - <NUM_LIT:1> ) != end ) { parent = null ; } else { parent = parent . getParent ( ) ; } } } } return true ; } private boolean flagNodesWithInsertedTokensInside ( ASTNode node ) { int start = node . getStartPosition ( ) ; int end = start + node . getLength ( ) - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < this . insertedTokensKind . length ; i ++ ) { if ( ! this . insertedTokensFlagged [ i ] && start <= this . insertedTokensPosition [ i ] && this . insertedTokensPosition [ i ] < end ) { node . setFlags ( node . getFlags ( ) | ASTNode . RECOVERED ) ; this . insertedTokensFlagged [ i ] = true ; } } return true ; } private boolean markIncludedProblems ( int start , int end ) { boolean foundProblems = false ; next : for ( int i = <NUM_LIT:0> , max = this . problems . length ; i < max ; i ++ ) { CategorizedProblem problem = this . problems [ i ] ; if ( this . usedOrIrrelevantProblems [ i ] ) continue next ; switch ( problem . getID ( ) ) { case IProblem . ParsingErrorOnKeywordNoSuggestion : case IProblem . ParsingErrorOnKeyword : case IProblem . ParsingError : case IProblem . ParsingErrorNoSuggestion : case IProblem . ParsingErrorInsertTokenBefore : case IProblem . ParsingErrorInsertTokenAfter : case IProblem . ParsingErrorDeleteToken : case IProblem . ParsingErrorDeleteTokens : case IProblem . ParsingErrorMergeTokens : case IProblem . ParsingErrorInvalidToken : case IProblem . ParsingErrorMisplacedConstruct : case IProblem . ParsingErrorReplaceTokens : case IProblem . ParsingErrorNoSuggestionForTokens : case IProblem . ParsingErrorUnexpectedEOF : case IProblem . ParsingErrorInsertToComplete : case IProblem . ParsingErrorInsertToCompleteScope : case IProblem . ParsingErrorInsertToCompletePhrase : case IProblem . EndOfSource : case IProblem . InvalidHexa : case IProblem . InvalidOctal : case IProblem . InvalidCharacterConstant : case IProblem . InvalidEscape : case IProblem . InvalidInput : case IProblem . InvalidUnicodeEscape : case IProblem . InvalidFloat : case IProblem . NullSourceString : case IProblem . UnterminatedString : case IProblem . UnterminatedComment : case IProblem . InvalidDigit : break ; default : this . usedOrIrrelevantProblems [ i ] = true ; continue next ; } int problemStart = problem . getSourceStart ( ) ; int problemEnd = problem . getSourceEnd ( ) ; if ( ( start <= problemStart ) && ( problemStart <= end ) || ( start <= problemEnd ) && ( problemEnd <= end ) ) { this . usedOrIrrelevantProblems [ i ] = true ; foundProblems = true ; } } return foundProblems ; } public void endVisit ( ExpressionStatement node ) { endVisitNode ( node ) ; if ( ( node . getFlags ( ) & ASTNode . RECOVERED ) == <NUM_LIT:0> ) return ; Expression expression = node . getExpression ( ) ; if ( expression . getNodeType ( ) == ASTNode . ASSIGNMENT ) { Assignment assignment = ( Assignment ) expression ; Expression rightHandSide = assignment . getRightHandSide ( ) ; if ( rightHandSide . getNodeType ( ) == ASTNode . SIMPLE_NAME ) { SimpleName simpleName = ( SimpleName ) rightHandSide ; if ( CharOperation . equals ( RecoveryScanner . FAKE_IDENTIFIER , simpleName . getIdentifier ( ) . toCharArray ( ) ) ) { Expression expression2 = assignment . getLeftHandSide ( ) ; expression2 . setParent ( null , null ) ; expression2 . setFlags ( expression2 . getFlags ( ) | ASTNode . RECOVERED ) ; node . setExpression ( expression2 ) ; } } } } public void endVisit ( ForStatement node ) { endVisitNode ( node ) ; List initializers = node . initializers ( ) ; if ( initializers . size ( ) == <NUM_LIT:1> ) { Expression expression = ( Expression ) initializers . get ( <NUM_LIT:0> ) ; if ( expression . getNodeType ( ) == ASTNode . VARIABLE_DECLARATION_EXPRESSION ) { VariableDeclarationExpression variableDeclarationExpression = ( VariableDeclarationExpression ) expression ; List fragments = variableDeclarationExpression . fragments ( ) ; for ( int i = <NUM_LIT:0> , max = fragments . size ( ) ; i < max ; i ++ ) { VariableDeclarationFragment fragment = ( VariableDeclarationFragment ) fragments . get ( i ) ; SimpleName simpleName = fragment . getName ( ) ; if ( CharOperation . equals ( RecoveryScanner . FAKE_IDENTIFIER , simpleName . getIdentifier ( ) . toCharArray ( ) ) ) { fragments . remove ( fragment ) ; variableDeclarationExpression . setFlags ( variableDeclarationExpression . getFlags ( ) | ASTNode . RECOVERED ) ; } } } } } public void endVisit ( VariableDeclarationStatement node ) { endVisitNode ( node ) ; List fragments = node . fragments ( ) ; for ( int i = <NUM_LIT:0> , max = fragments . size ( ) ; i < max ; i ++ ) { VariableDeclarationFragment fragment = ( VariableDeclarationFragment ) fragments . get ( i ) ; Expression expression = fragment . getInitializer ( ) ; if ( expression == null ) continue ; if ( ( expression . getFlags ( ) & ASTNode . RECOVERED ) == <NUM_LIT:0> ) continue ; if ( expression . getNodeType ( ) == ASTNode . SIMPLE_NAME ) { SimpleName simpleName = ( SimpleName ) expression ; if ( CharOperation . equals ( RecoveryScanner . FAKE_IDENTIFIER , simpleName . getIdentifier ( ) . toCharArray ( ) ) ) { fragment . setInitializer ( null ) ; fragment . setFlags ( fragment . getFlags ( ) | ASTNode . RECOVERED ) ; } } } } public void endVisit ( NormalAnnotation node ) { endVisitNode ( node ) ; if ( this . blockDepth < <NUM_LIT:1> ) { List values = node . values ( ) ; int size = values . size ( ) ; if ( size > <NUM_LIT:0> ) { MemberValuePair lastMemberValuePair = ( MemberValuePair ) values . get ( size - <NUM_LIT:1> ) ; int annotationEnd = node . getStartPosition ( ) + node . getLength ( ) ; int lastMemberValuePairEnd = lastMemberValuePair . getStartPosition ( ) + lastMemberValuePair . getLength ( ) ; if ( annotationEnd == lastMemberValuePairEnd ) { node . setFlags ( node . getFlags ( ) | ASTNode . RECOVERED ) ; } } } } public void endVisit ( SingleMemberAnnotation node ) { endVisitNode ( node ) ; if ( this . blockDepth < <NUM_LIT:1> ) { Expression value = node . getValue ( ) ; int annotationEnd = node . getStartPosition ( ) + node . getLength ( ) ; int valueEnd = value . getStartPosition ( ) + value . getLength ( ) ; if ( annotationEnd == valueEnd ) { node . setFlags ( node . getFlags ( ) | ASTNode . RECOVERED ) ; } } } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . HashSet ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . CaptureBinding ; import org . eclipse . jdt . internal . compiler . lookup . ExtraCompilerModifiers ; import org . eclipse . jdt . internal . compiler . lookup . FieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . ImportBinding ; import org . eclipse . jdt . internal . compiler . lookup . ParameterizedTypeBinding ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . TypeVariableBinding ; import org . eclipse . jdt . internal . compiler . lookup . VariableBinding ; import org . eclipse . jdt . internal . compiler . lookup . WildcardBinding ; class BindingComparator { static boolean isEqual ( TypeVariableBinding [ ] bindings , TypeVariableBinding [ ] otherBindings ) { if ( bindings == null ) { return otherBindings == null ; } if ( otherBindings == null ) { return false ; } int length = bindings . length ; int otherLength = otherBindings . length ; if ( length != otherLength ) { return false ; } for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { TypeVariableBinding typeVariableBinding = bindings [ i ] ; TypeVariableBinding typeVariableBinding2 = otherBindings [ i ] ; if ( ! isEqual ( typeVariableBinding , typeVariableBinding2 ) ) { return false ; } } return true ; } static boolean isEqual ( Binding declaringElement , Binding declaringElement2 , HashSet visitedTypes ) { if ( declaringElement instanceof org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) { if ( ! ( declaringElement2 instanceof org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) ) { return false ; } return isEqual ( ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) declaringElement , ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) declaringElement2 , visitedTypes ) ; } else if ( declaringElement instanceof org . eclipse . jdt . internal . compiler . lookup . MethodBinding ) { if ( ! ( declaringElement2 instanceof org . eclipse . jdt . internal . compiler . lookup . MethodBinding ) ) { return false ; } return isEqual ( ( org . eclipse . jdt . internal . compiler . lookup . MethodBinding ) declaringElement , ( org . eclipse . jdt . internal . compiler . lookup . MethodBinding ) declaringElement2 , visitedTypes ) ; } else if ( declaringElement instanceof VariableBinding ) { if ( ! ( declaringElement2 instanceof VariableBinding ) ) { return false ; } return isEqual ( ( VariableBinding ) declaringElement , ( VariableBinding ) declaringElement2 ) ; } else if ( declaringElement instanceof org . eclipse . jdt . internal . compiler . lookup . PackageBinding ) { if ( ! ( declaringElement2 instanceof org . eclipse . jdt . internal . compiler . lookup . PackageBinding ) ) { return false ; } org . eclipse . jdt . internal . compiler . lookup . PackageBinding packageBinding = ( org . eclipse . jdt . internal . compiler . lookup . PackageBinding ) declaringElement ; org . eclipse . jdt . internal . compiler . lookup . PackageBinding packageBinding2 = ( org . eclipse . jdt . internal . compiler . lookup . PackageBinding ) declaringElement2 ; return CharOperation . equals ( packageBinding . compoundName , packageBinding2 . compoundName ) ; } else if ( declaringElement instanceof ImportBinding ) { if ( ! ( declaringElement2 instanceof ImportBinding ) ) { return false ; } ImportBinding importBinding = ( ImportBinding ) declaringElement ; ImportBinding importBinding2 = ( ImportBinding ) declaringElement2 ; return importBinding . isStatic ( ) == importBinding2 . isStatic ( ) && importBinding . onDemand == importBinding2 . onDemand && CharOperation . equals ( importBinding . compoundName , importBinding2 . compoundName ) ; } return false ; } static boolean isEqual ( org . eclipse . jdt . internal . compiler . lookup . MethodBinding methodBinding , org . eclipse . jdt . internal . compiler . lookup . MethodBinding methodBinding2 ) { return isEqual ( methodBinding , methodBinding2 , new HashSet ( ) ) ; } static boolean isEqual ( org . eclipse . jdt . internal . compiler . lookup . MethodBinding methodBinding , org . eclipse . jdt . internal . compiler . lookup . MethodBinding methodBinding2 , HashSet visitedTypes ) { if ( methodBinding == null ) { return methodBinding2 == null ; } if ( methodBinding2 == null ) return false ; return CharOperation . equals ( methodBinding . selector , methodBinding2 . selector ) && isEqual ( methodBinding . returnType , methodBinding2 . returnType , visitedTypes ) && isEqual ( methodBinding . thrownExceptions , methodBinding2 . thrownExceptions , visitedTypes ) && isEqual ( methodBinding . declaringClass , methodBinding2 . declaringClass , visitedTypes ) && isEqual ( methodBinding . typeVariables , methodBinding2 . typeVariables , visitedTypes ) && isEqual ( methodBinding . parameters , methodBinding2 . parameters , visitedTypes ) ; } static boolean isEqual ( VariableBinding variableBinding , VariableBinding variableBinding2 ) { return ( variableBinding . modifiers & ExtraCompilerModifiers . AccJustFlag ) == ( variableBinding2 . modifiers & ExtraCompilerModifiers . AccJustFlag ) && CharOperation . equals ( variableBinding . name , variableBinding2 . name ) && isEqual ( variableBinding . type , variableBinding2 . type ) && ( variableBinding . id == variableBinding2 . id ) ; } static boolean isEqual ( FieldBinding fieldBinding , FieldBinding fieldBinding2 ) { HashSet visitedTypes = new HashSet ( ) ; return ( fieldBinding . modifiers & ExtraCompilerModifiers . AccJustFlag ) == ( fieldBinding2 . modifiers & ExtraCompilerModifiers . AccJustFlag ) && CharOperation . equals ( fieldBinding . name , fieldBinding2 . name ) && isEqual ( fieldBinding . type , fieldBinding2 . type , visitedTypes ) && isEqual ( fieldBinding . declaringClass , fieldBinding2 . declaringClass , visitedTypes ) ; } static boolean isEqual ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding [ ] bindings , org . eclipse . jdt . internal . compiler . lookup . TypeBinding [ ] otherBindings ) { return isEqual ( bindings , otherBindings , new HashSet ( ) ) ; } static boolean isEqual ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding [ ] bindings , org . eclipse . jdt . internal . compiler . lookup . TypeBinding [ ] otherBindings , HashSet visitedTypes ) { if ( bindings == null ) { return otherBindings == null ; } if ( otherBindings == null ) { return false ; } int length = bindings . length ; int otherLength = otherBindings . length ; if ( length != otherLength ) { return false ; } for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( ! isEqual ( bindings [ i ] , otherBindings [ i ] , visitedTypes ) ) { return false ; } } return true ; } static boolean isEqual ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding typeBinding , org . eclipse . jdt . internal . compiler . lookup . TypeBinding typeBinding2 , HashSet visitedTypes ) { if ( typeBinding == typeBinding2 ) return true ; if ( typeBinding == null || typeBinding2 == null ) return false ; switch ( typeBinding . kind ( ) ) { case Binding . BASE_TYPE : if ( ! typeBinding2 . isBaseType ( ) ) { return false ; } return typeBinding . id == typeBinding2 . id ; case Binding . ARRAY_TYPE : if ( ! typeBinding2 . isArrayType ( ) ) { return false ; } return typeBinding . dimensions ( ) == typeBinding2 . dimensions ( ) && isEqual ( typeBinding . leafComponentType ( ) , typeBinding2 . leafComponentType ( ) , visitedTypes ) ; case Binding . PARAMETERIZED_TYPE : if ( ! typeBinding2 . isParameterizedType ( ) ) { return false ; } ParameterizedTypeBinding parameterizedTypeBinding = ( ParameterizedTypeBinding ) typeBinding ; ParameterizedTypeBinding parameterizedTypeBinding2 = ( ParameterizedTypeBinding ) typeBinding2 ; return CharOperation . equals ( parameterizedTypeBinding . compoundName , parameterizedTypeBinding2 . compoundName ) && ( parameterizedTypeBinding . modifiers & ( ExtraCompilerModifiers . AccJustFlag | ClassFileConstants . AccInterface | ClassFileConstants . AccEnum | ClassFileConstants . AccAnnotation ) ) == ( parameterizedTypeBinding2 . modifiers & ( ExtraCompilerModifiers . AccJustFlag | ClassFileConstants . AccInterface | ClassFileConstants . AccEnum | ClassFileConstants . AccAnnotation ) ) && isEqual ( parameterizedTypeBinding . arguments , parameterizedTypeBinding2 . arguments , visitedTypes ) && isEqual ( parameterizedTypeBinding . enclosingType ( ) , parameterizedTypeBinding2 . enclosingType ( ) , visitedTypes ) ; case Binding . WILDCARD_TYPE : if ( typeBinding2 . kind ( ) != Binding . WILDCARD_TYPE ) { return false ; } WildcardBinding wildcardBinding = ( WildcardBinding ) typeBinding ; WildcardBinding wildcardBinding2 = ( WildcardBinding ) typeBinding2 ; return isEqual ( wildcardBinding . bound , wildcardBinding2 . bound , visitedTypes ) && wildcardBinding . boundKind == wildcardBinding2 . boundKind ; case Binding . INTERSECTION_TYPE : if ( typeBinding2 . kind ( ) != Binding . INTERSECTION_TYPE ) { return false ; } WildcardBinding intersectionBinding = ( WildcardBinding ) typeBinding ; WildcardBinding intersectionBinding2 = ( WildcardBinding ) typeBinding2 ; return isEqual ( intersectionBinding . bound , intersectionBinding2 . bound , visitedTypes ) && isEqual ( intersectionBinding . otherBounds , intersectionBinding2 . otherBounds , visitedTypes ) ; case Binding . TYPE_PARAMETER : if ( ! ( typeBinding2 . isTypeVariable ( ) ) ) { return false ; } if ( typeBinding . isCapture ( ) ) { if ( ! ( typeBinding2 . isCapture ( ) ) ) { return false ; } CaptureBinding captureBinding = ( CaptureBinding ) typeBinding ; CaptureBinding captureBinding2 = ( CaptureBinding ) typeBinding2 ; if ( captureBinding . position == captureBinding2 . position ) { if ( visitedTypes . contains ( typeBinding ) ) return true ; visitedTypes . add ( typeBinding ) ; return isEqual ( captureBinding . wildcard , captureBinding2 . wildcard , visitedTypes ) && isEqual ( captureBinding . sourceType , captureBinding2 . sourceType , visitedTypes ) ; } return false ; } TypeVariableBinding typeVariableBinding = ( TypeVariableBinding ) typeBinding ; TypeVariableBinding typeVariableBinding2 = ( TypeVariableBinding ) typeBinding2 ; if ( CharOperation . equals ( typeVariableBinding . sourceName , typeVariableBinding2 . sourceName ) ) { if ( visitedTypes . contains ( typeBinding ) ) return true ; visitedTypes . add ( typeBinding ) ; return isEqual ( typeVariableBinding . declaringElement , typeVariableBinding2 . declaringElement , visitedTypes ) && isEqual ( typeVariableBinding . superclass ( ) , typeVariableBinding2 . superclass ( ) , visitedTypes ) && isEqual ( typeVariableBinding . superInterfaces ( ) , typeVariableBinding2 . superInterfaces ( ) , visitedTypes ) ; } return false ; case Binding . GENERIC_TYPE : if ( ! typeBinding2 . isGenericType ( ) ) { return false ; } ReferenceBinding referenceBinding = ( ReferenceBinding ) typeBinding ; ReferenceBinding referenceBinding2 = ( ReferenceBinding ) typeBinding2 ; return CharOperation . equals ( referenceBinding . compoundName , referenceBinding2 . compoundName ) && ( referenceBinding . modifiers & ( ExtraCompilerModifiers . AccJustFlag | ClassFileConstants . AccInterface | ClassFileConstants . AccEnum | ClassFileConstants . AccAnnotation ) ) == ( referenceBinding2 . modifiers & ( ExtraCompilerModifiers . AccJustFlag | ClassFileConstants . AccInterface | ClassFileConstants . AccEnum | ClassFileConstants . AccAnnotation ) ) && isEqual ( referenceBinding . typeVariables ( ) , referenceBinding2 . typeVariables ( ) , visitedTypes ) && isEqual ( referenceBinding . enclosingType ( ) , referenceBinding2 . enclosingType ( ) , visitedTypes ) ; case Binding . RAW_TYPE : default : if ( ! ( typeBinding2 instanceof ReferenceBinding ) ) { return false ; } referenceBinding = ( ReferenceBinding ) typeBinding ; referenceBinding2 = ( ReferenceBinding ) typeBinding2 ; char [ ] constantPoolName = referenceBinding . constantPoolName ( ) ; char [ ] constantPoolName2 = referenceBinding2 . constantPoolName ( ) ; if ( constantPoolName == null ) { if ( constantPoolName2 != null ) { return false ; } if ( ! CharOperation . equals ( referenceBinding . computeUniqueKey ( ) , referenceBinding2 . computeUniqueKey ( ) ) ) { return false ; } } else { if ( constantPoolName2 == null ) { return false ; } if ( ! CharOperation . equals ( constantPoolName , constantPoolName2 ) ) { return false ; } } return CharOperation . equals ( referenceBinding . compoundName , referenceBinding2 . compoundName ) && ( ! referenceBinding2 . isGenericType ( ) ) && ( referenceBinding . isRawType ( ) == referenceBinding2 . isRawType ( ) ) && ( ( referenceBinding . modifiers & ~ ClassFileConstants . AccSuper ) & ( ExtraCompilerModifiers . AccJustFlag | ClassFileConstants . AccInterface | ClassFileConstants . AccEnum | ClassFileConstants . AccAnnotation ) ) == ( ( referenceBinding2 . modifiers & ~ ClassFileConstants . AccSuper ) & ( ExtraCompilerModifiers . AccJustFlag | ClassFileConstants . AccInterface | ClassFileConstants . AccEnum | ClassFileConstants . AccAnnotation ) ) && isEqual ( referenceBinding . enclosingType ( ) , referenceBinding2 . enclosingType ( ) , visitedTypes ) ; } } static boolean isEqual ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding typeBinding , org . eclipse . jdt . internal . compiler . lookup . TypeBinding typeBinding2 ) { return isEqual ( typeBinding , typeBinding2 , new HashSet ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . Iterator ; import java . util . List ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . parser . AbstractCommentParser ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; class DocCommentParser extends AbstractCommentParser { private Javadoc docComment ; private AST ast ; DocCommentParser ( AST ast , Scanner scanner , boolean check ) { super ( null ) ; this . ast = ast ; this . scanner = scanner ; this . sourceLevel = this . ast . apiLevel ( ) >= AST . JLS3 ? ClassFileConstants . JDK1_5 : ClassFileConstants . JDK1_3 ; this . checkDocComment = check ; this . kind = DOM_PARSER | TEXT_PARSE ; } public Javadoc parse ( int [ ] positions ) { return parse ( positions [ <NUM_LIT:0> ] , positions [ <NUM_LIT:1> ] - positions [ <NUM_LIT:0> ] ) ; } public Javadoc parse ( int start , int length ) { this . source = this . scanner . source ; this . lineEnds = this . scanner . lineEnds ; this . docComment = new Javadoc ( this . ast ) ; if ( this . checkDocComment ) { this . javadocStart = start ; this . javadocEnd = start + length - <NUM_LIT:1> ; this . firstTagPosition = this . javadocStart ; commentParse ( ) ; } this . docComment . setSourceRange ( start , length ) ; if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { setComment ( start , length ) ; } return this . docComment ; } private void setComment ( int start , int length ) { this . docComment . setComment ( new String ( this . source , start , length ) ) ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( "<STR_LIT>" ) . append ( this . docComment ) . append ( "<STR_LIT:n>" ) ; buffer . append ( super . toString ( ) ) ; return buffer . toString ( ) ; } protected Object createArgumentReference ( char [ ] name , int dim , boolean isVarargs , Object typeRef , long [ ] dimPositions , long argNamePos ) throws InvalidInputException { try { MethodRefParameter argument = this . ast . newMethodRefParameter ( ) ; ASTNode node = ( ASTNode ) typeRef ; int argStart = node . getStartPosition ( ) ; int argEnd = node . getStartPosition ( ) + node . getLength ( ) - <NUM_LIT:1> ; if ( dim > <NUM_LIT:0> ) argEnd = ( int ) dimPositions [ dim - <NUM_LIT:1> ] ; if ( argNamePos >= <NUM_LIT:0> ) argEnd = ( int ) argNamePos ; if ( name . length != <NUM_LIT:0> ) { final SimpleName argName = new SimpleName ( this . ast ) ; argName . internalSetIdentifier ( new String ( name ) ) ; argument . setName ( argName ) ; int argNameStart = ( int ) ( argNamePos > > > <NUM_LIT:32> ) ; argName . setSourceRange ( argNameStart , argEnd - argNameStart + <NUM_LIT:1> ) ; } Type argType = null ; if ( node . getNodeType ( ) == ASTNode . PRIMITIVE_TYPE ) { argType = ( PrimitiveType ) node ; } else { Name argTypeName = ( Name ) node ; argType = this . ast . newSimpleType ( argTypeName ) ; argType . setSourceRange ( argStart , node . getLength ( ) ) ; } if ( dim > <NUM_LIT:0> && ! isVarargs ) { for ( int i = <NUM_LIT:0> ; i < dim ; i ++ ) { argType = this . ast . newArrayType ( argType ) ; argType . setSourceRange ( argStart , ( ( int ) dimPositions [ i ] ) - argStart + <NUM_LIT:1> ) ; } } argument . setType ( argType ) ; argument . setSourceRange ( argStart , argEnd - argStart + <NUM_LIT:1> ) ; return argument ; } catch ( ClassCastException ex ) { throw new InvalidInputException ( ) ; } } protected Object createFieldReference ( Object receiver ) throws InvalidInputException { try { MemberRef fieldRef = this . ast . newMemberRef ( ) ; SimpleName fieldName = new SimpleName ( this . ast ) ; fieldName . internalSetIdentifier ( new String ( this . identifierStack [ <NUM_LIT:0> ] ) ) ; fieldRef . setName ( fieldName ) ; int start = ( int ) ( this . identifierPositionStack [ <NUM_LIT:0> ] > > > <NUM_LIT:32> ) ; int end = ( int ) this . identifierPositionStack [ <NUM_LIT:0> ] ; fieldName . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; if ( receiver == null ) { start = this . memberStart ; fieldRef . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; } else { Name typeRef = ( Name ) receiver ; fieldRef . setQualifier ( typeRef ) ; start = typeRef . getStartPosition ( ) ; end = fieldName . getStartPosition ( ) + fieldName . getLength ( ) - <NUM_LIT:1> ; fieldRef . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; } return fieldRef ; } catch ( ClassCastException ex ) { throw new InvalidInputException ( ) ; } } protected Object createMethodReference ( Object receiver , List arguments ) throws InvalidInputException { try { MethodRef methodRef = this . ast . newMethodRef ( ) ; SimpleName methodName = new SimpleName ( this . ast ) ; int length = this . identifierLengthStack [ <NUM_LIT:0> ] - <NUM_LIT:1> ; methodName . internalSetIdentifier ( new String ( this . identifierStack [ length ] ) ) ; methodRef . setName ( methodName ) ; int start = ( int ) ( this . identifierPositionStack [ length ] > > > <NUM_LIT:32> ) ; int end = ( int ) this . identifierPositionStack [ length ] ; methodName . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; if ( receiver == null ) { start = this . memberStart ; methodRef . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; } else { Name typeRef = ( Name ) receiver ; methodRef . setQualifier ( typeRef ) ; start = typeRef . getStartPosition ( ) ; } if ( arguments != null ) { Iterator parameters = arguments . listIterator ( ) ; while ( parameters . hasNext ( ) ) { MethodRefParameter param = ( MethodRefParameter ) parameters . next ( ) ; methodRef . parameters ( ) . add ( param ) ; } } methodRef . setSourceRange ( start , this . scanner . getCurrentTokenEndPosition ( ) - start + <NUM_LIT:1> ) ; return methodRef ; } catch ( ClassCastException ex ) { throw new InvalidInputException ( ) ; } } protected void createTag ( ) { TagElement tagElement = this . ast . newTagElement ( ) ; int position = this . scanner . currentPosition ; this . scanner . resetTo ( this . tagSourceStart , this . tagSourceEnd ) ; StringBuffer tagName = new StringBuffer ( ) ; int start = this . tagSourceStart ; this . scanner . getNextChar ( ) ; while ( this . scanner . currentPosition <= ( this . tagSourceEnd + <NUM_LIT:1> ) ) { tagName . append ( this . scanner . currentCharacter ) ; this . scanner . getNextChar ( ) ; } tagElement . setTagName ( tagName . toString ( ) ) ; if ( this . inlineTagStarted ) { start = this . inlineTagStart ; TagElement previousTag = null ; if ( this . astPtr == - <NUM_LIT:1> ) { previousTag = this . ast . newTagElement ( ) ; previousTag . setSourceRange ( start , this . tagSourceEnd - start + <NUM_LIT:1> ) ; pushOnAstStack ( previousTag , true ) ; } else { previousTag = ( TagElement ) this . astStack [ this . astPtr ] ; } int previousStart = previousTag . getStartPosition ( ) ; previousTag . fragments ( ) . add ( tagElement ) ; previousTag . setSourceRange ( previousStart , this . tagSourceEnd - previousStart + <NUM_LIT:1> ) ; } else { pushOnAstStack ( tagElement , true ) ; } tagElement . setSourceRange ( start , this . tagSourceEnd - start + <NUM_LIT:1> ) ; this . scanner . resetTo ( position , this . javadocEnd ) ; } protected Object createTypeReference ( int primitiveToken ) { int size = this . identifierLengthStack [ this . identifierLengthPtr ] ; String [ ] identifiers = new String [ size ] ; int pos = this . identifierPtr - size + <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { identifiers [ i ] = new String ( this . identifierStack [ pos + i ] ) ; } ASTNode typeRef = null ; if ( primitiveToken == - <NUM_LIT:1> ) { typeRef = this . ast . internalNewName ( identifiers ) ; } else { switch ( primitiveToken ) { case TerminalTokens . TokenNamevoid : typeRef = this . ast . newPrimitiveType ( PrimitiveType . VOID ) ; break ; case TerminalTokens . TokenNameboolean : typeRef = this . ast . newPrimitiveType ( PrimitiveType . BOOLEAN ) ; break ; case TerminalTokens . TokenNamebyte : typeRef = this . ast . newPrimitiveType ( PrimitiveType . BYTE ) ; break ; case TerminalTokens . TokenNamechar : typeRef = this . ast . newPrimitiveType ( PrimitiveType . CHAR ) ; break ; case TerminalTokens . TokenNamedouble : typeRef = this . ast . newPrimitiveType ( PrimitiveType . DOUBLE ) ; break ; case TerminalTokens . TokenNamefloat : typeRef = this . ast . newPrimitiveType ( PrimitiveType . FLOAT ) ; break ; case TerminalTokens . TokenNameint : typeRef = this . ast . newPrimitiveType ( PrimitiveType . INT ) ; break ; case TerminalTokens . TokenNamelong : typeRef = this . ast . newPrimitiveType ( PrimitiveType . LONG ) ; break ; case TerminalTokens . TokenNameshort : typeRef = this . ast . newPrimitiveType ( PrimitiveType . SHORT ) ; break ; default : return null ; } } int start = ( int ) ( this . identifierPositionStack [ pos ] > > > <NUM_LIT:32> ) ; if ( size > <NUM_LIT:1> ) { Name name = ( Name ) typeRef ; int nameIndex = size ; for ( int i = this . identifierPtr ; i > pos ; i -- , nameIndex -- ) { int s = ( int ) ( this . identifierPositionStack [ i ] > > > <NUM_LIT:32> ) ; int e = ( int ) this . identifierPositionStack [ i ] ; name . index = nameIndex ; SimpleName simpleName = ( ( QualifiedName ) name ) . getName ( ) ; simpleName . index = nameIndex ; simpleName . setSourceRange ( s , e - s + <NUM_LIT:1> ) ; name . setSourceRange ( start , e - start + <NUM_LIT:1> ) ; name = ( ( QualifiedName ) name ) . getQualifier ( ) ; } int end = ( int ) this . identifierPositionStack [ pos ] ; name . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; name . index = nameIndex ; } else { int end = ( int ) this . identifierPositionStack [ pos ] ; typeRef . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; } return typeRef ; } protected boolean parseIdentifierTag ( boolean report ) { if ( super . parseIdentifierTag ( report ) ) { createTag ( ) ; this . index = this . tagSourceEnd + <NUM_LIT:1> ; this . scanner . resetTo ( this . index , this . javadocEnd ) ; return true ; } return false ; } protected boolean parseReturn ( ) { createTag ( ) ; return true ; } protected boolean parseTag ( int previousPosition ) throws InvalidInputException { int currentPosition = this . index ; int token = readTokenAndConsume ( ) ; char [ ] tagName = CharOperation . NO_CHAR ; if ( currentPosition == this . scanner . startPosition ) { this . tagSourceStart = this . scanner . getCurrentTokenStartPosition ( ) ; this . tagSourceEnd = this . scanner . getCurrentTokenEndPosition ( ) ; tagName = this . scanner . getCurrentIdentifierSource ( ) ; } else { this . tagSourceEnd = currentPosition - <NUM_LIT:1> ; } if ( this . scanner . currentCharacter != '<CHAR_LIT:U+0020>' && ! ScannerHelper . isWhitespace ( this . scanner . currentCharacter ) ) { tagNameToken : while ( token != TerminalTokens . TokenNameEOF && this . index < this . scanner . eofPosition ) { int length = tagName . length ; switch ( this . scanner . currentCharacter ) { case '<CHAR_LIT:}>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<STR_LIT>' : case '<CHAR_LIT:">' : case '<CHAR_LIT::>' : case '<CHAR_LIT>' : case '<CHAR_LIT:>>' : break tagNameToken ; case '<CHAR_LIT:->' : System . arraycopy ( tagName , <NUM_LIT:0> , tagName = new char [ length + <NUM_LIT:1> ] , <NUM_LIT:0> , length ) ; tagName [ length ] = this . scanner . currentCharacter ; break ; default : if ( this . scanner . currentCharacter == '<CHAR_LIT:U+0020>' || ScannerHelper . isWhitespace ( this . scanner . currentCharacter ) ) { break tagNameToken ; } token = readTokenAndConsume ( ) ; char [ ] ident = this . scanner . getCurrentIdentifierSource ( ) ; System . arraycopy ( tagName , <NUM_LIT:0> , tagName = new char [ length + ident . length ] , <NUM_LIT:0> , length ) ; System . arraycopy ( ident , <NUM_LIT:0> , tagName , length , ident . length ) ; break ; } this . tagSourceEnd = this . scanner . getCurrentTokenEndPosition ( ) ; this . scanner . getNextChar ( ) ; this . index = this . scanner . currentPosition ; } } int length = tagName . length ; this . index = this . tagSourceEnd + <NUM_LIT:1> ; this . scanner . currentPosition = this . tagSourceEnd + <NUM_LIT:1> ; this . tagSourceStart = previousPosition ; if ( tagName . length == <NUM_LIT:0> ) { return false ; } this . tagValue = NO_TAG_VALUE ; boolean valid = true ; switch ( token ) { case TerminalTokens . TokenNameIdentifier : switch ( tagName [ <NUM_LIT:0> ] ) { case '<CHAR_LIT:c>' : if ( length == TAG_CATEGORY_LENGTH && CharOperation . equals ( TAG_CATEGORY , tagName ) ) { this . tagValue = TAG_CATEGORY_VALUE ; valid = parseIdentifierTag ( false ) ; } else { this . tagValue = TAG_OTHERS_VALUE ; createTag ( ) ; } break ; case '<CHAR_LIT>' : if ( length == TAG_DEPRECATED_LENGTH && CharOperation . equals ( TAG_DEPRECATED , tagName ) ) { this . deprecated = true ; this . tagValue = TAG_DEPRECATED_VALUE ; } else { this . tagValue = TAG_OTHERS_VALUE ; } createTag ( ) ; break ; case '<CHAR_LIT>' : if ( length == TAG_INHERITDOC_LENGTH && CharOperation . equals ( TAG_INHERITDOC , tagName ) ) { if ( this . reportProblems ) { recordInheritedPosition ( ( ( ( long ) this . tagSourceStart ) << <NUM_LIT:32> ) + this . tagSourceEnd ) ; } this . tagValue = TAG_INHERITDOC_VALUE ; } else { this . tagValue = TAG_OTHERS_VALUE ; } createTag ( ) ; break ; case '<CHAR_LIT>' : if ( length == TAG_PARAM_LENGTH && CharOperation . equals ( TAG_PARAM , tagName ) ) { this . tagValue = TAG_PARAM_VALUE ; valid = parseParam ( ) ; } else { this . tagValue = TAG_OTHERS_VALUE ; createTag ( ) ; } break ; case '<CHAR_LIT:e>' : if ( length == TAG_EXCEPTION_LENGTH && CharOperation . equals ( TAG_EXCEPTION , tagName ) ) { this . tagValue = TAG_EXCEPTION_VALUE ; valid = parseThrows ( ) ; } else { this . tagValue = TAG_OTHERS_VALUE ; createTag ( ) ; } break ; case '<CHAR_LIT>' : if ( length == TAG_SEE_LENGTH && CharOperation . equals ( TAG_SEE , tagName ) ) { this . tagValue = TAG_SEE_VALUE ; if ( this . inlineTagStarted ) { valid = false ; } else { valid = parseReference ( ) ; } } else { this . tagValue = TAG_OTHERS_VALUE ; createTag ( ) ; } break ; case '<CHAR_LIT>' : if ( length == TAG_LINK_LENGTH && CharOperation . equals ( TAG_LINK , tagName ) ) { this . tagValue = TAG_LINK_VALUE ; } else if ( length == TAG_LINKPLAIN_LENGTH && CharOperation . equals ( TAG_LINKPLAIN , tagName ) ) { this . tagValue = TAG_LINKPLAIN_VALUE ; } if ( this . tagValue != NO_TAG_VALUE ) { if ( this . inlineTagStarted ) { valid = parseReference ( ) ; } else { valid = false ; } } else { this . tagValue = TAG_OTHERS_VALUE ; createTag ( ) ; } break ; case '<CHAR_LIT>' : if ( this . sourceLevel >= ClassFileConstants . JDK1_5 && length == TAG_VALUE_LENGTH && CharOperation . equals ( TAG_VALUE , tagName ) ) { this . tagValue = TAG_VALUE_VALUE ; if ( this . inlineTagStarted ) { valid = parseReference ( ) ; } else { valid = false ; } } else { this . tagValue = TAG_OTHERS_VALUE ; createTag ( ) ; } break ; default : this . tagValue = TAG_OTHERS_VALUE ; createTag ( ) ; } break ; case TerminalTokens . TokenNamereturn : this . tagValue = TAG_RETURN_VALUE ; valid = parseReturn ( ) ; break ; case TerminalTokens . TokenNamethrows : this . tagValue = TAG_THROWS_VALUE ; valid = parseThrows ( ) ; break ; case TerminalTokens . TokenNameabstract : case TerminalTokens . TokenNameassert : case TerminalTokens . TokenNameboolean : case TerminalTokens . TokenNamebreak : case TerminalTokens . TokenNamebyte : case TerminalTokens . TokenNamecase : case TerminalTokens . TokenNamecatch : case TerminalTokens . TokenNamechar : case TerminalTokens . TokenNameclass : case TerminalTokens . TokenNamecontinue : case TerminalTokens . TokenNamedefault : case TerminalTokens . TokenNamedo : case TerminalTokens . TokenNamedouble : case TerminalTokens . TokenNameelse : case TerminalTokens . TokenNameextends : case TerminalTokens . TokenNamefalse : case TerminalTokens . TokenNamefinal : case TerminalTokens . TokenNamefinally : case TerminalTokens . TokenNamefloat : case TerminalTokens . TokenNamefor : case TerminalTokens . TokenNameif : case TerminalTokens . TokenNameimplements : case TerminalTokens . TokenNameimport : case TerminalTokens . TokenNameinstanceof : case TerminalTokens . TokenNameint : case TerminalTokens . TokenNameinterface : case TerminalTokens . TokenNamelong : case TerminalTokens . TokenNamenative : case TerminalTokens . TokenNamenew : case TerminalTokens . TokenNamenull : case TerminalTokens . TokenNamepackage : case TerminalTokens . TokenNameprivate : case TerminalTokens . TokenNameprotected : case TerminalTokens . TokenNamepublic : case TerminalTokens . TokenNameshort : case TerminalTokens . TokenNamestatic : case TerminalTokens . TokenNamestrictfp : case TerminalTokens . TokenNamesuper : case TerminalTokens . TokenNameswitch : case TerminalTokens . TokenNamesynchronized : case TerminalTokens . TokenNamethis : case TerminalTokens . TokenNamethrow : case TerminalTokens . TokenNametransient : case TerminalTokens . TokenNametrue : case TerminalTokens . TokenNametry : case TerminalTokens . TokenNamevoid : case TerminalTokens . TokenNamevolatile : case TerminalTokens . TokenNamewhile : case TerminalTokens . TokenNameenum : case TerminalTokens . TokenNameconst : case TerminalTokens . TokenNamegoto : this . tagValue = TAG_OTHERS_VALUE ; createTag ( ) ; break ; } this . textStart = this . index ; return valid ; } protected boolean pushParamName ( boolean isTypeParam ) { int idIndex = isTypeParam ? <NUM_LIT:1> : <NUM_LIT:0> ; final SimpleName name = new SimpleName ( this . ast ) ; name . internalSetIdentifier ( new String ( this . identifierStack [ idIndex ] ) ) ; int nameStart = ( int ) ( this . identifierPositionStack [ idIndex ] > > > <NUM_LIT:32> ) ; int nameEnd = ( int ) ( this . identifierPositionStack [ idIndex ] & <NUM_LIT> ) ; name . setSourceRange ( nameStart , nameEnd - nameStart + <NUM_LIT:1> ) ; TagElement paramTag = this . ast . newTagElement ( ) ; paramTag . setTagName ( TagElement . TAG_PARAM ) ; if ( isTypeParam ) { TextElement text = this . ast . newTextElement ( ) ; text . setText ( new String ( this . identifierStack [ <NUM_LIT:0> ] ) ) ; int txtStart = ( int ) ( this . identifierPositionStack [ <NUM_LIT:0> ] > > > <NUM_LIT:32> ) ; int txtEnd = ( int ) ( this . identifierPositionStack [ <NUM_LIT:0> ] & <NUM_LIT> ) ; text . setSourceRange ( txtStart , txtEnd - txtStart + <NUM_LIT:1> ) ; paramTag . fragments ( ) . add ( text ) ; paramTag . fragments ( ) . add ( name ) ; text = this . ast . newTextElement ( ) ; text . setText ( new String ( this . identifierStack [ <NUM_LIT:2> ] ) ) ; txtStart = ( int ) ( this . identifierPositionStack [ <NUM_LIT:2> ] > > > <NUM_LIT:32> ) ; txtEnd = ( int ) ( this . identifierPositionStack [ <NUM_LIT:2> ] & <NUM_LIT> ) ; text . setSourceRange ( txtStart , txtEnd - txtStart + <NUM_LIT:1> ) ; paramTag . fragments ( ) . add ( text ) ; paramTag . setSourceRange ( this . tagSourceStart , txtEnd - this . tagSourceStart + <NUM_LIT:1> ) ; } else { paramTag . setSourceRange ( this . tagSourceStart , nameEnd - this . tagSourceStart + <NUM_LIT:1> ) ; paramTag . fragments ( ) . add ( name ) ; } pushOnAstStack ( paramTag , true ) ; return true ; } protected boolean pushSeeRef ( Object statement ) { TagElement seeTag = this . ast . newTagElement ( ) ; ASTNode node = ( ASTNode ) statement ; seeTag . fragments ( ) . add ( node ) ; int end = node . getStartPosition ( ) + node . getLength ( ) - <NUM_LIT:1> ; if ( this . inlineTagStarted ) { seeTag . setSourceRange ( this . inlineTagStart , end - this . inlineTagStart + <NUM_LIT:1> ) ; switch ( this . tagValue ) { case TAG_LINK_VALUE : seeTag . setTagName ( TagElement . TAG_LINK ) ; break ; case TAG_LINKPLAIN_VALUE : seeTag . setTagName ( TagElement . TAG_LINKPLAIN ) ; break ; case TAG_VALUE_VALUE : seeTag . setTagName ( TagElement . TAG_VALUE ) ; break ; } TagElement previousTag = null ; int previousStart = this . inlineTagStart ; if ( this . astPtr == - <NUM_LIT:1> ) { previousTag = this . ast . newTagElement ( ) ; pushOnAstStack ( previousTag , true ) ; } else { previousTag = ( TagElement ) this . astStack [ this . astPtr ] ; previousStart = previousTag . getStartPosition ( ) ; } previousTag . fragments ( ) . add ( seeTag ) ; previousTag . setSourceRange ( previousStart , end - previousStart + <NUM_LIT:1> ) ; } else { seeTag . setTagName ( TagElement . TAG_SEE ) ; seeTag . setSourceRange ( this . tagSourceStart , end - this . tagSourceStart + <NUM_LIT:1> ) ; pushOnAstStack ( seeTag , true ) ; } return true ; } protected void pushText ( int start , int end ) { TextElement text = this . ast . newTextElement ( ) ; text . setText ( new String ( this . source , start , end - start ) ) ; text . setSourceRange ( start , end - start ) ; TagElement previousTag = null ; int previousStart = start ; if ( this . astPtr == - <NUM_LIT:1> ) { previousTag = this . ast . newTagElement ( ) ; previousTag . setSourceRange ( start , end - start ) ; pushOnAstStack ( previousTag , true ) ; } else { previousTag = ( TagElement ) this . astStack [ this . astPtr ] ; previousStart = previousTag . getStartPosition ( ) ; } List fragments = previousTag . fragments ( ) ; if ( this . inlineTagStarted ) { int size = fragments . size ( ) ; if ( size == <NUM_LIT:0> ) { TagElement inlineTag = this . ast . newTagElement ( ) ; fragments . add ( inlineTag ) ; previousTag = inlineTag ; } else { ASTNode lastFragment = ( ASTNode ) fragments . get ( size - <NUM_LIT:1> ) ; if ( lastFragment . getNodeType ( ) == ASTNode . TAG_ELEMENT ) { previousTag = ( TagElement ) lastFragment ; previousStart = previousTag . getStartPosition ( ) ; } } } previousTag . fragments ( ) . add ( text ) ; previousTag . setSourceRange ( previousStart , end - previousStart ) ; this . textStart = - <NUM_LIT:1> ; } protected boolean pushThrowName ( Object typeRef ) { TagElement throwsTag = this . ast . newTagElement ( ) ; switch ( this . tagValue ) { case TAG_THROWS_VALUE : throwsTag . setTagName ( TagElement . TAG_THROWS ) ; break ; case TAG_EXCEPTION_VALUE : throwsTag . setTagName ( TagElement . TAG_EXCEPTION ) ; break ; } throwsTag . setSourceRange ( this . tagSourceStart , this . scanner . getCurrentTokenEndPosition ( ) - this . tagSourceStart + <NUM_LIT:1> ) ; throwsTag . fragments ( ) . add ( typeRef ) ; pushOnAstStack ( throwsTag , true ) ; return true ; } protected void refreshInlineTagPosition ( int previousPosition ) { if ( this . astPtr != - <NUM_LIT:1> ) { TagElement previousTag = ( TagElement ) this . astStack [ this . astPtr ] ; if ( this . inlineTagStarted ) { int previousStart = previousTag . getStartPosition ( ) ; previousTag . setSourceRange ( previousStart , previousPosition - previousStart + <NUM_LIT:1> ) ; if ( previousTag . fragments ( ) . size ( ) > <NUM_LIT:0> ) { ASTNode inlineTag = ( ASTNode ) previousTag . fragments ( ) . get ( previousTag . fragments ( ) . size ( ) - <NUM_LIT:1> ) ; if ( inlineTag . getNodeType ( ) == ASTNode . TAG_ELEMENT ) { int inlineStart = inlineTag . getStartPosition ( ) ; inlineTag . setSourceRange ( inlineStart , previousPosition - inlineStart + <NUM_LIT:1> ) ; } } } } } protected void updateDocComment ( ) { for ( int idx = <NUM_LIT:0> ; idx <= this . astPtr ; idx ++ ) { this . docComment . tags ( ) . add ( this . astStack [ idx ] ) ; } } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class AnnotationTypeDeclaration extends AbstractTypeDeclaration { public static final ChildPropertyDescriptor JAVADOC_PROPERTY = internalJavadocPropertyFactory ( AnnotationTypeDeclaration . class ) ; public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY = internalModifiers2PropertyFactory ( AnnotationTypeDeclaration . class ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = internalNamePropertyFactory ( AnnotationTypeDeclaration . class ) ; public static final ChildListPropertyDescriptor BODY_DECLARATIONS_PROPERTY = internalBodyDeclarationPropertyFactory ( AnnotationTypeDeclaration . class ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:5> ) ; createPropertyList ( AnnotationTypeDeclaration . class , properyList ) ; addProperty ( JAVADOC_PROPERTY , properyList ) ; addProperty ( MODIFIERS2_PROPERTY , properyList ) ; addProperty ( NAME_PROPERTY , properyList ) ; addProperty ( BODY_DECLARATIONS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } AnnotationTypeDeclaration ( AST ast ) { super ( ast ) ; unsupportedIn2 ( ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == JAVADOC_PROPERTY ) { if ( get ) { return getJavadoc ( ) ; } else { setJavadoc ( ( Javadoc ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == MODIFIERS2_PROPERTY ) { return modifiers ( ) ; } if ( property == BODY_DECLARATIONS_PROPERTY ) { return bodyDeclarations ( ) ; } return super . internalGetChildListProperty ( property ) ; } final ChildPropertyDescriptor internalJavadocProperty ( ) { return JAVADOC_PROPERTY ; } final ChildListPropertyDescriptor internalModifiers2Property ( ) { return MODIFIERS2_PROPERTY ; } final SimplePropertyDescriptor internalModifiersProperty ( ) { return null ; } final ChildPropertyDescriptor internalNameProperty ( ) { return NAME_PROPERTY ; } final ChildListPropertyDescriptor internalBodyDeclarationsProperty ( ) { return BODY_DECLARATIONS_PROPERTY ; } final int getNodeType0 ( ) { return ANNOTATION_TYPE_DECLARATION ; } ASTNode clone0 ( AST target ) { AnnotationTypeDeclaration result = new AnnotationTypeDeclaration ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setJavadoc ( ( Javadoc ) ASTNode . copySubtree ( target , getJavadoc ( ) ) ) ; result . modifiers ( ) . addAll ( ASTNode . copySubtrees ( target , modifiers ( ) ) ) ; result . setName ( ( SimpleName ) getName ( ) . clone ( target ) ) ; result . bodyDeclarations ( ) . addAll ( ASTNode . copySubtrees ( target , bodyDeclarations ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getJavadoc ( ) ) ; acceptChildren ( visitor , this . modifiers ) ; acceptChild ( visitor , getName ( ) ) ; acceptChildren ( visitor , this . bodyDeclarations ) ; } visitor . endVisit ( this ) ; } ITypeBinding internalResolveBinding ( ) { return this . ast . getBindingResolver ( ) . resolveType ( this ) ; } int memSize ( ) { return super . memSize ( ) ; } int treeSize ( ) { return memSize ( ) + ( this . optionalDocComment == null ? <NUM_LIT:0> : getJavadoc ( ) . treeSize ( ) ) + this . modifiers . listSize ( ) + ( this . typeName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) + this . bodyDeclarations . listSize ( ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; public interface IPackageBinding extends IBinding { public String getName ( ) ; public boolean isUnnamed ( ) ; public String [ ] getNameComponents ( ) ; } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . HashMap ; import java . util . Map ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . AbstractVariableDeclaration ; import org . eclipse . jdt . internal . compiler . ast . AllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . ArrayAllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . ast . ExplicitConstructorCall ; import org . eclipse . jdt . internal . compiler . ast . FieldReference ; import org . eclipse . jdt . internal . compiler . ast . JavadocImplicitTypeReference ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . ast . JavadocAllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . JavadocFieldReference ; import org . eclipse . jdt . internal . compiler . ast . JavadocMessageSend ; import org . eclipse . jdt . internal . compiler . ast . JavadocQualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . JavadocSingleNameReference ; import org . eclipse . jdt . internal . compiler . ast . JavadocSingleTypeReference ; import org . eclipse . jdt . internal . compiler . ast . Literal ; import org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ; import org . eclipse . jdt . internal . compiler . ast . MemberValuePair ; import org . eclipse . jdt . internal . compiler . ast . MessageSend ; import org . eclipse . jdt . internal . compiler . ast . ParameterizedQualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . QualifiedNameReference ; import org . eclipse . jdt . internal . compiler . ast . QualifiedSuperReference ; import org . eclipse . jdt . internal . compiler . ast . QualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . SingleNameReference ; import org . eclipse . jdt . internal . compiler . ast . SingleTypeReference ; import org . eclipse . jdt . internal . compiler . ast . ThisReference ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . impl . Constant ; import org . eclipse . jdt . internal . compiler . lookup . ArrayBinding ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . CompilationUnitScope ; import org . eclipse . jdt . internal . compiler . lookup . ElementValuePair ; import org . eclipse . jdt . internal . compiler . lookup . FieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . LocalVariableBinding ; import org . eclipse . jdt . internal . compiler . lookup . LookupEnvironment ; import org . eclipse . jdt . internal . compiler . lookup . ParameterizedGenericMethodBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemFieldBinding ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReasons ; import org . eclipse . jdt . internal . compiler . lookup . ProblemReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . ReferenceBinding ; import org . eclipse . jdt . internal . compiler . lookup . Scope ; import org . eclipse . jdt . internal . compiler . lookup . TagBits ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . compiler . lookup . TypeIds ; import org . eclipse . jdt . internal . compiler . problem . AbortCompilation ; import org . eclipse . jdt . internal . core . util . Util ; class DefaultBindingResolver extends BindingResolver { static class BindingTables { Map bindingKeysToBindings ; Map compilerBindingsToASTBindings ; BindingTables ( ) { this . compilerBindingsToASTBindings = new HashMap ( ) ; this . bindingKeysToBindings = new HashMap ( ) ; } } Map astNodesToBlockScope ; Map bindingsToAstNodes ; BindingTables bindingTables ; Map newAstToOldAst ; private CompilationUnitScope scope ; WorkingCopyOwner workingCopyOwner ; boolean isRecoveringBindings ; boolean fromJavaProject ; DefaultBindingResolver ( CompilationUnitScope scope , WorkingCopyOwner workingCopyOwner , BindingTables bindingTables , boolean isRecoveringBindings , boolean fromJavaProject ) { this . newAstToOldAst = new HashMap ( ) ; this . astNodesToBlockScope = new HashMap ( ) ; this . bindingsToAstNodes = new HashMap ( ) ; this . bindingTables = bindingTables ; this . scope = scope ; this . workingCopyOwner = workingCopyOwner ; this . isRecoveringBindings = isRecoveringBindings ; this . fromJavaProject = fromJavaProject ; } DefaultBindingResolver ( LookupEnvironment lookupEnvironment , WorkingCopyOwner workingCopyOwner , BindingTables bindingTables , boolean isRecoveringBindings , boolean fromJavaProject ) { this . newAstToOldAst = new HashMap ( ) ; this . astNodesToBlockScope = new HashMap ( ) ; this . bindingsToAstNodes = new HashMap ( ) ; this . bindingTables = bindingTables ; this . scope = new CompilationUnitScope ( new CompilationUnitDeclaration ( null , null , - <NUM_LIT:1> ) , lookupEnvironment ) ; this . workingCopyOwner = workingCopyOwner ; this . isRecoveringBindings = isRecoveringBindings ; this . fromJavaProject = fromJavaProject ; } synchronized ASTNode findDeclaringNode ( IBinding binding ) { if ( binding == null ) { return null ; } if ( binding instanceof IMethodBinding ) { IMethodBinding methodBinding = ( IMethodBinding ) binding ; return ( ASTNode ) this . bindingsToAstNodes . get ( methodBinding . getMethodDeclaration ( ) ) ; } else if ( binding instanceof ITypeBinding ) { ITypeBinding typeBinding = ( ITypeBinding ) binding ; return ( ASTNode ) this . bindingsToAstNodes . get ( typeBinding . getTypeDeclaration ( ) ) ; } else if ( binding instanceof IVariableBinding ) { IVariableBinding variableBinding = ( IVariableBinding ) binding ; return ( ASTNode ) this . bindingsToAstNodes . get ( variableBinding . getVariableDeclaration ( ) ) ; } return ( ASTNode ) this . bindingsToAstNodes . get ( binding ) ; } synchronized ASTNode findDeclaringNode ( String bindingKey ) { if ( bindingKey == null ) { return null ; } Object binding = this . bindingTables . bindingKeysToBindings . get ( bindingKey ) ; if ( binding == null ) return null ; return ( ASTNode ) this . bindingsToAstNodes . get ( binding ) ; } IBinding getBinding ( org . eclipse . jdt . internal . compiler . lookup . Binding binding ) { switch ( binding . kind ( ) ) { case Binding . PACKAGE : return getPackageBinding ( ( org . eclipse . jdt . internal . compiler . lookup . PackageBinding ) binding ) ; case Binding . TYPE : case Binding . BASE_TYPE : case Binding . GENERIC_TYPE : case Binding . PARAMETERIZED_TYPE : case Binding . RAW_TYPE : return getTypeBinding ( ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) binding ) ; case Binding . ARRAY_TYPE : case Binding . TYPE_PARAMETER : return new TypeBinding ( this , ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) binding ) ; case Binding . METHOD : return getMethodBinding ( ( org . eclipse . jdt . internal . compiler . lookup . MethodBinding ) binding ) ; case Binding . FIELD : case Binding . LOCAL : return getVariableBinding ( ( org . eclipse . jdt . internal . compiler . lookup . VariableBinding ) binding ) ; } return null ; } Util . BindingsToNodesMap getBindingsToNodesMap ( ) { return new Util . BindingsToNodesMap ( ) { public org . eclipse . jdt . internal . compiler . ast . ASTNode get ( Binding binding ) { return ( org . eclipse . jdt . internal . compiler . ast . ASTNode ) DefaultBindingResolver . this . newAstToOldAst . get ( DefaultBindingResolver . this . bindingsToAstNodes . get ( binding ) ) ; } } ; } synchronized org . eclipse . jdt . internal . compiler . ast . ASTNode getCorrespondingNode ( ASTNode currentNode ) { return ( org . eclipse . jdt . internal . compiler . ast . ASTNode ) this . newAstToOldAst . get ( currentNode ) ; } synchronized IMethodBinding getMethodBinding ( org . eclipse . jdt . internal . compiler . lookup . MethodBinding methodBinding ) { if ( methodBinding != null && ! methodBinding . isValidBinding ( ) ) { org . eclipse . jdt . internal . compiler . lookup . ProblemMethodBinding problemMethodBinding = ( org . eclipse . jdt . internal . compiler . lookup . ProblemMethodBinding ) methodBinding ; methodBinding = problemMethodBinding . closestMatch ; } if ( methodBinding != null ) { if ( ! this . isRecoveringBindings && ( ( methodBinding . tagBits & TagBits . HasMissingType ) != <NUM_LIT:0> ) ) { return null ; } IMethodBinding binding = ( IMethodBinding ) this . bindingTables . compilerBindingsToASTBindings . get ( methodBinding ) ; if ( binding != null ) { return binding ; } binding = new MethodBinding ( this , methodBinding ) ; this . bindingTables . compilerBindingsToASTBindings . put ( methodBinding , binding ) ; return binding ; } return null ; } synchronized IMemberValuePairBinding getMemberValuePairBinding ( ElementValuePair valuePair ) { if ( valuePair == null || valuePair . binding == null ) return null ; IMemberValuePairBinding binding = ( IMemberValuePairBinding ) this . bindingTables . compilerBindingsToASTBindings . get ( valuePair ) ; if ( binding != null ) return binding ; binding = new MemberValuePairBinding ( valuePair , this ) ; this . bindingTables . compilerBindingsToASTBindings . put ( valuePair , binding ) ; return binding ; } synchronized IPackageBinding getPackageBinding ( org . eclipse . jdt . internal . compiler . lookup . PackageBinding packageBinding ) { if ( packageBinding == null ) { return null ; } IPackageBinding binding = ( IPackageBinding ) this . bindingTables . compilerBindingsToASTBindings . get ( packageBinding ) ; if ( binding != null ) { return binding ; } binding = new PackageBinding ( packageBinding , this ) ; this . bindingTables . compilerBindingsToASTBindings . put ( packageBinding , binding ) ; return binding ; } private int getTypeArguments ( ParameterizedQualifiedTypeReference typeReference ) { TypeReference [ ] [ ] typeArguments = typeReference . typeArguments ; int value = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> , max = typeArguments . length ; i < max ; i ++ ) { if ( ( typeArguments [ i ] != null ) || ( value != <NUM_LIT:0> ) ) { value ++ ; } } return value ; } synchronized ITypeBinding getTypeBinding ( VariableDeclaration variableDeclaration ) { ITypeBinding binding = ( ITypeBinding ) this . bindingTables . compilerBindingsToASTBindings . get ( variableDeclaration ) ; if ( binding != null ) { return binding ; } binding = new RecoveredTypeBinding ( this , variableDeclaration ) ; this . bindingTables . compilerBindingsToASTBindings . put ( variableDeclaration , binding ) ; return binding ; } synchronized ITypeBinding getTypeBinding ( Type type ) { ITypeBinding binding = ( ITypeBinding ) this . bindingTables . compilerBindingsToASTBindings . get ( type ) ; if ( binding != null ) { return binding ; } binding = new RecoveredTypeBinding ( this , type ) ; this . bindingTables . compilerBindingsToASTBindings . put ( type , binding ) ; return binding ; } synchronized ITypeBinding getTypeBinding ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding referenceBinding ) { if ( referenceBinding == null ) { return null ; } else if ( ! referenceBinding . isValidBinding ( ) ) { switch ( referenceBinding . problemId ( ) ) { case ProblemReasons . NotVisible : case ProblemReasons . NonStaticReferenceInStaticContext : if ( referenceBinding instanceof ProblemReferenceBinding ) { ProblemReferenceBinding problemReferenceBinding = ( ProblemReferenceBinding ) referenceBinding ; org . eclipse . jdt . internal . compiler . lookup . TypeBinding binding2 = problemReferenceBinding . closestMatch ( ) ; ITypeBinding binding = ( ITypeBinding ) this . bindingTables . compilerBindingsToASTBindings . get ( binding2 ) ; if ( binding != null ) { return binding ; } binding = new TypeBinding ( this , binding2 ) ; this . bindingTables . compilerBindingsToASTBindings . put ( binding2 , binding ) ; return binding ; } break ; case ProblemReasons . NotFound : if ( ! this . isRecoveringBindings ) { return null ; } ITypeBinding binding = ( ITypeBinding ) this . bindingTables . compilerBindingsToASTBindings . get ( referenceBinding ) ; if ( binding != null ) { return binding ; } if ( ( referenceBinding . tagBits & TagBits . HasMissingType ) != <NUM_LIT:0> ) { binding = new TypeBinding ( this , referenceBinding ) ; } else { binding = new RecoveredTypeBinding ( this , referenceBinding ) ; } this . bindingTables . compilerBindingsToASTBindings . put ( referenceBinding , binding ) ; return binding ; } return null ; } else { if ( ( referenceBinding . tagBits & TagBits . HasMissingType ) != <NUM_LIT:0> && ! this . isRecoveringBindings ) { return null ; } ITypeBinding binding = ( ITypeBinding ) this . bindingTables . compilerBindingsToASTBindings . get ( referenceBinding ) ; if ( binding != null ) { return binding ; } binding = new TypeBinding ( this , referenceBinding ) ; this . bindingTables . compilerBindingsToASTBindings . put ( referenceBinding , binding ) ; return binding ; } } synchronized ITypeBinding getTypeBinding ( RecoveredTypeBinding recoveredTypeBinding , int dimensions ) { if ( recoveredTypeBinding == null ) { return null ; } return new RecoveredTypeBinding ( this , recoveredTypeBinding , dimensions ) ; } synchronized IVariableBinding getVariableBinding ( org . eclipse . jdt . internal . compiler . lookup . VariableBinding variableBinding , VariableDeclaration variableDeclaration ) { if ( this . isRecoveringBindings ) { if ( variableBinding != null ) { if ( variableBinding . isValidBinding ( ) ) { IVariableBinding binding = ( IVariableBinding ) this . bindingTables . compilerBindingsToASTBindings . get ( variableBinding ) ; if ( binding != null ) { return binding ; } if ( variableBinding . type != null ) { binding = new VariableBinding ( this , variableBinding ) ; } else { binding = new RecoveredVariableBinding ( this , variableDeclaration ) ; } this . bindingTables . compilerBindingsToASTBindings . put ( variableBinding , binding ) ; return binding ; } else { if ( variableBinding instanceof ProblemFieldBinding ) { ProblemFieldBinding problemFieldBinding = ( ProblemFieldBinding ) variableBinding ; switch ( problemFieldBinding . problemId ( ) ) { case ProblemReasons . NotVisible : case ProblemReasons . NonStaticReferenceInStaticContext : case ProblemReasons . NonStaticReferenceInConstructorInvocation : ReferenceBinding declaringClass = problemFieldBinding . declaringClass ; FieldBinding exactBinding = declaringClass . getField ( problemFieldBinding . name , true ) ; if ( exactBinding != null ) { IVariableBinding variableBinding2 = ( IVariableBinding ) this . bindingTables . compilerBindingsToASTBindings . get ( exactBinding ) ; if ( variableBinding2 != null ) { return variableBinding2 ; } variableBinding2 = new VariableBinding ( this , exactBinding ) ; this . bindingTables . compilerBindingsToASTBindings . put ( exactBinding , variableBinding2 ) ; return variableBinding2 ; } break ; } } } } return null ; } return this . getVariableBinding ( variableBinding ) ; } public WorkingCopyOwner getWorkingCopyOwner ( ) { return this . workingCopyOwner ; } synchronized IVariableBinding getVariableBinding ( org . eclipse . jdt . internal . compiler . lookup . VariableBinding variableBinding ) { if ( variableBinding != null ) { if ( variableBinding . isValidBinding ( ) ) { org . eclipse . jdt . internal . compiler . lookup . TypeBinding variableType = variableBinding . type ; if ( variableType != null ) { if ( ! this . isRecoveringBindings && ( ( variableType . tagBits & TagBits . HasMissingType ) != <NUM_LIT:0> ) ) { return null ; } IVariableBinding binding = ( IVariableBinding ) this . bindingTables . compilerBindingsToASTBindings . get ( variableBinding ) ; if ( binding != null ) { return binding ; } binding = new VariableBinding ( this , variableBinding ) ; this . bindingTables . compilerBindingsToASTBindings . put ( variableBinding , binding ) ; return binding ; } } else { if ( variableBinding instanceof ProblemFieldBinding ) { ProblemFieldBinding problemFieldBinding = ( ProblemFieldBinding ) variableBinding ; switch ( problemFieldBinding . problemId ( ) ) { case ProblemReasons . NotVisible : case ProblemReasons . NonStaticReferenceInStaticContext : case ProblemReasons . NonStaticReferenceInConstructorInvocation : ReferenceBinding declaringClass = problemFieldBinding . declaringClass ; FieldBinding exactBinding = declaringClass . getField ( problemFieldBinding . name , true ) ; if ( exactBinding != null ) { IVariableBinding variableBinding2 = ( IVariableBinding ) this . bindingTables . compilerBindingsToASTBindings . get ( exactBinding ) ; if ( variableBinding2 != null ) { return variableBinding2 ; } variableBinding2 = new VariableBinding ( this , exactBinding ) ; this . bindingTables . compilerBindingsToASTBindings . put ( exactBinding , variableBinding2 ) ; return variableBinding2 ; } break ; } } } } return null ; } synchronized IAnnotationBinding getAnnotationInstance ( org . eclipse . jdt . internal . compiler . lookup . AnnotationBinding internalInstance ) { if ( internalInstance == null ) return null ; ReferenceBinding annotationType = internalInstance . getAnnotationType ( ) ; if ( ! this . isRecoveringBindings ) { if ( annotationType == null || ( ( annotationType . tagBits & TagBits . HasMissingType ) != <NUM_LIT:0> ) ) { return null ; } } IAnnotationBinding domInstance = ( IAnnotationBinding ) this . bindingTables . compilerBindingsToASTBindings . get ( internalInstance ) ; if ( domInstance != null ) return domInstance ; domInstance = new AnnotationBinding ( internalInstance , this ) ; this . bindingTables . compilerBindingsToASTBindings . put ( internalInstance , domInstance ) ; return domInstance ; } boolean isResolvedTypeInferredFromExpectedType ( MethodInvocation methodInvocation ) { Object oldNode = this . newAstToOldAst . get ( methodInvocation ) ; if ( oldNode instanceof MessageSend ) { MessageSend messageSend = ( MessageSend ) oldNode ; org . eclipse . jdt . internal . compiler . lookup . MethodBinding methodBinding = messageSend . binding ; if ( methodBinding instanceof ParameterizedGenericMethodBinding ) { ParameterizedGenericMethodBinding genericMethodBinding = ( ParameterizedGenericMethodBinding ) methodBinding ; return genericMethodBinding . inferredReturnType ; } } return false ; } boolean isResolvedTypeInferredFromExpectedType ( SuperMethodInvocation superMethodInvocation ) { Object oldNode = this . newAstToOldAst . get ( superMethodInvocation ) ; if ( oldNode instanceof MessageSend ) { MessageSend messageSend = ( MessageSend ) oldNode ; org . eclipse . jdt . internal . compiler . lookup . MethodBinding methodBinding = messageSend . binding ; if ( methodBinding instanceof ParameterizedGenericMethodBinding ) { ParameterizedGenericMethodBinding genericMethodBinding = ( ParameterizedGenericMethodBinding ) methodBinding ; return genericMethodBinding . inferredReturnType ; } } return false ; } LookupEnvironment lookupEnvironment ( ) { return this . scope . environment ( ) ; } synchronized void recordScope ( ASTNode astNode , BlockScope blockScope ) { this . astNodesToBlockScope . put ( astNode , blockScope ) ; } boolean resolveBoxing ( Expression expression ) { org . eclipse . jdt . internal . compiler . ast . ASTNode node = ( org . eclipse . jdt . internal . compiler . ast . ASTNode ) this . newAstToOldAst . get ( expression ) ; if ( node instanceof org . eclipse . jdt . internal . compiler . ast . Expression ) { org . eclipse . jdt . internal . compiler . ast . Expression compilerExpression = ( org . eclipse . jdt . internal . compiler . ast . Expression ) node ; return ( compilerExpression . implicitConversion & TypeIds . BOXING ) != <NUM_LIT:0> ; } return false ; } boolean resolveUnboxing ( Expression expression ) { org . eclipse . jdt . internal . compiler . ast . ASTNode node = ( org . eclipse . jdt . internal . compiler . ast . ASTNode ) this . newAstToOldAst . get ( expression ) ; if ( node instanceof org . eclipse . jdt . internal . compiler . ast . Expression ) { org . eclipse . jdt . internal . compiler . ast . Expression compilerExpression = ( org . eclipse . jdt . internal . compiler . ast . Expression ) node ; return ( compilerExpression . implicitConversion & TypeIds . UNBOXING ) != <NUM_LIT:0> ; } return false ; } Object resolveConstantExpressionValue ( Expression expression ) { org . eclipse . jdt . internal . compiler . ast . ASTNode node = ( org . eclipse . jdt . internal . compiler . ast . ASTNode ) this . newAstToOldAst . get ( expression ) ; if ( node instanceof org . eclipse . jdt . internal . compiler . ast . Expression ) { org . eclipse . jdt . internal . compiler . ast . Expression compilerExpression = ( org . eclipse . jdt . internal . compiler . ast . Expression ) node ; Constant constant = compilerExpression . constant ; if ( constant != null && constant != Constant . NotAConstant ) { switch ( constant . typeID ( ) ) { case TypeIds . T_int : return new Integer ( constant . intValue ( ) ) ; case TypeIds . T_byte : return new Byte ( constant . byteValue ( ) ) ; case TypeIds . T_short : return new Short ( constant . shortValue ( ) ) ; case TypeIds . T_char : return new Character ( constant . charValue ( ) ) ; case TypeIds . T_float : return new Float ( constant . floatValue ( ) ) ; case TypeIds . T_double : return new Double ( constant . doubleValue ( ) ) ; case TypeIds . T_boolean : return constant . booleanValue ( ) ? Boolean . TRUE : Boolean . FALSE ; case TypeIds . T_long : return new Long ( constant . longValue ( ) ) ; case TypeIds . T_JavaLangString : return constant . stringValue ( ) ; } return null ; } } return null ; } synchronized IMethodBinding resolveConstructor ( ClassInstanceCreation expression ) { org . eclipse . jdt . internal . compiler . ast . ASTNode node = ( org . eclipse . jdt . internal . compiler . ast . ASTNode ) this . newAstToOldAst . get ( expression ) ; if ( node != null && ( node . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . IsAnonymousType ) != <NUM_LIT:0> ) { org . eclipse . jdt . internal . compiler . ast . TypeDeclaration anonymousLocalTypeDeclaration = ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) node ; return getMethodBinding ( anonymousLocalTypeDeclaration . allocation . binding ) ; } else if ( node instanceof AllocationExpression ) { return getMethodBinding ( ( ( AllocationExpression ) node ) . binding ) ; } return null ; } synchronized IMethodBinding resolveConstructor ( ConstructorInvocation expression ) { org . eclipse . jdt . internal . compiler . ast . ASTNode node = ( org . eclipse . jdt . internal . compiler . ast . ASTNode ) this . newAstToOldAst . get ( expression ) ; if ( node instanceof ExplicitConstructorCall ) { ExplicitConstructorCall explicitConstructorCall = ( ExplicitConstructorCall ) node ; return getMethodBinding ( explicitConstructorCall . binding ) ; } return null ; } IMethodBinding resolveConstructor ( EnumConstantDeclaration enumConstantDeclaration ) { org . eclipse . jdt . internal . compiler . ast . ASTNode node = ( org . eclipse . jdt . internal . compiler . ast . ASTNode ) this . newAstToOldAst . get ( enumConstantDeclaration ) ; if ( node instanceof org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ) { org . eclipse . jdt . internal . compiler . ast . FieldDeclaration fieldDeclaration = ( org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ) node ; if ( fieldDeclaration . getKind ( ) == AbstractVariableDeclaration . ENUM_CONSTANT && fieldDeclaration . initialization != null ) { AllocationExpression allocationExpression = ( AllocationExpression ) fieldDeclaration . initialization ; return getMethodBinding ( allocationExpression . binding ) ; } } return null ; } synchronized IMethodBinding resolveConstructor ( SuperConstructorInvocation expression ) { org . eclipse . jdt . internal . compiler . ast . ASTNode node = ( org . eclipse . jdt . internal . compiler . ast . ASTNode ) this . newAstToOldAst . get ( expression ) ; if ( node instanceof ExplicitConstructorCall ) { ExplicitConstructorCall explicitConstructorCall = ( ExplicitConstructorCall ) node ; return getMethodBinding ( explicitConstructorCall . binding ) ; } return null ; } synchronized ITypeBinding resolveExpressionType ( Expression expression ) { try { switch ( expression . getNodeType ( ) ) { case ASTNode . CLASS_INSTANCE_CREATION : org . eclipse . jdt . internal . compiler . ast . ASTNode astNode = ( org . eclipse . jdt . internal . compiler . ast . ASTNode ) this . newAstToOldAst . get ( expression ) ; if ( astNode instanceof org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) { org . eclipse . jdt . internal . compiler . ast . TypeDeclaration typeDeclaration = ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) astNode ; ITypeBinding typeBinding = this . getTypeBinding ( typeDeclaration . binding ) ; if ( typeBinding != null ) { return typeBinding ; } } else if ( astNode instanceof AllocationExpression ) { AllocationExpression allocationExpression = ( AllocationExpression ) astNode ; return this . getTypeBinding ( allocationExpression . resolvedType ) ; } break ; case ASTNode . SIMPLE_NAME : case ASTNode . QUALIFIED_NAME : return resolveTypeBindingForName ( ( Name ) expression ) ; case ASTNode . ARRAY_INITIALIZER : case ASTNode . ARRAY_CREATION : case ASTNode . ASSIGNMENT : case ASTNode . POSTFIX_EXPRESSION : case ASTNode . PREFIX_EXPRESSION : case ASTNode . CAST_EXPRESSION : case ASTNode . TYPE_LITERAL : case ASTNode . INFIX_EXPRESSION : case ASTNode . INSTANCEOF_EXPRESSION : case ASTNode . FIELD_ACCESS : case ASTNode . SUPER_FIELD_ACCESS : case ASTNode . ARRAY_ACCESS : case ASTNode . METHOD_INVOCATION : case ASTNode . SUPER_METHOD_INVOCATION : case ASTNode . CONDITIONAL_EXPRESSION : case ASTNode . MARKER_ANNOTATION : case ASTNode . NORMAL_ANNOTATION : case ASTNode . SINGLE_MEMBER_ANNOTATION : org . eclipse . jdt . internal . compiler . ast . Expression compilerExpression = ( org . eclipse . jdt . internal . compiler . ast . Expression ) this . newAstToOldAst . get ( expression ) ; if ( compilerExpression != null ) { return this . getTypeBinding ( compilerExpression . resolvedType ) ; } break ; case ASTNode . STRING_LITERAL : if ( this . scope != null ) { return this . getTypeBinding ( this . scope . getJavaLangString ( ) ) ; } break ; case ASTNode . BOOLEAN_LITERAL : case ASTNode . NULL_LITERAL : case ASTNode . CHARACTER_LITERAL : case ASTNode . NUMBER_LITERAL : Literal literal = ( Literal ) this . newAstToOldAst . get ( expression ) ; if ( literal != null ) { return this . getTypeBinding ( literal . literalType ( null ) ) ; } break ; case ASTNode . THIS_EXPRESSION : ThisReference thisReference = ( ThisReference ) this . newAstToOldAst . get ( expression ) ; BlockScope blockScope = ( BlockScope ) this . astNodesToBlockScope . get ( expression ) ; if ( blockScope != null ) { return this . getTypeBinding ( thisReference . resolveType ( blockScope ) ) ; } break ; case ASTNode . PARENTHESIZED_EXPRESSION : ParenthesizedExpression parenthesizedExpression = ( ParenthesizedExpression ) expression ; return resolveExpressionType ( parenthesizedExpression . getExpression ( ) ) ; case ASTNode . VARIABLE_DECLARATION_EXPRESSION : VariableDeclarationExpression variableDeclarationExpression = ( VariableDeclarationExpression ) expression ; Type type = variableDeclarationExpression . getType ( ) ; if ( type != null ) { return type . resolveBinding ( ) ; } break ; } } catch ( AbortCompilation e ) { } return null ; } synchronized IVariableBinding resolveField ( FieldAccess fieldAccess ) { Object oldNode = this . newAstToOldAst . get ( fieldAccess ) ; if ( oldNode instanceof FieldReference ) { FieldReference fieldReference = ( FieldReference ) oldNode ; return this . getVariableBinding ( fieldReference . binding ) ; } return null ; } synchronized IVariableBinding resolveField ( SuperFieldAccess fieldAccess ) { Object oldNode = this . newAstToOldAst . get ( fieldAccess ) ; if ( oldNode instanceof FieldReference ) { FieldReference fieldReference = ( FieldReference ) oldNode ; return this . getVariableBinding ( fieldReference . binding ) ; } return null ; } synchronized IBinding resolveImport ( ImportDeclaration importDeclaration ) { if ( this . scope == null ) return null ; try { org . eclipse . jdt . internal . compiler . ast . ASTNode node = ( org . eclipse . jdt . internal . compiler . ast . ASTNode ) this . newAstToOldAst . get ( importDeclaration ) ; if ( node instanceof ImportReference ) { ImportReference importReference = ( ImportReference ) node ; final boolean isStatic = importReference . isStatic ( ) ; if ( ( importReference . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . OnDemand ) != <NUM_LIT:0> ) { Binding binding = this . scope . getImport ( CharOperation . subarray ( importReference . tokens , <NUM_LIT:0> , importReference . tokens . length ) , true , isStatic ) ; if ( binding != null ) { if ( isStatic ) { if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) { ITypeBinding typeBinding = this . getTypeBinding ( ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) binding ) ; return typeBinding == null ? null : typeBinding ; } } else { if ( ( binding . kind ( ) & Binding . PACKAGE ) != <NUM_LIT:0> ) { IPackageBinding packageBinding = getPackageBinding ( ( org . eclipse . jdt . internal . compiler . lookup . PackageBinding ) binding ) ; if ( packageBinding == null ) { return null ; } return packageBinding ; } else { ITypeBinding typeBinding = this . getTypeBinding ( ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) binding ) ; if ( typeBinding == null ) { return null ; } return typeBinding ; } } } } else { Binding binding = this . scope . getImport ( importReference . tokens , false , isStatic ) ; if ( binding != null ) { if ( isStatic ) { if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) { ITypeBinding typeBinding = this . getTypeBinding ( ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) binding ) ; return typeBinding == null ? null : typeBinding ; } else if ( binding instanceof FieldBinding ) { IVariableBinding variableBinding = this . getVariableBinding ( ( FieldBinding ) binding ) ; return variableBinding == null ? null : variableBinding ; } else if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . MethodBinding ) { return getMethodBinding ( ( org . eclipse . jdt . internal . compiler . lookup . MethodBinding ) binding ) ; } } else { if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) { ITypeBinding typeBinding = this . getTypeBinding ( ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) binding ) ; return typeBinding == null ? null : typeBinding ; } } } } } } catch ( AbortCompilation e ) { } return null ; } IMethodBinding resolveMember ( AnnotationTypeMemberDeclaration declaration ) { Object oldNode = this . newAstToOldAst . get ( declaration ) ; if ( oldNode instanceof AbstractMethodDeclaration ) { AbstractMethodDeclaration methodDeclaration = ( AbstractMethodDeclaration ) oldNode ; IMethodBinding methodBinding = getMethodBinding ( methodDeclaration . binding ) ; if ( methodBinding == null ) { return null ; } this . bindingsToAstNodes . put ( methodBinding , declaration ) ; String key = methodBinding . getKey ( ) ; if ( key != null ) { this . bindingTables . bindingKeysToBindings . put ( key , methodBinding ) ; } return methodBinding ; } return null ; } synchronized IMethodBinding resolveMethod ( MethodDeclaration method ) { Object oldNode = this . newAstToOldAst . get ( method ) ; if ( oldNode instanceof AbstractMethodDeclaration ) { AbstractMethodDeclaration methodDeclaration = ( AbstractMethodDeclaration ) oldNode ; IMethodBinding methodBinding = getMethodBinding ( methodDeclaration . binding ) ; if ( methodBinding == null ) { return null ; } this . bindingsToAstNodes . put ( methodBinding , method ) ; String key = methodBinding . getKey ( ) ; if ( key != null ) { this . bindingTables . bindingKeysToBindings . put ( key , methodBinding ) ; } return methodBinding ; } return null ; } synchronized IMethodBinding resolveMethod ( MethodInvocation method ) { Object oldNode = this . newAstToOldAst . get ( method ) ; if ( oldNode instanceof MessageSend ) { MessageSend messageSend = ( MessageSend ) oldNode ; return getMethodBinding ( messageSend . binding ) ; } return null ; } synchronized IMethodBinding resolveMethod ( SuperMethodInvocation method ) { Object oldNode = this . newAstToOldAst . get ( method ) ; if ( oldNode instanceof MessageSend ) { MessageSend messageSend = ( MessageSend ) oldNode ; return getMethodBinding ( messageSend . binding ) ; } return null ; } synchronized ITypeBinding resolveTypeBindingForName ( Name name ) { org . eclipse . jdt . internal . compiler . ast . ASTNode node = ( org . eclipse . jdt . internal . compiler . ast . ASTNode ) this . newAstToOldAst . get ( name ) ; int index = name . index ; if ( node instanceof QualifiedNameReference ) { QualifiedNameReference qualifiedNameReference = ( QualifiedNameReference ) node ; final char [ ] [ ] tokens = qualifiedNameReference . tokens ; if ( tokens . length == index ) { return this . getTypeBinding ( qualifiedNameReference . resolvedType ) ; } int indexOfFirstFieldBinding = qualifiedNameReference . indexOfFirstFieldBinding ; if ( index < indexOfFirstFieldBinding ) { BlockScope internalScope = ( BlockScope ) this . astNodesToBlockScope . get ( name ) ; Binding binding = null ; try { if ( internalScope == null ) { if ( this . scope == null ) return null ; binding = this . scope . getTypeOrPackage ( CharOperation . subarray ( tokens , <NUM_LIT:0> , index ) ) ; } else { binding = internalScope . getTypeOrPackage ( CharOperation . subarray ( tokens , <NUM_LIT:0> , index ) ) ; } } catch ( AbortCompilation e ) { } if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . PackageBinding ) { return null ; } else if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) { return this . getTypeBinding ( ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) binding ) ; } } else if ( index == indexOfFirstFieldBinding ) { if ( qualifiedNameReference . isTypeReference ( ) ) { return this . getTypeBinding ( qualifiedNameReference . resolvedType ) ; } else { if ( qualifiedNameReference . otherBindings == null ) { return null ; } FieldBinding fieldBinding = qualifiedNameReference . otherBindings [ <NUM_LIT:0> ] ; if ( fieldBinding == null ) return null ; org . eclipse . jdt . internal . compiler . lookup . TypeBinding type = fieldBinding . declaringClass ; if ( type == null ) { switch ( qualifiedNameReference . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . RestrictiveFlagMASK ) { case Binding . FIELD : type = ( ( FieldBinding ) qualifiedNameReference . binding ) . type ; break ; case Binding . LOCAL : type = ( ( LocalVariableBinding ) qualifiedNameReference . binding ) . type ; break ; } } return this . getTypeBinding ( type ) ; } } else { if ( qualifiedNameReference . otherBindings == null ) return null ; final int otherBindingsLength = qualifiedNameReference . otherBindings . length ; if ( otherBindingsLength == ( index - indexOfFirstFieldBinding ) ) { return this . getTypeBinding ( qualifiedNameReference . resolvedType ) ; } FieldBinding fieldBinding = qualifiedNameReference . otherBindings [ index - indexOfFirstFieldBinding ] ; if ( fieldBinding == null ) return null ; org . eclipse . jdt . internal . compiler . lookup . TypeBinding type = fieldBinding . declaringClass ; if ( type == null ) { fieldBinding = qualifiedNameReference . otherBindings [ index - indexOfFirstFieldBinding - <NUM_LIT:1> ] ; if ( fieldBinding == null ) return null ; type = fieldBinding . type ; } return this . getTypeBinding ( type ) ; } } else if ( node instanceof QualifiedTypeReference ) { QualifiedTypeReference qualifiedTypeReference = ( QualifiedTypeReference ) node ; if ( qualifiedTypeReference . resolvedType == null ) { return null ; } if ( index == qualifiedTypeReference . tokens . length ) { if ( ! qualifiedTypeReference . resolvedType . isValidBinding ( ) && qualifiedTypeReference instanceof JavadocQualifiedTypeReference ) { JavadocQualifiedTypeReference typeRef = ( JavadocQualifiedTypeReference ) node ; if ( typeRef . packageBinding != null ) { return null ; } } return this . getTypeBinding ( qualifiedTypeReference . resolvedType . leafComponentType ( ) ) ; } else { if ( index >= <NUM_LIT:0> ) { BlockScope internalScope = ( BlockScope ) this . astNodesToBlockScope . get ( name ) ; Binding binding = null ; try { if ( internalScope == null ) { if ( this . scope == null ) return null ; binding = this . scope . getTypeOrPackage ( CharOperation . subarray ( qualifiedTypeReference . tokens , <NUM_LIT:0> , index ) ) ; } else { binding = internalScope . getTypeOrPackage ( CharOperation . subarray ( qualifiedTypeReference . tokens , <NUM_LIT:0> , index ) ) ; } } catch ( AbortCompilation e ) { } if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . PackageBinding ) { return null ; } else if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) { return this . getTypeBinding ( ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) binding ) ; } else { return null ; } } } } else if ( node instanceof ImportReference ) { ImportReference importReference = ( ImportReference ) node ; int importReferenceLength = importReference . tokens . length ; if ( index >= <NUM_LIT:0> ) { Binding binding = null ; if ( this . scope == null ) return null ; if ( importReferenceLength == index ) { try { binding = this . scope . getImport ( CharOperation . subarray ( importReference . tokens , <NUM_LIT:0> , index ) , ( importReference . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . OnDemand ) != <NUM_LIT:0> , importReference . isStatic ( ) ) ; } catch ( AbortCompilation e ) { } } else { try { binding = this . scope . getImport ( CharOperation . subarray ( importReference . tokens , <NUM_LIT:0> , index ) , true , importReference . isStatic ( ) ) ; } catch ( AbortCompilation e ) { } } if ( binding != null ) { if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) { return this . getTypeBinding ( ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) binding ) ; } return null ; } } } else if ( node instanceof AbstractMethodDeclaration ) { AbstractMethodDeclaration methodDeclaration = ( AbstractMethodDeclaration ) node ; IMethodBinding method = getMethodBinding ( methodDeclaration . binding ) ; if ( method == null ) return null ; return method . getReturnType ( ) ; } else if ( node instanceof org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) { org . eclipse . jdt . internal . compiler . ast . TypeDeclaration typeDeclaration = ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) node ; ITypeBinding typeBinding = this . getTypeBinding ( typeDeclaration . binding ) ; if ( typeBinding != null ) { return typeBinding ; } } if ( node instanceof JavadocSingleNameReference ) { JavadocSingleNameReference singleNameReference = ( JavadocSingleNameReference ) node ; LocalVariableBinding localVariable = ( LocalVariableBinding ) singleNameReference . binding ; if ( localVariable != null ) { return this . getTypeBinding ( localVariable . type ) ; } } if ( node instanceof SingleNameReference ) { SingleNameReference singleNameReference = ( SingleNameReference ) node ; return this . getTypeBinding ( singleNameReference . resolvedType ) ; } else if ( node instanceof QualifiedSuperReference ) { QualifiedSuperReference qualifiedSuperReference = ( QualifiedSuperReference ) node ; return this . getTypeBinding ( qualifiedSuperReference . qualification . resolvedType ) ; } else if ( node instanceof LocalDeclaration ) { IVariableBinding variable = this . getVariableBinding ( ( ( LocalDeclaration ) node ) . binding ) ; if ( variable == null ) return null ; return variable . getType ( ) ; } else if ( node instanceof JavadocFieldReference ) { JavadocFieldReference fieldRef = ( JavadocFieldReference ) node ; if ( fieldRef . methodBinding != null ) { return getMethodBinding ( fieldRef . methodBinding ) . getReturnType ( ) ; } return getTypeBinding ( fieldRef . resolvedType ) ; } else if ( node instanceof FieldReference ) { return getTypeBinding ( ( ( FieldReference ) node ) . resolvedType ) ; } else if ( node instanceof SingleTypeReference ) { SingleTypeReference singleTypeReference = ( SingleTypeReference ) node ; org . eclipse . jdt . internal . compiler . lookup . TypeBinding binding = singleTypeReference . resolvedType ; if ( binding != null ) { return this . getTypeBinding ( binding . leafComponentType ( ) ) ; } } else if ( node instanceof org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ) { org . eclipse . jdt . internal . compiler . ast . FieldDeclaration fieldDeclaration = ( org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ) node ; IVariableBinding field = this . getVariableBinding ( fieldDeclaration . binding ) ; if ( field == null ) return null ; return field . getType ( ) ; } else if ( node instanceof MessageSend ) { MessageSend messageSend = ( MessageSend ) node ; IMethodBinding method = getMethodBinding ( messageSend . binding ) ; if ( method == null ) return null ; return method . getReturnType ( ) ; } else if ( node instanceof AllocationExpression ) { AllocationExpression allocation = ( AllocationExpression ) node ; return getTypeBinding ( allocation . resolvedType ) ; } else if ( node instanceof JavadocImplicitTypeReference ) { JavadocImplicitTypeReference implicitRef = ( JavadocImplicitTypeReference ) node ; return getTypeBinding ( implicitRef . resolvedType ) ; } else if ( node instanceof org . eclipse . jdt . internal . compiler . ast . TypeParameter ) { org . eclipse . jdt . internal . compiler . ast . TypeParameter typeParameter = ( org . eclipse . jdt . internal . compiler . ast . TypeParameter ) node ; return this . getTypeBinding ( typeParameter . binding ) ; } else if ( node instanceof org . eclipse . jdt . internal . compiler . ast . MemberValuePair ) { org . eclipse . jdt . internal . compiler . ast . MemberValuePair memberValuePair = ( org . eclipse . jdt . internal . compiler . ast . MemberValuePair ) node ; IMethodBinding method = getMethodBinding ( memberValuePair . binding ) ; if ( method == null ) return null ; return method . getReturnType ( ) ; } return null ; } synchronized IBinding resolveName ( Name name ) { org . eclipse . jdt . internal . compiler . ast . ASTNode node = ( org . eclipse . jdt . internal . compiler . ast . ASTNode ) this . newAstToOldAst . get ( name ) ; int index = name . index ; if ( node instanceof QualifiedNameReference ) { QualifiedNameReference qualifiedNameReference = ( QualifiedNameReference ) node ; final char [ ] [ ] tokens = qualifiedNameReference . tokens ; int indexOfFirstFieldBinding = qualifiedNameReference . indexOfFirstFieldBinding ; if ( index < indexOfFirstFieldBinding ) { BlockScope internalScope = ( BlockScope ) this . astNodesToBlockScope . get ( name ) ; Binding binding = null ; try { if ( internalScope == null ) { if ( this . scope == null ) return null ; binding = this . scope . getTypeOrPackage ( CharOperation . subarray ( tokens , <NUM_LIT:0> , index ) ) ; } else { binding = internalScope . getTypeOrPackage ( CharOperation . subarray ( tokens , <NUM_LIT:0> , index ) ) ; } } catch ( AbortCompilation e ) { } if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . PackageBinding ) { return getPackageBinding ( ( org . eclipse . jdt . internal . compiler . lookup . PackageBinding ) binding ) ; } else if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) { return this . getTypeBinding ( ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) binding ) ; } } else if ( index == indexOfFirstFieldBinding ) { if ( qualifiedNameReference . isTypeReference ( ) ) { return this . getTypeBinding ( qualifiedNameReference . resolvedType ) ; } else { Binding binding = qualifiedNameReference . binding ; if ( binding != null ) { if ( binding . isValidBinding ( ) ) { return this . getVariableBinding ( ( org . eclipse . jdt . internal . compiler . lookup . VariableBinding ) binding ) ; } else if ( binding instanceof ProblemFieldBinding ) { ProblemFieldBinding problemFieldBinding = ( ProblemFieldBinding ) binding ; switch ( problemFieldBinding . problemId ( ) ) { case ProblemReasons . NotVisible : case ProblemReasons . NonStaticReferenceInStaticContext : ReferenceBinding declaringClass = problemFieldBinding . declaringClass ; if ( declaringClass != null ) { FieldBinding exactBinding = declaringClass . getField ( tokens [ tokens . length - <NUM_LIT:1> ] , true ) ; if ( exactBinding != null ) { if ( exactBinding . type != null ) { IVariableBinding variableBinding = ( IVariableBinding ) this . bindingTables . compilerBindingsToASTBindings . get ( exactBinding ) ; if ( variableBinding != null ) { return variableBinding ; } variableBinding = new VariableBinding ( this , exactBinding ) ; this . bindingTables . compilerBindingsToASTBindings . put ( exactBinding , variableBinding ) ; return variableBinding ; } } } break ; } } } } } else { if ( qualifiedNameReference . otherBindings == null || ( index - indexOfFirstFieldBinding - <NUM_LIT:1> ) < <NUM_LIT:0> ) { return null ; } else { return this . getVariableBinding ( qualifiedNameReference . otherBindings [ index - indexOfFirstFieldBinding - <NUM_LIT:1> ] ) ; } } } else if ( node instanceof QualifiedTypeReference ) { QualifiedTypeReference qualifiedTypeReference = ( QualifiedTypeReference ) node ; if ( qualifiedTypeReference . resolvedType == null ) { return null ; } if ( index == qualifiedTypeReference . tokens . length ) { if ( ! qualifiedTypeReference . resolvedType . isValidBinding ( ) && qualifiedTypeReference instanceof JavadocQualifiedTypeReference ) { JavadocQualifiedTypeReference typeRef = ( JavadocQualifiedTypeReference ) node ; if ( typeRef . packageBinding != null ) { return getPackageBinding ( typeRef . packageBinding ) ; } } return this . getTypeBinding ( qualifiedTypeReference . resolvedType . leafComponentType ( ) ) ; } else { if ( index >= <NUM_LIT:0> ) { BlockScope internalScope = ( BlockScope ) this . astNodesToBlockScope . get ( name ) ; Binding binding = null ; try { if ( internalScope == null ) { if ( this . scope == null ) return null ; binding = this . scope . getTypeOrPackage ( CharOperation . subarray ( qualifiedTypeReference . tokens , <NUM_LIT:0> , index ) ) ; } else { binding = internalScope . getTypeOrPackage ( CharOperation . subarray ( qualifiedTypeReference . tokens , <NUM_LIT:0> , index ) ) ; } } catch ( AbortCompilation e ) { } if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . PackageBinding ) { return getPackageBinding ( ( org . eclipse . jdt . internal . compiler . lookup . PackageBinding ) binding ) ; } else if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) { return this . getTypeBinding ( ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) binding ) ; } else { return null ; } } } } else if ( node instanceof ImportReference ) { ImportReference importReference = ( ImportReference ) node ; int importReferenceLength = importReference . tokens . length ; if ( index >= <NUM_LIT:0> ) { Binding binding = null ; if ( this . scope == null ) return null ; if ( importReferenceLength == index ) { try { binding = this . scope . getImport ( CharOperation . subarray ( importReference . tokens , <NUM_LIT:0> , index ) , ( importReference . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . OnDemand ) != <NUM_LIT:0> , importReference . isStatic ( ) ) ; } catch ( AbortCompilation e ) { } } else { try { binding = this . scope . getImport ( CharOperation . subarray ( importReference . tokens , <NUM_LIT:0> , index ) , true , importReference . isStatic ( ) ) ; } catch ( AbortCompilation e ) { } } if ( binding != null ) { if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . PackageBinding ) { return getPackageBinding ( ( org . eclipse . jdt . internal . compiler . lookup . PackageBinding ) binding ) ; } else if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) { return this . getTypeBinding ( ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding ) binding ) ; } else if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . FieldBinding ) { return this . getVariableBinding ( ( org . eclipse . jdt . internal . compiler . lookup . FieldBinding ) binding ) ; } else if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . MethodBinding ) { return getMethodBinding ( ( org . eclipse . jdt . internal . compiler . lookup . MethodBinding ) binding ) ; } else { return null ; } } } } else if ( node instanceof CompilationUnitDeclaration ) { CompilationUnitDeclaration compilationUnitDeclaration = ( CompilationUnitDeclaration ) node ; org . eclipse . jdt . internal . compiler . ast . TypeDeclaration [ ] types = compilationUnitDeclaration . types ; if ( types == null || types . length == <NUM_LIT:0> ) { return null ; } org . eclipse . jdt . internal . compiler . ast . TypeDeclaration type = types [ <NUM_LIT:0> ] ; if ( type != null ) { ITypeBinding typeBinding = this . getTypeBinding ( type . binding ) ; if ( typeBinding != null ) { return typeBinding . getPackage ( ) ; } } } else if ( node instanceof AbstractMethodDeclaration ) { AbstractMethodDeclaration methodDeclaration = ( AbstractMethodDeclaration ) node ; IMethodBinding methodBinding = getMethodBinding ( methodDeclaration . binding ) ; if ( methodBinding != null ) { return methodBinding ; } } else if ( node instanceof org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) { org . eclipse . jdt . internal . compiler . ast . TypeDeclaration typeDeclaration = ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) node ; ITypeBinding typeBinding = this . getTypeBinding ( typeDeclaration . binding ) ; if ( typeBinding != null ) { return typeBinding ; } } if ( node instanceof SingleNameReference ) { SingleNameReference singleNameReference = ( SingleNameReference ) node ; if ( singleNameReference . isTypeReference ( ) ) { return this . getTypeBinding ( singleNameReference . resolvedType ) ; } else { Binding binding = singleNameReference . binding ; if ( binding != null ) { if ( binding . isValidBinding ( ) ) { return this . getVariableBinding ( ( org . eclipse . jdt . internal . compiler . lookup . VariableBinding ) binding ) ; } else { if ( binding instanceof ProblemFieldBinding ) { ProblemFieldBinding problemFieldBinding = ( ProblemFieldBinding ) binding ; switch ( problemFieldBinding . problemId ( ) ) { case ProblemReasons . NotVisible : case ProblemReasons . NonStaticReferenceInStaticContext : case ProblemReasons . NonStaticReferenceInConstructorInvocation : ReferenceBinding declaringClass = problemFieldBinding . declaringClass ; FieldBinding exactBinding = declaringClass . getField ( problemFieldBinding . name , true ) ; if ( exactBinding != null ) { if ( exactBinding . type != null ) { IVariableBinding variableBinding2 = ( IVariableBinding ) this . bindingTables . compilerBindingsToASTBindings . get ( exactBinding ) ; if ( variableBinding2 != null ) { return variableBinding2 ; } variableBinding2 = new VariableBinding ( this , exactBinding ) ; this . bindingTables . compilerBindingsToASTBindings . put ( exactBinding , variableBinding2 ) ; return variableBinding2 ; } } break ; } } } } } } else if ( node instanceof QualifiedSuperReference ) { QualifiedSuperReference qualifiedSuperReference = ( QualifiedSuperReference ) node ; return this . getTypeBinding ( qualifiedSuperReference . qualification . resolvedType ) ; } else if ( node instanceof LocalDeclaration ) { return this . getVariableBinding ( ( ( LocalDeclaration ) node ) . binding ) ; } else if ( node instanceof JavadocFieldReference ) { JavadocFieldReference fieldRef = ( JavadocFieldReference ) node ; if ( fieldRef . methodBinding != null ) { return getMethodBinding ( fieldRef . methodBinding ) ; } return getVariableBinding ( fieldRef . binding ) ; } else if ( node instanceof FieldReference ) { return getVariableBinding ( ( ( FieldReference ) node ) . binding ) ; } else if ( node instanceof SingleTypeReference ) { if ( node instanceof JavadocSingleTypeReference ) { JavadocSingleTypeReference typeRef = ( JavadocSingleTypeReference ) node ; if ( typeRef . packageBinding != null ) { return getPackageBinding ( typeRef . packageBinding ) ; } } SingleTypeReference singleTypeReference = ( SingleTypeReference ) node ; org . eclipse . jdt . internal . compiler . lookup . TypeBinding binding = singleTypeReference . resolvedType ; if ( binding == null ) { return null ; } return this . getTypeBinding ( binding . leafComponentType ( ) ) ; } else if ( node instanceof org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ) { org . eclipse . jdt . internal . compiler . ast . FieldDeclaration fieldDeclaration = ( org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ) node ; return this . getVariableBinding ( fieldDeclaration . binding ) ; } else if ( node instanceof MessageSend ) { MessageSend messageSend = ( MessageSend ) node ; return getMethodBinding ( messageSend . binding ) ; } else if ( node instanceof AllocationExpression ) { AllocationExpression allocation = ( AllocationExpression ) node ; return getMethodBinding ( allocation . binding ) ; } else if ( node instanceof JavadocImplicitTypeReference ) { JavadocImplicitTypeReference implicitRef = ( JavadocImplicitTypeReference ) node ; return getTypeBinding ( implicitRef . resolvedType ) ; } else if ( node instanceof org . eclipse . jdt . internal . compiler . ast . TypeParameter ) { org . eclipse . jdt . internal . compiler . ast . TypeParameter typeParameter = ( org . eclipse . jdt . internal . compiler . ast . TypeParameter ) node ; return this . getTypeBinding ( typeParameter . binding ) ; } else if ( node instanceof org . eclipse . jdt . internal . compiler . ast . MemberValuePair ) { org . eclipse . jdt . internal . compiler . ast . MemberValuePair memberValuePair = ( org . eclipse . jdt . internal . compiler . ast . MemberValuePair ) node ; return getMethodBinding ( memberValuePair . binding ) ; } return null ; } synchronized IPackageBinding resolvePackage ( PackageDeclaration pkg ) { if ( this . scope == null ) return null ; try { org . eclipse . jdt . internal . compiler . ast . ASTNode node = ( org . eclipse . jdt . internal . compiler . ast . ASTNode ) this . newAstToOldAst . get ( pkg ) ; if ( node instanceof ImportReference ) { ImportReference importReference = ( ImportReference ) node ; Binding binding = this . scope . getTypeOrPackage ( CharOperation . subarray ( importReference . tokens , <NUM_LIT:0> , importReference . tokens . length ) ) ; if ( ( binding != null ) && ( binding . isValidBinding ( ) ) ) { if ( binding instanceof ReferenceBinding ) { ReferenceBinding referenceBinding = ( ReferenceBinding ) binding ; binding = referenceBinding . fPackage ; } if ( binding instanceof org . eclipse . jdt . internal . compiler . lookup . PackageBinding ) { IPackageBinding packageBinding = getPackageBinding ( ( org . eclipse . jdt . internal . compiler . lookup . PackageBinding ) binding ) ; if ( packageBinding == null ) { return null ; } this . bindingsToAstNodes . put ( packageBinding , pkg ) ; String key = packageBinding . getKey ( ) ; if ( key != null ) { this . bindingTables . bindingKeysToBindings . put ( key , packageBinding ) ; } return packageBinding ; } } } } catch ( AbortCompilation e ) { } return null ; } synchronized IBinding resolveReference ( MemberRef ref ) { org . eclipse . jdt . internal . compiler . ast . Expression expression = ( org . eclipse . jdt . internal . compiler . ast . Expression ) this . newAstToOldAst . get ( ref ) ; if ( expression instanceof TypeReference ) { return getTypeBinding ( expression . resolvedType ) ; } else if ( expression instanceof JavadocFieldReference ) { JavadocFieldReference fieldRef = ( JavadocFieldReference ) expression ; if ( fieldRef . methodBinding != null ) { return getMethodBinding ( fieldRef . methodBinding ) ; } return getVariableBinding ( fieldRef . binding ) ; } return null ; } synchronized IMemberValuePairBinding resolveMemberValuePair ( org . eclipse . jdt . core . dom . MemberValuePair memberValuePair ) { MemberValuePair valuePair = ( MemberValuePair ) this . newAstToOldAst . get ( memberValuePair ) ; if ( valuePair != null ) { return getMemberValuePairBinding ( valuePair . compilerElementPair ) ; } return null ; } synchronized IBinding resolveReference ( MethodRef ref ) { org . eclipse . jdt . internal . compiler . ast . Expression expression = ( org . eclipse . jdt . internal . compiler . ast . Expression ) this . newAstToOldAst . get ( ref ) ; if ( expression instanceof JavadocMessageSend ) { return getMethodBinding ( ( ( JavadocMessageSend ) expression ) . binding ) ; } else if ( expression instanceof JavadocAllocationExpression ) { return getMethodBinding ( ( ( JavadocAllocationExpression ) expression ) . binding ) ; } return null ; } ITypeBinding resolveType ( AnnotationTypeDeclaration type ) { final Object node = this . newAstToOldAst . get ( type ) ; if ( node instanceof org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) { org . eclipse . jdt . internal . compiler . ast . TypeDeclaration typeDeclaration = ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) node ; ITypeBinding typeBinding = this . getTypeBinding ( typeDeclaration . binding ) ; if ( typeBinding == null ) { return null ; } this . bindingsToAstNodes . put ( typeBinding , type ) ; String key = typeBinding . getKey ( ) ; if ( key != null ) { this . bindingTables . bindingKeysToBindings . put ( key , typeBinding ) ; } return typeBinding ; } return null ; } synchronized ITypeBinding resolveType ( AnonymousClassDeclaration type ) { org . eclipse . jdt . internal . compiler . ast . ASTNode node = ( org . eclipse . jdt . internal . compiler . ast . ASTNode ) this . newAstToOldAst . get ( type ) ; if ( node != null && ( node . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . IsAnonymousType ) != <NUM_LIT:0> ) { org . eclipse . jdt . internal . compiler . ast . TypeDeclaration anonymousLocalTypeDeclaration = ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) node ; ITypeBinding typeBinding = this . getTypeBinding ( anonymousLocalTypeDeclaration . binding ) ; if ( typeBinding == null ) { return null ; } this . bindingsToAstNodes . put ( typeBinding , type ) ; String key = typeBinding . getKey ( ) ; if ( key != null ) { this . bindingTables . bindingKeysToBindings . put ( key , typeBinding ) ; } return typeBinding ; } return null ; } ITypeBinding resolveType ( EnumDeclaration type ) { final Object node = this . newAstToOldAst . get ( type ) ; if ( node instanceof org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) { org . eclipse . jdt . internal . compiler . ast . TypeDeclaration typeDeclaration = ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) node ; ITypeBinding typeBinding = this . getTypeBinding ( typeDeclaration . binding ) ; if ( typeBinding == null ) { return null ; } this . bindingsToAstNodes . put ( typeBinding , type ) ; String key = typeBinding . getKey ( ) ; if ( key != null ) { this . bindingTables . bindingKeysToBindings . put ( key , typeBinding ) ; } return typeBinding ; } return null ; } synchronized ITypeBinding resolveType ( Type type ) { org . eclipse . jdt . internal . compiler . ast . ASTNode node = ( org . eclipse . jdt . internal . compiler . ast . ASTNode ) this . newAstToOldAst . get ( type ) ; org . eclipse . jdt . internal . compiler . lookup . TypeBinding binding = null ; if ( node != null ) { if ( node instanceof ParameterizedQualifiedTypeReference ) { ParameterizedQualifiedTypeReference typeReference = ( ParameterizedQualifiedTypeReference ) node ; org . eclipse . jdt . internal . compiler . lookup . TypeBinding typeBinding = typeReference . resolvedType ; int index ; if ( type . isQualifiedType ( ) ) { index = ( ( QualifiedType ) type ) . index ; } else if ( type . isParameterizedType ( ) ) { index = ( ( ParameterizedType ) type ) . index ; } else { index = <NUM_LIT:1> ; } final int numberOfTypeArgumentsNotNull = getTypeArguments ( typeReference ) ; if ( index != numberOfTypeArgumentsNotNull ) { int i = numberOfTypeArgumentsNotNull ; while ( i != index ) { typeBinding = typeBinding . enclosingType ( ) ; i -- ; } binding = typeBinding ; } else { binding = typeBinding ; } } else if ( node instanceof TypeReference ) { TypeReference typeReference = ( TypeReference ) node ; binding = typeReference . resolvedType ; } else if ( node instanceof SingleNameReference && ( ( SingleNameReference ) node ) . isTypeReference ( ) ) { binding = ( ( ( SingleNameReference ) node ) . resolvedType ) ; } else if ( node instanceof QualifiedNameReference && ( ( QualifiedNameReference ) node ) . isTypeReference ( ) ) { binding = ( ( ( QualifiedNameReference ) node ) . resolvedType ) ; } else if ( node instanceof ArrayAllocationExpression ) { binding = ( ( ArrayAllocationExpression ) node ) . resolvedType ; } if ( binding != null ) { if ( type . isArrayType ( ) ) { ArrayType arrayType = ( ArrayType ) type ; if ( this . scope == null ) return null ; if ( binding . isArrayType ( ) ) { ArrayBinding arrayBinding = ( ArrayBinding ) binding ; return getTypeBinding ( this . scope . createArrayType ( arrayBinding . leafComponentType , arrayType . getDimensions ( ) ) ) ; } else { return getTypeBinding ( this . scope . createArrayType ( binding , arrayType . getDimensions ( ) ) ) ; } } else { if ( binding . isArrayType ( ) ) { ArrayBinding arrayBinding = ( ArrayBinding ) binding ; return getTypeBinding ( arrayBinding . leafComponentType ) ; } else { return getTypeBinding ( binding ) ; } } } } else if ( type . isPrimitiveType ( ) ) { if ( ( ( PrimitiveType ) type ) . getPrimitiveTypeCode ( ) == PrimitiveType . VOID ) { return this . getTypeBinding ( org . eclipse . jdt . internal . compiler . lookup . TypeBinding . VOID ) ; } } return null ; } synchronized ITypeBinding resolveType ( TypeDeclaration type ) { final Object node = this . newAstToOldAst . get ( type ) ; if ( node instanceof org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) { org . eclipse . jdt . internal . compiler . ast . TypeDeclaration typeDeclaration = ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) node ; ITypeBinding typeBinding = this . getTypeBinding ( typeDeclaration . binding ) ; if ( typeBinding == null ) { return null ; } this . bindingsToAstNodes . put ( typeBinding , type ) ; String key = typeBinding . getKey ( ) ; if ( key != null ) { this . bindingTables . bindingKeysToBindings . put ( key , typeBinding ) ; } return typeBinding ; } return null ; } synchronized ITypeBinding resolveTypeParameter ( TypeParameter typeParameter ) { final Object node = this . newAstToOldAst . get ( typeParameter ) ; if ( node instanceof org . eclipse . jdt . internal . compiler . ast . TypeParameter ) { org . eclipse . jdt . internal . compiler . ast . TypeParameter typeParameter2 = ( org . eclipse . jdt . internal . compiler . ast . TypeParameter ) node ; ITypeBinding typeBinding = this . getTypeBinding ( typeParameter2 . binding ) ; if ( typeBinding == null ) { return null ; } this . bindingsToAstNodes . put ( typeBinding , typeParameter ) ; String key = typeBinding . getKey ( ) ; if ( key != null ) { this . bindingTables . bindingKeysToBindings . put ( key , typeBinding ) ; } return typeBinding ; } return null ; } synchronized IVariableBinding resolveVariable ( EnumConstantDeclaration enumConstant ) { final Object node = this . newAstToOldAst . get ( enumConstant ) ; if ( node instanceof org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ) { org . eclipse . jdt . internal . compiler . ast . FieldDeclaration fieldDeclaration = ( org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ) node ; IVariableBinding variableBinding = this . getVariableBinding ( fieldDeclaration . binding ) ; if ( variableBinding == null ) { return null ; } this . bindingsToAstNodes . put ( variableBinding , enumConstant ) ; String key = variableBinding . getKey ( ) ; if ( key != null ) { this . bindingTables . bindingKeysToBindings . put ( key , variableBinding ) ; } return variableBinding ; } return null ; } synchronized IVariableBinding resolveVariable ( VariableDeclaration variable ) { final Object node = this . newAstToOldAst . get ( variable ) ; if ( node instanceof AbstractVariableDeclaration ) { AbstractVariableDeclaration abstractVariableDeclaration = ( AbstractVariableDeclaration ) node ; IVariableBinding variableBinding = null ; if ( abstractVariableDeclaration instanceof org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ) { org . eclipse . jdt . internal . compiler . ast . FieldDeclaration fieldDeclaration = ( org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ) abstractVariableDeclaration ; variableBinding = this . getVariableBinding ( fieldDeclaration . binding , variable ) ; } else { variableBinding = this . getVariableBinding ( ( ( LocalDeclaration ) abstractVariableDeclaration ) . binding , variable ) ; } if ( variableBinding == null ) { return null ; } this . bindingsToAstNodes . put ( variableBinding , variable ) ; String key = variableBinding . getKey ( ) ; if ( key != null ) { this . bindingTables . bindingKeysToBindings . put ( key , variableBinding ) ; } return variableBinding ; } return null ; } synchronized ITypeBinding resolveWellKnownType ( String name ) { if ( this . scope == null ) return null ; ITypeBinding typeBinding = null ; try { if ( ( "<STR_LIT:boolean>" . equals ( name ) ) || ( "<STR_LIT>" . equals ( name ) ) || ( "<STR_LIT>" . equals ( name ) ) || ( "<STR_LIT>" . equals ( name ) ) || ( "<STR_LIT:int>" . equals ( name ) ) || ( "<STR_LIT:long>" . equals ( name ) ) || ( "<STR_LIT:float>" . equals ( name ) ) || ( "<STR_LIT:double>" . equals ( name ) ) || ( "<STR_LIT>" . equals ( name ) ) ) { typeBinding = this . getTypeBinding ( Scope . getBaseType ( name . toCharArray ( ) ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getJavaLangObject ( ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getJavaLangString ( ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getType ( TypeConstants . JAVA_LANG_STRINGBUFFER , <NUM_LIT:3> ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getJavaLangThrowable ( ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getType ( TypeConstants . JAVA_LANG_EXCEPTION , <NUM_LIT:3> ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getType ( TypeConstants . JAVA_LANG_RUNTIMEEXCEPTION , <NUM_LIT:3> ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getType ( TypeConstants . JAVA_LANG_ERROR , <NUM_LIT:3> ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getJavaLangClass ( ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getJavaLangCloneable ( ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getJavaIoSerializable ( ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getType ( TypeConstants . JAVA_LANG_BOOLEAN , <NUM_LIT:3> ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getType ( TypeConstants . JAVA_LANG_BYTE , <NUM_LIT:3> ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getType ( TypeConstants . JAVA_LANG_CHARACTER , <NUM_LIT:3> ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getType ( TypeConstants . JAVA_LANG_DOUBLE , <NUM_LIT:3> ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getType ( TypeConstants . JAVA_LANG_FLOAT , <NUM_LIT:3> ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getType ( TypeConstants . JAVA_LANG_INTEGER , <NUM_LIT:3> ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getType ( TypeConstants . JAVA_LANG_LONG , <NUM_LIT:3> ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getType ( TypeConstants . JAVA_LANG_SHORT , <NUM_LIT:3> ) ) ; } else if ( "<STR_LIT>" . equals ( name ) ) { typeBinding = this . getTypeBinding ( this . scope . getType ( TypeConstants . JAVA_LANG_VOID , <NUM_LIT:3> ) ) ; } } catch ( AbortCompilation e ) { } if ( typeBinding != null && ! typeBinding . isRecovered ( ) ) { return typeBinding ; } return null ; } synchronized IAnnotationBinding resolveAnnotation ( final Annotation domASTNode ) { Object oldNode = this . newAstToOldAst . get ( domASTNode ) ; if ( oldNode instanceof org . eclipse . jdt . internal . compiler . ast . Annotation ) { org . eclipse . jdt . internal . compiler . ast . Annotation internalAstNode = ( org . eclipse . jdt . internal . compiler . ast . Annotation ) oldNode ; IAnnotationBinding domAnnotation = getAnnotationInstance ( internalAstNode . getCompilerAnnotation ( ) ) ; if ( domAnnotation == null ) return null ; this . bindingsToAstNodes . put ( domAnnotation , domASTNode ) ; return domAnnotation ; } return null ; } public CompilationUnitScope scope ( ) { return this . scope ; } synchronized void store ( ASTNode node , org . eclipse . jdt . internal . compiler . ast . ASTNode oldASTNode ) { this . newAstToOldAst . put ( node , oldASTNode ) ; } synchronized void updateKey ( ASTNode node , ASTNode newNode ) { Object astNode = this . newAstToOldAst . remove ( node ) ; if ( astNode != null ) { this . newAstToOldAst . put ( newNode , astNode ) ; } } ITypeBinding resolveArrayType ( ITypeBinding typeBinding , int dimensions ) { if ( typeBinding instanceof RecoveredTypeBinding ) throw new IllegalArgumentException ( "<STR_LIT>" ) ; ITypeBinding leafComponentType = typeBinding ; int actualDimensions = dimensions ; if ( typeBinding . isArray ( ) ) { leafComponentType = typeBinding . getElementType ( ) ; actualDimensions += typeBinding . getDimensions ( ) ; } org . eclipse . jdt . internal . compiler . lookup . TypeBinding leafTypeBinding = null ; if ( leafComponentType . isPrimitive ( ) ) { String name = leafComponentType . getBinaryName ( ) ; switch ( name . charAt ( <NUM_LIT:0> ) ) { case '<CHAR_LIT>' : leafTypeBinding = org . eclipse . jdt . internal . compiler . lookup . TypeBinding . INT ; break ; case '<CHAR_LIT>' : leafTypeBinding = org . eclipse . jdt . internal . compiler . lookup . TypeBinding . BYTE ; break ; case '<CHAR_LIT:Z>' : leafTypeBinding = org . eclipse . jdt . internal . compiler . lookup . TypeBinding . BOOLEAN ; break ; case '<CHAR_LIT>' : leafTypeBinding = org . eclipse . jdt . internal . compiler . lookup . TypeBinding . CHAR ; break ; case '<CHAR_LIT>' : leafTypeBinding = org . eclipse . jdt . internal . compiler . lookup . TypeBinding . LONG ; break ; case '<CHAR_LIT>' : leafTypeBinding = org . eclipse . jdt . internal . compiler . lookup . TypeBinding . SHORT ; break ; case '<CHAR_LIT>' : leafTypeBinding = org . eclipse . jdt . internal . compiler . lookup . TypeBinding . DOUBLE ; break ; case '<CHAR_LIT>' : leafTypeBinding = org . eclipse . jdt . internal . compiler . lookup . TypeBinding . FLOAT ; break ; case '<CHAR_LIT>' : throw new IllegalArgumentException ( ) ; } } else { if ( ! ( leafComponentType instanceof TypeBinding ) ) return null ; leafTypeBinding = ( ( TypeBinding ) leafComponentType ) . binding ; } return this . getTypeBinding ( lookupEnvironment ( ) . createArrayType ( leafTypeBinding , actualDimensions ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; public class InfixExpression extends Expression { public static class Operator { private String token ; private Operator ( String token ) { this . token = token ; } public String toString ( ) { return this . token ; } public static final Operator TIMES = new Operator ( "<STR_LIT:*>" ) ; public static final Operator DIVIDE = new Operator ( "<STR_LIT:/>" ) ; public static final Operator REMAINDER = new Operator ( "<STR_LIT:%>" ) ; public static final Operator PLUS = new Operator ( "<STR_LIT:+>" ) ; public static final Operator MINUS = new Operator ( "<STR_LIT:->" ) ; public static final Operator LEFT_SHIFT = new Operator ( "<STR_LIT>" ) ; public static final Operator RIGHT_SHIFT_SIGNED = new Operator ( "<STR_LIT>" ) ; public static final Operator RIGHT_SHIFT_UNSIGNED = new Operator ( "<STR_LIT>" ) ; public static final Operator LESS = new Operator ( "<STR_LIT:<>" ) ; public static final Operator GREATER = new Operator ( "<STR_LIT:>>" ) ; public static final Operator LESS_EQUALS = new Operator ( "<STR_LIT>" ) ; public static final Operator GREATER_EQUALS = new Operator ( "<STR_LIT>" ) ; public static final Operator EQUALS = new Operator ( "<STR_LIT>" ) ; public static final Operator NOT_EQUALS = new Operator ( "<STR_LIT>" ) ; public static final Operator XOR = new Operator ( "<STR_LIT>" ) ; public static final Operator OR = new Operator ( "<STR_LIT:|>" ) ; public static final Operator AND = new Operator ( "<STR_LIT:&>" ) ; public static final Operator CONDITIONAL_OR = new Operator ( "<STR_LIT>" ) ; public static final Operator CONDITIONAL_AND = new Operator ( "<STR_LIT>" ) ; private static final Map CODES ; static { CODES = new HashMap ( <NUM_LIT:20> ) ; Operator [ ] ops = { TIMES , DIVIDE , REMAINDER , PLUS , MINUS , LEFT_SHIFT , RIGHT_SHIFT_SIGNED , RIGHT_SHIFT_UNSIGNED , LESS , GREATER , LESS_EQUALS , GREATER_EQUALS , EQUALS , NOT_EQUALS , XOR , OR , AND , CONDITIONAL_OR , CONDITIONAL_AND , } ; for ( int i = <NUM_LIT:0> ; i < ops . length ; i ++ ) { CODES . put ( ops [ i ] . toString ( ) , ops [ i ] ) ; } } public static Operator toOperator ( String token ) { return ( Operator ) CODES . get ( token ) ; } } public static final ChildPropertyDescriptor LEFT_OPERAND_PROPERTY = new ChildPropertyDescriptor ( InfixExpression . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; public static final SimplePropertyDescriptor OPERATOR_PROPERTY = new SimplePropertyDescriptor ( InfixExpression . class , "<STR_LIT>" , InfixExpression . Operator . class , MANDATORY ) ; public static final ChildPropertyDescriptor RIGHT_OPERAND_PROPERTY = new ChildPropertyDescriptor ( InfixExpression . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; public static final ChildListPropertyDescriptor EXTENDED_OPERANDS_PROPERTY = new ChildListPropertyDescriptor ( InfixExpression . class , "<STR_LIT>" , Expression . class , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:5> ) ; createPropertyList ( InfixExpression . class , properyList ) ; addProperty ( LEFT_OPERAND_PROPERTY , properyList ) ; addProperty ( OPERATOR_PROPERTY , properyList ) ; addProperty ( RIGHT_OPERAND_PROPERTY , properyList ) ; addProperty ( EXTENDED_OPERANDS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private InfixExpression . Operator operator = InfixExpression . Operator . PLUS ; private Expression leftOperand = null ; private Expression rightOperand = null ; private ASTNode . NodeList extendedOperands = null ; InfixExpression ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final Object internalGetSetObjectProperty ( SimplePropertyDescriptor property , boolean get , Object value ) { if ( property == OPERATOR_PROPERTY ) { if ( get ) { return getOperator ( ) ; } else { setOperator ( ( Operator ) value ) ; return null ; } } return super . internalGetSetObjectProperty ( property , get , value ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == LEFT_OPERAND_PROPERTY ) { if ( get ) { return getLeftOperand ( ) ; } else { setLeftOperand ( ( Expression ) child ) ; return null ; } } if ( property == RIGHT_OPERAND_PROPERTY ) { if ( get ) { return getRightOperand ( ) ; } else { setRightOperand ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == EXTENDED_OPERANDS_PROPERTY ) { return extendedOperands ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return INFIX_EXPRESSION ; } ASTNode clone0 ( AST target ) { InfixExpression result = new InfixExpression ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setOperator ( getOperator ( ) ) ; result . setLeftOperand ( ( Expression ) getLeftOperand ( ) . clone ( target ) ) ; result . setRightOperand ( ( Expression ) getRightOperand ( ) . clone ( target ) ) ; if ( this . extendedOperands != null ) { result . extendedOperands ( ) . addAll ( ASTNode . copySubtrees ( target , extendedOperands ( ) ) ) ; } return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getLeftOperand ( ) ) ; acceptChild ( visitor , getRightOperand ( ) ) ; if ( this . extendedOperands != null ) { acceptChildren ( visitor , this . extendedOperands ) ; } } visitor . endVisit ( this ) ; } public InfixExpression . Operator getOperator ( ) { return this . operator ; } public void setOperator ( InfixExpression . Operator operator ) { if ( operator == null ) { throw new IllegalArgumentException ( ) ; } preValueChange ( OPERATOR_PROPERTY ) ; this . operator = operator ; postValueChange ( OPERATOR_PROPERTY ) ; } public Expression getLeftOperand ( ) { if ( this . leftOperand == null ) { synchronized ( this ) { if ( this . leftOperand == null ) { preLazyInit ( ) ; this . leftOperand = new SimpleName ( this . ast ) ; postLazyInit ( this . leftOperand , LEFT_OPERAND_PROPERTY ) ; } } } return this . leftOperand ; } public void setLeftOperand ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . leftOperand ; preReplaceChild ( oldChild , expression , LEFT_OPERAND_PROPERTY ) ; this . leftOperand = expression ; postReplaceChild ( oldChild , expression , LEFT_OPERAND_PROPERTY ) ; } public Expression getRightOperand ( ) { if ( this . rightOperand == null ) { synchronized ( this ) { if ( this . rightOperand == null ) { preLazyInit ( ) ; this . rightOperand = new SimpleName ( this . ast ) ; postLazyInit ( this . rightOperand , RIGHT_OPERAND_PROPERTY ) ; } } } return this . rightOperand ; } public void setRightOperand ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . rightOperand ; preReplaceChild ( oldChild , expression , RIGHT_OPERAND_PROPERTY ) ; this . rightOperand = expression ; postReplaceChild ( oldChild , expression , RIGHT_OPERAND_PROPERTY ) ; } public boolean hasExtendedOperands ( ) { return ( this . extendedOperands != null ) && this . extendedOperands . size ( ) > <NUM_LIT:0> ; } public List extendedOperands ( ) { if ( this . extendedOperands == null ) { this . extendedOperands = new ASTNode . NodeList ( EXTENDED_OPERANDS_PROPERTY ) ; } return this . extendedOperands ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:4> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . leftOperand == null ? <NUM_LIT:0> : getLeftOperand ( ) . treeSize ( ) ) + ( this . rightOperand == null ? <NUM_LIT:0> : getRightOperand ( ) . treeSize ( ) ) + ( this . extendedOperands == null ? <NUM_LIT:0> : this . extendedOperands . listSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . Iterator ; import java . util . List ; public class VariableDeclarationExpression extends Expression { public static final SimplePropertyDescriptor MODIFIERS_PROPERTY = new SimplePropertyDescriptor ( VariableDeclarationExpression . class , "<STR_LIT>" , int . class , MANDATORY ) ; public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY = new ChildListPropertyDescriptor ( VariableDeclarationExpression . class , "<STR_LIT>" , IExtendedModifier . class , CYCLE_RISK ) ; public static final ChildPropertyDescriptor TYPE_PROPERTY = new ChildPropertyDescriptor ( VariableDeclarationExpression . class , "<STR_LIT:type>" , Type . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor FRAGMENTS_PROPERTY = new ChildListPropertyDescriptor ( VariableDeclarationExpression . class , "<STR_LIT>" , VariableDeclarationFragment . class , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List propertyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( VariableDeclarationExpression . class , propertyList ) ; addProperty ( MODIFIERS_PROPERTY , propertyList ) ; addProperty ( TYPE_PROPERTY , propertyList ) ; addProperty ( FRAGMENTS_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( propertyList ) ; propertyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( VariableDeclarationExpression . class , propertyList ) ; addProperty ( MODIFIERS2_PROPERTY , propertyList ) ; addProperty ( TYPE_PROPERTY , propertyList ) ; addProperty ( FRAGMENTS_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private ASTNode . NodeList modifiers = null ; private int modifierFlags = Modifier . NONE ; private Type baseType = null ; private ASTNode . NodeList variableDeclarationFragments = new ASTNode . NodeList ( FRAGMENTS_PROPERTY ) ; VariableDeclarationExpression ( AST ast ) { super ( ast ) ; if ( ast . apiLevel >= AST . JLS3 ) { this . modifiers = new ASTNode . NodeList ( MODIFIERS2_PROPERTY ) ; } } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final int internalGetSetIntProperty ( SimplePropertyDescriptor property , boolean get , int value ) { if ( property == MODIFIERS_PROPERTY ) { if ( get ) { return getModifiers ( ) ; } else { setModifiers ( value ) ; return <NUM_LIT:0> ; } } return super . internalGetSetIntProperty ( property , get , value ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == TYPE_PROPERTY ) { if ( get ) { return getType ( ) ; } else { setType ( ( Type ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == MODIFIERS2_PROPERTY ) { return modifiers ( ) ; } if ( property == FRAGMENTS_PROPERTY ) { return fragments ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return VARIABLE_DECLARATION_EXPRESSION ; } ASTNode clone0 ( AST target ) { VariableDeclarationExpression result = new VariableDeclarationExpression ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { result . setModifiers ( getModifiers ( ) ) ; } if ( this . ast . apiLevel >= AST . JLS3 ) { result . modifiers ( ) . addAll ( ASTNode . copySubtrees ( target , modifiers ( ) ) ) ; } result . setType ( ( Type ) getType ( ) . clone ( target ) ) ; result . fragments ( ) . addAll ( ASTNode . copySubtrees ( target , fragments ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { if ( this . ast . apiLevel >= AST . JLS3 ) { acceptChildren ( visitor , this . modifiers ) ; } acceptChild ( visitor , getType ( ) ) ; acceptChildren ( visitor , this . variableDeclarationFragments ) ; } visitor . endVisit ( this ) ; } public List modifiers ( ) { if ( this . modifiers == null ) { unsupportedIn2 ( ) ; } return this . modifiers ; } public int getModifiers ( ) { if ( this . modifiers == null ) { return this . modifierFlags ; } else { int computedModifierFlags = Modifier . NONE ; for ( Iterator it = modifiers ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Object x = it . next ( ) ; if ( x instanceof Modifier ) { computedModifierFlags |= ( ( Modifier ) x ) . getKeyword ( ) . toFlagValue ( ) ; } } return computedModifierFlags ; } } public void setModifiers ( int modifiers ) { internalSetModifiers ( modifiers ) ; } final void internalSetModifiers ( int pmodifiers ) { supportedOnlyIn2 ( ) ; preValueChange ( MODIFIERS_PROPERTY ) ; this . modifierFlags = pmodifiers ; postValueChange ( MODIFIERS_PROPERTY ) ; } public Type getType ( ) { if ( this . baseType == null ) { synchronized ( this ) { if ( this . baseType == null ) { preLazyInit ( ) ; this . baseType = this . ast . newPrimitiveType ( PrimitiveType . INT ) ; postLazyInit ( this . baseType , TYPE_PROPERTY ) ; } } } return this . baseType ; } public void setType ( Type type ) { if ( type == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . baseType ; preReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; this . baseType = type ; postReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; } public List fragments ( ) { return this . variableDeclarationFragments ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:4> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . modifiers == null ? <NUM_LIT:0> : this . modifiers . listSize ( ) ) + ( this . baseType == null ? <NUM_LIT:0> : getType ( ) . treeSize ( ) ) + this . variableDeclarationFragments . listSize ( ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class ExpressionStatement extends Statement { public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( ExpressionStatement . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( ExpressionStatement . class , properyList ) ; addProperty ( EXPRESSION_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Expression expression = null ; ExpressionStatement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return EXPRESSION_STATEMENT ; } ASTNode clone0 ( AST target ) { ExpressionStatement result = new ExpressionStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; result . setExpression ( ( Expression ) getExpression ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getExpression ( ) ) ; } visitor . endVisit ( this ) ; } public Expression getExpression ( ) { if ( this . expression == null ) { synchronized ( this ) { if ( this . expression == null ) { preLazyInit ( ) ; this . expression = new MethodInvocation ( this . ast ) ; postLazyInit ( this . expression , EXPRESSION_PROPERTY ) ; } } } return this . expression ; } public void setExpression ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . expression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . expression = expression ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:1> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . expression == null ? <NUM_LIT:0> : getExpression ( ) . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . io . File ; import java . io . IOException ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . Iterator ; import java . util . List ; import java . util . Map ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . OperationCanceledException ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . WorkingCopyOwner ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . util . CompilerUtils ; import org . eclipse . jdt . internal . compiler . CompilationResult ; import org . eclipse . jdt . internal . compiler . Compiler ; import org . eclipse . jdt . internal . compiler . DefaultErrorHandlingPolicies ; import org . eclipse . jdt . internal . compiler . ICompilerRequestor ; import org . eclipse . jdt . internal . compiler . IErrorHandlingPolicy ; import org . eclipse . jdt . internal . compiler . IProblemFactory ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration ; import org . eclipse . jdt . internal . compiler . batch . FileSystem . Classpath ; import org . eclipse . jdt . internal . compiler . env . AccessRestriction ; import org . eclipse . jdt . internal . compiler . env . INameEnvironment ; import org . eclipse . jdt . internal . compiler . env . ISourceType ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . lookup . AnnotationBinding ; import org . eclipse . jdt . internal . compiler . lookup . Binding ; import org . eclipse . jdt . internal . compiler . lookup . ExtraCompilerModifiers ; import org . eclipse . jdt . internal . compiler . lookup . PackageBinding ; import org . eclipse . jdt . internal . compiler . parser . Parser ; import org . eclipse . jdt . internal . compiler . problem . AbortCompilation ; import org . eclipse . jdt . internal . compiler . problem . DefaultProblemFactory ; import org . eclipse . jdt . internal . compiler . problem . ProblemReporter ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObject ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObjectToInt ; import org . eclipse . jdt . internal . compiler . util . Messages ; import org . eclipse . jdt . internal . compiler . util . Util ; import org . eclipse . jdt . internal . core . BinaryMember ; import org . eclipse . jdt . internal . core . CancelableNameEnvironment ; import org . eclipse . jdt . internal . core . CancelableProblemFactory ; import org . eclipse . jdt . internal . core . INameEnviromentWithProgress ; import org . eclipse . jdt . internal . core . JavaProject ; import org . eclipse . jdt . internal . core . NameLookup ; import org . eclipse . jdt . internal . core . SourceRefElement ; import org . eclipse . jdt . internal . core . SourceTypeElementInfo ; import org . eclipse . jdt . internal . core . util . BindingKeyResolver ; import org . eclipse . jdt . internal . core . util . CommentRecorderParser ; import org . eclipse . jdt . internal . core . util . DOMFinder ; public class CompilationUnitResolver extends Compiler { public static final int RESOLVE_BINDING = <NUM_LIT> ; public static final int PARTIAL = <NUM_LIT> ; public static final int STATEMENT_RECOVERY = <NUM_LIT> ; public static final int IGNORE_METHOD_BODIES = <NUM_LIT> ; public static final int BINDING_RECOVERY = <NUM_LIT> ; public static final int INCLUDE_RUNNING_VM_BOOTCLASSPATH = <NUM_LIT> ; static class IntArrayList { public int [ ] list = new int [ <NUM_LIT:5> ] ; public int length = <NUM_LIT:0> ; public void add ( int i ) { if ( this . list . length == this . length ) { System . arraycopy ( this . list , <NUM_LIT:0> , this . list = new int [ this . length * <NUM_LIT:2> ] , <NUM_LIT:0> , this . length ) ; } this . list [ this . length ++ ] = i ; } } HashtableOfObject requestedSources ; HashtableOfObject requestedKeys ; DefaultBindingResolver . BindingTables bindingTables ; boolean hasCompilationAborted ; private IProgressMonitor monitor ; boolean fromJavaProject ; public CompilationUnitResolver ( INameEnvironment environment , IErrorHandlingPolicy policy , CompilerOptions compilerOptions , ICompilerRequestor requestor , IProblemFactory problemFactory , IProgressMonitor monitor , boolean fromJavaProject ) { super ( environment , policy , compilerOptions , requestor , problemFactory ) ; this . hasCompilationAborted = false ; this . monitor = monitor ; this . fromJavaProject = fromJavaProject ; } public void accept ( ISourceType [ ] sourceTypes , PackageBinding packageBinding , AccessRestriction accessRestriction ) { SourceTypeElementInfo sourceType = ( SourceTypeElementInfo ) sourceTypes [ <NUM_LIT:0> ] ; accept ( ( org . eclipse . jdt . internal . compiler . env . ICompilationUnit ) sourceType . getHandle ( ) . getCompilationUnit ( ) , accessRestriction ) ; } public synchronized void accept ( org . eclipse . jdt . internal . compiler . env . ICompilationUnit sourceUnit , AccessRestriction accessRestriction ) { super . accept ( sourceUnit , accessRestriction ) ; } protected void beginToCompile ( org . eclipse . jdt . internal . compiler . env . ICompilationUnit [ ] sourceUnits , String [ ] bindingKeys ) { int sourceLength = sourceUnits . length ; int keyLength = bindingKeys . length ; int maxUnits = sourceLength + keyLength ; this . totalUnits = <NUM_LIT:0> ; this . unitsToProcess = new CompilationUnitDeclaration [ maxUnits ] ; int index = <NUM_LIT:0> ; this . requestedSources = new HashtableOfObject ( ) ; for ( int i = <NUM_LIT:0> ; i < sourceLength ; i ++ ) { org . eclipse . jdt . internal . compiler . env . ICompilationUnit sourceUnit = sourceUnits [ i ] ; CompilationUnitDeclaration parsedUnit ; CompilationResult unitResult = new CompilationResult ( sourceUnit , index ++ , maxUnits , this . options . maxProblemsPerUnit ) ; try { if ( this . options . verbose ) { this . out . println ( Messages . bind ( Messages . compilation_request , new String [ ] { String . valueOf ( index ++ + <NUM_LIT:1> ) , String . valueOf ( maxUnits ) , new String ( sourceUnit . getFileName ( ) ) } ) ) ; } if ( this . totalUnits < this . parseThreshold ) { parsedUnit = this . parser . parse ( sourceUnit , unitResult ) ; } else { parsedUnit = this . parser . dietParse ( sourceUnit , unitResult ) ; } this . lookupEnvironment . buildTypeBindings ( parsedUnit , null ) ; addCompilationUnit ( sourceUnit , parsedUnit ) ; this . requestedSources . put ( unitResult . getFileName ( ) , sourceUnit ) ; worked ( <NUM_LIT:1> ) ; } finally { sourceUnits [ i ] = null ; } } this . requestedKeys = new HashtableOfObject ( ) ; for ( int i = <NUM_LIT:0> ; i < keyLength ; i ++ ) { BindingKeyResolver resolver = new BindingKeyResolver ( bindingKeys [ i ] , this , this . lookupEnvironment ) ; resolver . parse ( true ) ; CompilationUnitDeclaration parsedUnit = resolver . hasTypeName ( ) ? resolver . getCompilationUnitDeclaration ( ) : null ; if ( parsedUnit != null ) { char [ ] fileName = parsedUnit . compilationResult . getFileName ( ) ; Object existing = this . requestedKeys . get ( fileName ) ; if ( existing == null ) this . requestedKeys . put ( fileName , resolver ) ; else if ( existing instanceof ArrayList ) ( ( ArrayList ) existing ) . add ( resolver ) ; else { ArrayList list = new ArrayList ( ) ; list . add ( existing ) ; list . add ( resolver ) ; this . requestedKeys . put ( fileName , list ) ; } } else { char [ ] key = resolver . hasTypeName ( ) ? resolver . getKey ( ) . toCharArray ( ) : CharOperation . concatWith ( resolver . compoundName ( ) , '<CHAR_LIT:.>' ) ; this . requestedKeys . put ( key , resolver ) ; } worked ( <NUM_LIT:1> ) ; } this . lookupEnvironment . completeTypeBindings ( ) ; } IBinding createBinding ( String key ) { if ( this . bindingTables == null ) throw new RuntimeException ( "<STR_LIT>" ) ; BindingKeyResolver keyResolver = new BindingKeyResolver ( key , this , this . lookupEnvironment ) ; Binding compilerBinding = keyResolver . getCompilerBinding ( ) ; if ( compilerBinding == null ) return null ; DefaultBindingResolver resolver = new DefaultBindingResolver ( this . lookupEnvironment , null , this . bindingTables , false , this . fromJavaProject ) ; return resolver . getBinding ( compilerBinding ) ; } public static CompilationUnit convert ( CompilationUnitDeclaration compilationUnitDeclaration , char [ ] source , int apiLevel , Map options , boolean needToResolveBindings , WorkingCopyOwner owner , DefaultBindingResolver . BindingTables bindingTables , int flags , IProgressMonitor monitor , boolean fromJavaProject ) { BindingResolver resolver = null ; AST ast = AST . newAST ( apiLevel ) ; ast . setDefaultNodeFlag ( ASTNode . ORIGINAL ) ; CompilationUnit compilationUnit = null ; ASTConverter converter = new ASTConverter ( options , needToResolveBindings , monitor ) ; if ( needToResolveBindings ) { resolver = new DefaultBindingResolver ( compilationUnitDeclaration . scope , owner , bindingTables , ( flags & ICompilationUnit . ENABLE_BINDINGS_RECOVERY ) != <NUM_LIT:0> , fromJavaProject ) ; ast . setFlag ( flags | AST . RESOLVED_BINDINGS ) ; } else { resolver = new BindingResolver ( ) ; ast . setFlag ( flags ) ; } ast . setBindingResolver ( resolver ) ; converter . setAST ( ast ) ; compilationUnit = converter . convert ( compilationUnitDeclaration , source ) ; compilationUnit . setLineEndTable ( compilationUnitDeclaration . compilationResult . getLineSeparatorPositions ( ) ) ; ast . setDefaultNodeFlag ( <NUM_LIT:0> ) ; ast . setOriginalModificationCount ( ast . modificationCount ( ) ) ; return compilationUnit ; } protected static CompilerOptions getCompilerOptions ( Map options , boolean statementsRecovery ) { CompilerOptions compilerOptions = new CompilerOptions ( options ) ; compilerOptions . performMethodsFullRecovery = statementsRecovery ; compilerOptions . performStatementsRecovery = statementsRecovery ; compilerOptions . parseLiteralExpressionsAsConstants = false ; compilerOptions . storeAnnotations = true ; return compilerOptions ; } protected static IErrorHandlingPolicy getHandlingPolicy ( ) { return new IErrorHandlingPolicy ( ) { public boolean stopOnFirstError ( ) { return false ; } public boolean proceedOnErrors ( ) { return false ; } } ; } protected static ICompilerRequestor getRequestor ( ) { return new ICompilerRequestor ( ) { public void acceptResult ( CompilationResult compilationResult ) { } } ; } public void initializeParser ( ) { this . parser = LanguageSupportFactory . getParser ( this , this . lookupEnvironment == null ? null : this . lookupEnvironment . globalOptions , this . problemReporter , false , LanguageSupportFactory . CommentRecorderParserVariant ) ; } public void process ( CompilationUnitDeclaration unit , int i ) { char [ ] fileName = unit . compilationResult . getFileName ( ) ; if ( this . requestedKeys . get ( fileName ) == null && this . requestedSources . get ( fileName ) == null ) super . process ( unit , i ) ; } protected void handleInternalException ( Throwable internalException , CompilationUnitDeclaration unit , CompilationResult result ) { super . handleInternalException ( internalException , unit , result ) ; if ( unit != null ) { removeUnresolvedBindings ( unit ) ; } } protected void handleInternalException ( AbortCompilation abortException , CompilationUnitDeclaration unit ) { super . handleInternalException ( abortException , unit ) ; if ( unit != null ) { removeUnresolvedBindings ( unit ) ; } this . hasCompilationAborted = true ; } public static void parse ( ICompilationUnit [ ] compilationUnits , ASTRequestor astRequestor , int apiLevel , Map options , int flags , IProgressMonitor monitor ) { try { CompilerOptions compilerOptions = new CompilerOptions ( options ) ; compilerOptions . ignoreMethodBodies = ( flags & ICompilationUnit . IGNORE_METHOD_BODIES ) != <NUM_LIT:0> ; Parser parser = new CommentRecorderParser ( new ProblemReporter ( DefaultErrorHandlingPolicies . proceedWithAllProblems ( ) , compilerOptions , new DefaultProblemFactory ( ) ) , false ) ; int unitLength = compilationUnits . length ; if ( monitor != null ) monitor . beginTask ( "<STR_LIT>" , unitLength ) ; for ( int i = <NUM_LIT:0> ; i < unitLength ; i ++ ) { org . eclipse . jdt . internal . compiler . env . ICompilationUnit sourceUnit = ( org . eclipse . jdt . internal . compiler . env . ICompilationUnit ) compilationUnits [ i ] ; CompilationResult compilationResult = new CompilationResult ( sourceUnit , <NUM_LIT:0> , <NUM_LIT:0> , compilerOptions . maxProblemsPerUnit ) ; CompilationUnitDeclaration compilationUnitDeclaration = parser . dietParse ( sourceUnit , compilationResult ) ; if ( compilationUnitDeclaration . ignoreMethodBodies ) { compilationUnitDeclaration . ignoreFurtherInvestigation = true ; continue ; } org . eclipse . jdt . internal . compiler . ast . TypeDeclaration [ ] types = compilationUnitDeclaration . types ; if ( types != null ) { for ( int j = <NUM_LIT:0> , typeLength = types . length ; j < typeLength ; j ++ ) { types [ j ] . parseMethods ( parser , compilationUnitDeclaration ) ; } } CompilationUnit node = convert ( compilationUnitDeclaration , parser . scanner . getSource ( ) , apiLevel , options , false , null , null , flags , monitor , true ) ; node . setTypeRoot ( compilationUnits [ i ] ) ; astRequestor . acceptAST ( compilationUnits [ i ] , node ) ; if ( monitor != null ) monitor . worked ( <NUM_LIT:1> ) ; } } finally { if ( monitor != null ) monitor . done ( ) ; } } public static void parse ( String [ ] sourceUnits , String [ ] encodings , FileASTRequestor astRequestor , int apiLevel , Map options , int flags , IProgressMonitor monitor ) { try { CompilerOptions compilerOptions = new CompilerOptions ( options ) ; compilerOptions . ignoreMethodBodies = ( flags & ICompilationUnit . IGNORE_METHOD_BODIES ) != <NUM_LIT:0> ; Parser parser = new CommentRecorderParser ( new ProblemReporter ( DefaultErrorHandlingPolicies . proceedWithAllProblems ( ) , compilerOptions , new DefaultProblemFactory ( ) ) , false ) ; int unitLength = sourceUnits . length ; if ( monitor != null ) monitor . beginTask ( "<STR_LIT>" , unitLength ) ; for ( int i = <NUM_LIT:0> ; i < unitLength ; i ++ ) { char [ ] contents = null ; String encoding = encodings != null ? encodings [ i ] : null ; try { contents = Util . getFileCharContent ( new File ( sourceUnits [ i ] ) , encoding ) ; } catch ( IOException e ) { continue ; } if ( contents == null ) { continue ; } org . eclipse . jdt . internal . compiler . batch . CompilationUnit compilationUnit = new org . eclipse . jdt . internal . compiler . batch . CompilationUnit ( contents , sourceUnits [ i ] , encoding ) ; org . eclipse . jdt . internal . compiler . env . ICompilationUnit sourceUnit = compilationUnit ; CompilationResult compilationResult = new CompilationResult ( sourceUnit , <NUM_LIT:0> , <NUM_LIT:0> , compilerOptions . maxProblemsPerUnit ) ; CompilationUnitDeclaration compilationUnitDeclaration = parser . dietParse ( sourceUnit , compilationResult ) ; if ( compilationUnitDeclaration . ignoreMethodBodies ) { compilationUnitDeclaration . ignoreFurtherInvestigation = true ; continue ; } org . eclipse . jdt . internal . compiler . ast . TypeDeclaration [ ] types = compilationUnitDeclaration . types ; if ( types != null ) { for ( int j = <NUM_LIT:0> , typeLength = types . length ; j < typeLength ; j ++ ) { types [ j ] . parseMethods ( parser , compilationUnitDeclaration ) ; } } CompilationUnit node = convert ( compilationUnitDeclaration , parser . scanner . getSource ( ) , apiLevel , options , false , null , null , flags , monitor , true ) ; node . setTypeRoot ( null ) ; astRequestor . acceptAST ( sourceUnits [ i ] , node ) ; if ( monitor != null ) monitor . worked ( <NUM_LIT:1> ) ; } } finally { if ( monitor != null ) monitor . done ( ) ; } } public static CompilationUnitDeclaration parse ( org . eclipse . jdt . internal . compiler . env . ICompilationUnit sourceUnit , NodeSearcher nodeSearcher , Map settings , int flags ) { if ( sourceUnit == null ) { throw new IllegalStateException ( ) ; } CompilerOptions compilerOptions = new CompilerOptions ( settings ) ; boolean statementsRecovery = ( flags & ICompilationUnit . ENABLE_STATEMENTS_RECOVERY ) != <NUM_LIT:0> ; compilerOptions . performMethodsFullRecovery = statementsRecovery ; compilerOptions . performStatementsRecovery = statementsRecovery ; compilerOptions . ignoreMethodBodies = ( flags & ICompilationUnit . IGNORE_METHOD_BODIES ) != <NUM_LIT:0> ; Parser parser = LanguageSupportFactory . getParser ( null , compilerOptions , new ProblemReporter ( DefaultErrorHandlingPolicies . proceedWithAllProblems ( ) , compilerOptions , new DefaultProblemFactory ( ) ) , false , <NUM_LIT:2> ) ; CompilationResult compilationResult = new CompilationResult ( sourceUnit , <NUM_LIT:0> , <NUM_LIT:0> , compilerOptions . maxProblemsPerUnit ) ; CompilationUnitDeclaration compilationUnitDeclaration = parser . dietParse ( sourceUnit , compilationResult ) ; if ( compilationUnitDeclaration . ignoreMethodBodies ) { compilationUnitDeclaration . ignoreFurtherInvestigation = true ; return compilationUnitDeclaration ; } if ( nodeSearcher != null ) { char [ ] source = parser . scanner . getSource ( ) ; int searchPosition = nodeSearcher . position ; if ( searchPosition < <NUM_LIT:0> || searchPosition > source . length ) { return compilationUnitDeclaration ; } compilationUnitDeclaration . traverse ( nodeSearcher , compilationUnitDeclaration . scope ) ; org . eclipse . jdt . internal . compiler . ast . ASTNode node = nodeSearcher . found ; if ( node == null ) { return compilationUnitDeclaration ; } org . eclipse . jdt . internal . compiler . ast . TypeDeclaration enclosingTypeDeclaration = nodeSearcher . enclosingType ; if ( node instanceof AbstractMethodDeclaration ) { ( ( AbstractMethodDeclaration ) node ) . parseStatements ( parser , compilationUnitDeclaration ) ; } else if ( enclosingTypeDeclaration != null ) { if ( node instanceof org . eclipse . jdt . internal . compiler . ast . Initializer ) { ( ( org . eclipse . jdt . internal . compiler . ast . Initializer ) node ) . parseStatements ( parser , enclosingTypeDeclaration , compilationUnitDeclaration ) ; } else if ( node instanceof org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) { ( ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) node ) . parseMethods ( parser , compilationUnitDeclaration ) ; } } } else { org . eclipse . jdt . internal . compiler . ast . TypeDeclaration [ ] types = compilationUnitDeclaration . types ; if ( types != null ) { for ( int j = <NUM_LIT:0> , typeLength = types . length ; j < typeLength ; j ++ ) { types [ j ] . parseMethods ( parser , compilationUnitDeclaration ) ; } } } return compilationUnitDeclaration ; } public static void resolve ( ICompilationUnit [ ] compilationUnits , String [ ] bindingKeys , ASTRequestor requestor , int apiLevel , Map options , IJavaProject javaProject , WorkingCopyOwner owner , int flags , IProgressMonitor monitor ) { CancelableNameEnvironment environment = null ; CancelableProblemFactory problemFactory = null ; try { if ( monitor != null ) { int amountOfWork = ( compilationUnits . length + bindingKeys . length ) * <NUM_LIT:2> ; monitor . beginTask ( "<STR_LIT>" , amountOfWork ) ; } environment = new CancelableNameEnvironment ( ( ( JavaProject ) javaProject ) , owner , monitor ) ; problemFactory = new CancelableProblemFactory ( monitor ) ; CompilerOptions compilerOptions = getCompilerOptions ( options , ( flags & ICompilationUnit . ENABLE_STATEMENTS_RECOVERY ) != <NUM_LIT:0> ) ; compilerOptions . ignoreMethodBodies = ( flags & ICompilationUnit . IGNORE_METHOD_BODIES ) != <NUM_LIT:0> ; CompilerUtils . configureOptionsBasedOnNature ( compilerOptions , javaProject ) ; CompilationUnitResolver resolver = new CompilationUnitResolver ( environment , getHandlingPolicy ( ) , compilerOptions , getRequestor ( ) , problemFactory , monitor , javaProject != null ) ; resolver . resolve ( compilationUnits , bindingKeys , requestor , apiLevel , options , owner , flags ) ; if ( NameLookup . VERBOSE ) { System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + environment . nameLookup . timeSpentInSeekTypesInSourcePackage + "<STR_LIT>" ) ; System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + environment . nameLookup . timeSpentInSeekTypesInBinaryPackage + "<STR_LIT>" ) ; } } catch ( JavaModelException e ) { parse ( compilationUnits , requestor , apiLevel , options , flags , monitor ) ; } finally { if ( monitor != null ) monitor . done ( ) ; if ( environment != null ) { environment . setMonitor ( null ) ; } if ( problemFactory != null ) { problemFactory . monitor = null ; } } } public static void resolve ( String [ ] sourceUnits , String [ ] encodings , String [ ] bindingKeys , FileASTRequestor requestor , int apiLevel , Map options , List classpaths , int flags , IProgressMonitor monitor ) { INameEnviromentWithProgress environment = null ; CancelableProblemFactory problemFactory = null ; try { if ( monitor != null ) { int amountOfWork = ( sourceUnits . length + bindingKeys . length ) * <NUM_LIT:2> ; monitor . beginTask ( "<STR_LIT>" , amountOfWork ) ; } Classpath [ ] allEntries = new Classpath [ classpaths . size ( ) ] ; classpaths . toArray ( allEntries ) ; environment = new NameEnviromentWithProgress ( allEntries , null , monitor ) ; problemFactory = new CancelableProblemFactory ( monitor ) ; CompilerOptions compilerOptions = getCompilerOptions ( options , ( flags & ICompilationUnit . ENABLE_STATEMENTS_RECOVERY ) != <NUM_LIT:0> ) ; compilerOptions . ignoreMethodBodies = ( flags & ICompilationUnit . IGNORE_METHOD_BODIES ) != <NUM_LIT:0> ; CompilationUnitResolver resolver = new CompilationUnitResolver ( environment , getHandlingPolicy ( ) , compilerOptions , getRequestor ( ) , problemFactory , monitor , false ) ; resolver . resolve ( sourceUnits , encodings , bindingKeys , requestor , apiLevel , options , flags ) ; if ( NameLookup . VERBOSE && ( environment instanceof CancelableNameEnvironment ) ) { CancelableNameEnvironment cancelableNameEnvironment = ( CancelableNameEnvironment ) environment ; System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + cancelableNameEnvironment . nameLookup . timeSpentInSeekTypesInSourcePackage + "<STR_LIT>" ) ; System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + cancelableNameEnvironment . nameLookup . timeSpentInSeekTypesInBinaryPackage + "<STR_LIT>" ) ; } } finally { if ( monitor != null ) monitor . done ( ) ; if ( environment != null ) { environment . setMonitor ( null ) ; } if ( problemFactory != null ) { problemFactory . monitor = null ; } } } public static CompilationUnitDeclaration resolve ( org . eclipse . jdt . internal . compiler . env . ICompilationUnit sourceUnit , IJavaProject javaProject , List classpaths , NodeSearcher nodeSearcher , Map options , WorkingCopyOwner owner , int flags , IProgressMonitor monitor ) throws JavaModelException { CompilationUnitDeclaration unit = null ; INameEnviromentWithProgress environment = null ; CancelableProblemFactory problemFactory = null ; CompilationUnitResolver resolver = null ; try { if ( javaProject == null ) { Classpath [ ] allEntries = new Classpath [ classpaths . size ( ) ] ; classpaths . toArray ( allEntries ) ; environment = new NameEnviromentWithProgress ( allEntries , null , monitor ) ; } else { environment = new CancelableNameEnvironment ( ( JavaProject ) javaProject , owner , monitor ) ; } problemFactory = new CancelableProblemFactory ( monitor ) ; CompilerOptions compilerOptions = getCompilerOptions ( options , ( flags & ICompilationUnit . ENABLE_STATEMENTS_RECOVERY ) != <NUM_LIT:0> ) ; boolean ignoreMethodBodies = ( flags & ICompilationUnit . IGNORE_METHOD_BODIES ) != <NUM_LIT:0> ; compilerOptions . ignoreMethodBodies = ignoreMethodBodies ; CompilerUtils . configureOptionsBasedOnNature ( compilerOptions , javaProject ) ; resolver = new CompilationUnitResolver ( environment , getHandlingPolicy ( ) , compilerOptions , getRequestor ( ) , problemFactory , monitor , javaProject != null ) ; boolean analyzeAndGenerateCode = ! ignoreMethodBodies ; unit = resolver . resolve ( null , sourceUnit , nodeSearcher , true , analyzeAndGenerateCode , analyzeAndGenerateCode ) ; if ( resolver . hasCompilationAborted ) { CompilationUnitDeclaration unitDeclaration = parse ( sourceUnit , nodeSearcher , options , flags ) ; final int problemCount = unit . compilationResult . problemCount ; if ( problemCount != <NUM_LIT:0> ) { unitDeclaration . compilationResult . problems = new CategorizedProblem [ problemCount ] ; System . arraycopy ( unit . compilationResult . problems , <NUM_LIT:0> , unitDeclaration . compilationResult . problems , <NUM_LIT:0> , problemCount ) ; unitDeclaration . compilationResult . problemCount = problemCount ; } return unitDeclaration ; } if ( NameLookup . VERBOSE && environment instanceof CancelableNameEnvironment ) { CancelableNameEnvironment cancelableNameEnvironment = ( CancelableNameEnvironment ) environment ; System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + cancelableNameEnvironment . nameLookup . timeSpentInSeekTypesInSourcePackage + "<STR_LIT>" ) ; System . out . println ( Thread . currentThread ( ) + "<STR_LIT>" + cancelableNameEnvironment . nameLookup . timeSpentInSeekTypesInBinaryPackage + "<STR_LIT>" ) ; } return unit ; } finally { if ( environment != null ) { environment . setMonitor ( null ) ; } if ( problemFactory != null ) { problemFactory . monitor = null ; } } } public static IBinding [ ] resolve ( final IJavaElement [ ] elements , int apiLevel , Map compilerOptions , IJavaProject javaProject , WorkingCopyOwner owner , int flags , IProgressMonitor monitor ) { final int length = elements . length ; final HashMap sourceElementPositions = new HashMap ( ) ; int cuNumber = <NUM_LIT:0> ; final HashtableOfObjectToInt binaryElementPositions = new HashtableOfObjectToInt ( ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IJavaElement element = elements [ i ] ; if ( ! ( element instanceof SourceRefElement ) ) throw new IllegalStateException ( element + "<STR_LIT>" ) ; Object cu = element . getAncestor ( IJavaElement . COMPILATION_UNIT ) ; if ( cu != null ) { IntArrayList intList = ( IntArrayList ) sourceElementPositions . get ( cu ) ; if ( intList == null ) { sourceElementPositions . put ( cu , intList = new IntArrayList ( ) ) ; cuNumber ++ ; } intList . add ( i ) ; } else { try { String key = ( ( BinaryMember ) element ) . getKey ( true ) ; binaryElementPositions . put ( key , i ) ; } catch ( JavaModelException e ) { throw new IllegalArgumentException ( element + "<STR_LIT>" ) ; } } } ICompilationUnit [ ] cus = new ICompilationUnit [ cuNumber ] ; sourceElementPositions . keySet ( ) . toArray ( cus ) ; int bindingKeyNumber = binaryElementPositions . size ( ) ; String [ ] bindingKeys = new String [ bindingKeyNumber ] ; binaryElementPositions . keysToArray ( bindingKeys ) ; class Requestor extends ASTRequestor { IBinding [ ] bindings = new IBinding [ length ] ; public void acceptAST ( ICompilationUnit source , CompilationUnit ast ) { IntArrayList intList = ( IntArrayList ) sourceElementPositions . get ( source ) ; for ( int i = <NUM_LIT:0> ; i < intList . length ; i ++ ) { final int index = intList . list [ i ] ; SourceRefElement element = ( SourceRefElement ) elements [ index ] ; DOMFinder finder = new DOMFinder ( ast , element , true ) ; try { finder . search ( ) ; } catch ( JavaModelException e ) { throw new IllegalArgumentException ( element + "<STR_LIT>" ) ; } this . bindings [ index ] = finder . foundBinding ; } } public void acceptBinding ( String bindingKey , IBinding binding ) { int index = binaryElementPositions . get ( bindingKey ) ; this . bindings [ index ] = binding ; } } Requestor requestor = new Requestor ( ) ; resolve ( cus , bindingKeys , requestor , apiLevel , compilerOptions , javaProject , owner , flags , monitor ) ; return requestor . bindings ; } public void removeUnresolvedBindings ( CompilationUnitDeclaration compilationUnitDeclaration ) { final org . eclipse . jdt . internal . compiler . ast . TypeDeclaration [ ] types = compilationUnitDeclaration . types ; if ( types != null ) { for ( int i = <NUM_LIT:0> , max = types . length ; i < max ; i ++ ) { removeUnresolvedBindings ( types [ i ] ) ; } } } private void removeUnresolvedBindings ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration type ) { final org . eclipse . jdt . internal . compiler . ast . TypeDeclaration [ ] memberTypes = type . memberTypes ; if ( memberTypes != null ) { for ( int i = <NUM_LIT:0> , max = memberTypes . length ; i < max ; i ++ ) { removeUnresolvedBindings ( memberTypes [ i ] ) ; } } if ( type . binding != null && ( type . binding . modifiers & ExtraCompilerModifiers . AccUnresolved ) != <NUM_LIT:0> ) { type . binding = null ; } final org . eclipse . jdt . internal . compiler . ast . FieldDeclaration [ ] fields = type . fields ; if ( fields != null ) { for ( int i = <NUM_LIT:0> , max = fields . length ; i < max ; i ++ ) { if ( fields [ i ] . binding != null && ( fields [ i ] . binding . modifiers & ExtraCompilerModifiers . AccUnresolved ) != <NUM_LIT:0> ) { fields [ i ] . binding = null ; } } } final AbstractMethodDeclaration [ ] methods = type . methods ; if ( methods != null ) { for ( int i = <NUM_LIT:0> , max = methods . length ; i < max ; i ++ ) { if ( methods [ i ] . binding != null && ( methods [ i ] . binding . modifiers & ExtraCompilerModifiers . AccUnresolved ) != <NUM_LIT:0> ) { methods [ i ] . binding = null ; } } } } private void resolve ( ICompilationUnit [ ] compilationUnits , String [ ] bindingKeys , ASTRequestor astRequestor , int apiLevel , Map compilerOptions , WorkingCopyOwner owner , int flags ) { astRequestor . compilationUnitResolver = this ; this . bindingTables = new DefaultBindingResolver . BindingTables ( ) ; CompilationUnitDeclaration unit = null ; try { int length = compilationUnits . length ; org . eclipse . jdt . internal . compiler . env . ICompilationUnit [ ] sourceUnits = new org . eclipse . jdt . internal . compiler . env . ICompilationUnit [ length ] ; System . arraycopy ( compilationUnits , <NUM_LIT:0> , sourceUnits , <NUM_LIT:0> , length ) ; beginToCompile ( sourceUnits , bindingKeys ) ; for ( int i = <NUM_LIT:0> ; i < this . totalUnits ; i ++ ) { if ( resolvedRequestedSourcesAndKeys ( i ) ) { for ( ; i < this . totalUnits ; i ++ ) { this . unitsToProcess [ i ] . cleanUp ( ) ; this . unitsToProcess [ i ] = null ; } break ; } unit = this . unitsToProcess [ i ] ; try { super . process ( unit , i ) ; char [ ] fileName = unit . compilationResult . getFileName ( ) ; ICompilationUnit source = ( ICompilationUnit ) this . requestedSources . get ( fileName ) ; if ( source != null ) { CompilationResult compilationResult = unit . compilationResult ; org . eclipse . jdt . internal . compiler . env . ICompilationUnit sourceUnit = compilationResult . compilationUnit ; char [ ] contents = sourceUnit . getContents ( ) ; AST ast = AST . newAST ( apiLevel ) ; ast . setFlag ( flags | AST . RESOLVED_BINDINGS ) ; ast . setDefaultNodeFlag ( ASTNode . ORIGINAL ) ; ASTConverter converter = new ASTConverter ( compilerOptions , true , this . monitor ) ; BindingResolver resolver = new DefaultBindingResolver ( unit . scope , owner , this . bindingTables , ( flags & ICompilationUnit . ENABLE_BINDINGS_RECOVERY ) != <NUM_LIT:0> , this . fromJavaProject ) ; ast . setBindingResolver ( resolver ) ; converter . setAST ( ast ) ; CompilationUnit compilationUnit = converter . convert ( unit , contents ) ; compilationUnit . setTypeRoot ( source ) ; compilationUnit . setLineEndTable ( compilationResult . getLineSeparatorPositions ( ) ) ; ast . setDefaultNodeFlag ( <NUM_LIT:0> ) ; ast . setOriginalModificationCount ( ast . modificationCount ( ) ) ; astRequestor . acceptAST ( source , compilationUnit ) ; worked ( <NUM_LIT:1> ) ; this . requestedSources . put ( fileName , null ) ; } Object key = this . requestedKeys . get ( fileName ) ; if ( key != null ) { if ( key instanceof BindingKeyResolver ) { reportBinding ( key , astRequestor , owner , unit ) ; worked ( <NUM_LIT:1> ) ; } else if ( key instanceof ArrayList ) { Iterator iterator = ( ( ArrayList ) key ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { reportBinding ( iterator . next ( ) , astRequestor , owner , unit ) ; worked ( <NUM_LIT:1> ) ; } } this . requestedKeys . put ( fileName , null ) ; } } finally { unit . cleanUp ( ) ; } this . unitsToProcess [ i ] = null ; this . requestor . acceptResult ( unit . compilationResult . tagAsAccepted ( ) ) ; } DefaultBindingResolver resolver = new DefaultBindingResolver ( this . lookupEnvironment , owner , this . bindingTables , ( flags & ICompilationUnit . ENABLE_BINDINGS_RECOVERY ) != <NUM_LIT:0> , true ) ; Object [ ] keys = this . requestedKeys . valueTable ; for ( int j = <NUM_LIT:0> , keysLength = keys . length ; j < keysLength ; j ++ ) { BindingKeyResolver keyResolver = ( BindingKeyResolver ) keys [ j ] ; if ( keyResolver == null ) continue ; Binding compilerBinding = keyResolver . getCompilerBinding ( ) ; IBinding binding = compilerBinding == null ? null : resolver . getBinding ( compilerBinding ) ; astRequestor . acceptBinding ( ( ( BindingKeyResolver ) this . requestedKeys . valueTable [ j ] ) . getKey ( ) , binding ) ; worked ( <NUM_LIT:1> ) ; } } catch ( OperationCanceledException e ) { throw e ; } catch ( AbortCompilation e ) { this . handleInternalException ( e , unit ) ; } catch ( Error e ) { this . handleInternalException ( e , unit , null ) ; throw e ; } catch ( RuntimeException e ) { this . handleInternalException ( e , unit , null ) ; throw e ; } finally { astRequestor . compilationUnitResolver = null ; } } private void resolve ( String [ ] sourceCompilationUnits , String [ ] encodings , String [ ] bindingKeys , FileASTRequestor astRequestor , int apiLevel , Map compilerOptions , int flags ) { astRequestor . compilationUnitResolver = this ; this . bindingTables = new DefaultBindingResolver . BindingTables ( ) ; CompilationUnitDeclaration unit = null ; try { int length = sourceCompilationUnits . length ; org . eclipse . jdt . internal . compiler . env . ICompilationUnit [ ] sourceUnits = new org . eclipse . jdt . internal . compiler . env . ICompilationUnit [ length ] ; int count = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { char [ ] contents = null ; String encoding = encodings != null ? encodings [ i ] : null ; String sourceUnitPath = sourceCompilationUnits [ i ] ; try { contents = Util . getFileCharContent ( new File ( sourceUnitPath ) , encoding ) ; } catch ( IOException e ) { continue ; } if ( contents == null ) { continue ; } sourceUnits [ count ++ ] = new org . eclipse . jdt . internal . compiler . batch . CompilationUnit ( contents , sourceUnitPath , encoding ) ; } beginToCompile ( sourceUnits , bindingKeys ) ; for ( int i = <NUM_LIT:0> ; i < this . totalUnits ; i ++ ) { if ( resolvedRequestedSourcesAndKeys ( i ) ) { for ( ; i < this . totalUnits ; i ++ ) { this . unitsToProcess [ i ] . cleanUp ( ) ; this . unitsToProcess [ i ] = null ; } break ; } unit = this . unitsToProcess [ i ] ; try { super . process ( unit , i ) ; char [ ] fileName = unit . compilationResult . getFileName ( ) ; org . eclipse . jdt . internal . compiler . env . ICompilationUnit source = ( org . eclipse . jdt . internal . compiler . env . ICompilationUnit ) this . requestedSources . get ( fileName ) ; if ( source != null ) { CompilationResult compilationResult = unit . compilationResult ; org . eclipse . jdt . internal . compiler . env . ICompilationUnit sourceUnit = compilationResult . compilationUnit ; char [ ] contents = sourceUnit . getContents ( ) ; AST ast = AST . newAST ( apiLevel ) ; ast . setFlag ( flags | AST . RESOLVED_BINDINGS ) ; ast . setDefaultNodeFlag ( ASTNode . ORIGINAL ) ; ASTConverter converter = new ASTConverter ( compilerOptions , true , this . monitor ) ; BindingResolver resolver = new DefaultBindingResolver ( unit . scope , null , this . bindingTables , ( flags & ICompilationUnit . ENABLE_BINDINGS_RECOVERY ) != <NUM_LIT:0> , this . fromJavaProject ) ; ast . setBindingResolver ( resolver ) ; converter . setAST ( ast ) ; CompilationUnit compilationUnit = converter . convert ( unit , contents ) ; compilationUnit . setTypeRoot ( null ) ; compilationUnit . setLineEndTable ( compilationResult . getLineSeparatorPositions ( ) ) ; ast . setDefaultNodeFlag ( <NUM_LIT:0> ) ; ast . setOriginalModificationCount ( ast . modificationCount ( ) ) ; astRequestor . acceptAST ( new String ( source . getFileName ( ) ) , compilationUnit ) ; worked ( <NUM_LIT:1> ) ; this . requestedSources . put ( fileName , null ) ; } Object key = this . requestedKeys . get ( fileName ) ; if ( key != null ) { if ( key instanceof BindingKeyResolver ) { reportBinding ( key , astRequestor , unit ) ; worked ( <NUM_LIT:1> ) ; } else if ( key instanceof ArrayList ) { Iterator iterator = ( ( ArrayList ) key ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { reportBinding ( iterator . next ( ) , astRequestor , unit ) ; worked ( <NUM_LIT:1> ) ; } } this . requestedKeys . put ( fileName , null ) ; } } finally { unit . cleanUp ( ) ; } this . unitsToProcess [ i ] = null ; this . requestor . acceptResult ( unit . compilationResult . tagAsAccepted ( ) ) ; } DefaultBindingResolver resolver = new DefaultBindingResolver ( this . lookupEnvironment , null , this . bindingTables , ( flags & ICompilationUnit . ENABLE_BINDINGS_RECOVERY ) != <NUM_LIT:0> , true ) ; Object [ ] keys = this . requestedKeys . valueTable ; for ( int j = <NUM_LIT:0> , keysLength = keys . length ; j < keysLength ; j ++ ) { BindingKeyResolver keyResolver = ( BindingKeyResolver ) keys [ j ] ; if ( keyResolver == null ) continue ; Binding compilerBinding = keyResolver . getCompilerBinding ( ) ; IBinding binding = compilerBinding == null ? null : resolver . getBinding ( compilerBinding ) ; astRequestor . acceptBinding ( ( ( BindingKeyResolver ) this . requestedKeys . valueTable [ j ] ) . getKey ( ) , binding ) ; worked ( <NUM_LIT:1> ) ; } } catch ( OperationCanceledException e ) { throw e ; } catch ( AbortCompilation e ) { this . handleInternalException ( e , unit ) ; } catch ( Error e ) { this . handleInternalException ( e , unit , null ) ; throw e ; } catch ( RuntimeException e ) { this . handleInternalException ( e , unit , null ) ; throw e ; } finally { astRequestor . compilationUnitResolver = null ; } } private void reportBinding ( Object key , ASTRequestor astRequestor , WorkingCopyOwner owner , CompilationUnitDeclaration unit ) { BindingKeyResolver keyResolver = ( BindingKeyResolver ) key ; Binding compilerBinding = keyResolver . getCompilerBinding ( ) ; if ( compilerBinding != null ) { DefaultBindingResolver resolver = new DefaultBindingResolver ( unit . scope , owner , this . bindingTables , false , this . fromJavaProject ) ; AnnotationBinding annotationBinding = keyResolver . getAnnotationBinding ( ) ; IBinding binding ; if ( annotationBinding != null ) { binding = resolver . getAnnotationInstance ( annotationBinding ) ; } else { binding = resolver . getBinding ( compilerBinding ) ; } if ( binding != null ) astRequestor . acceptBinding ( keyResolver . getKey ( ) , binding ) ; } } private void reportBinding ( Object key , FileASTRequestor astRequestor , CompilationUnitDeclaration unit ) { BindingKeyResolver keyResolver = ( BindingKeyResolver ) key ; Binding compilerBinding = keyResolver . getCompilerBinding ( ) ; if ( compilerBinding != null ) { DefaultBindingResolver resolver = new DefaultBindingResolver ( unit . scope , null , this . bindingTables , false , this . fromJavaProject ) ; AnnotationBinding annotationBinding = keyResolver . getAnnotationBinding ( ) ; IBinding binding ; if ( annotationBinding != null ) { binding = resolver . getAnnotationInstance ( annotationBinding ) ; } else { binding = resolver . getBinding ( compilerBinding ) ; } if ( binding != null ) astRequestor . acceptBinding ( keyResolver . getKey ( ) , binding ) ; } } private CompilationUnitDeclaration resolve ( CompilationUnitDeclaration unit , org . eclipse . jdt . internal . compiler . env . ICompilationUnit sourceUnit , NodeSearcher nodeSearcher , boolean verifyMethods , boolean analyzeCode , boolean generateCode ) { try { if ( unit == null ) { this . parseThreshold = <NUM_LIT:0> ; beginToCompile ( new org . eclipse . jdt . internal . compiler . env . ICompilationUnit [ ] { sourceUnit } ) ; unit = this . unitsToProcess [ <NUM_LIT:0> ] ; } else { this . lookupEnvironment . buildTypeBindings ( unit , null ) ; this . lookupEnvironment . completeTypeBindings ( ) ; } if ( nodeSearcher == null ) { this . parser . getMethodBodies ( unit ) ; } else { int searchPosition = nodeSearcher . position ; char [ ] source = sourceUnit . getContents ( ) ; int length = source . length ; if ( searchPosition >= <NUM_LIT:0> && searchPosition <= length ) { unit . traverse ( nodeSearcher , unit . scope ) ; org . eclipse . jdt . internal . compiler . ast . ASTNode node = nodeSearcher . found ; if ( node != null ) { int [ ] oldLineEnds = this . parser . scanner . lineEnds ; int oldLinePtr = this . parser . scanner . linePtr ; this . parser . scanner . setSource ( source , unit . compilationResult ) ; org . eclipse . jdt . internal . compiler . ast . TypeDeclaration enclosingTypeDeclaration = nodeSearcher . enclosingType ; if ( node instanceof AbstractMethodDeclaration ) { ( ( AbstractMethodDeclaration ) node ) . parseStatements ( this . parser , unit ) ; } else if ( enclosingTypeDeclaration != null ) { if ( node instanceof org . eclipse . jdt . internal . compiler . ast . Initializer ) { ( ( org . eclipse . jdt . internal . compiler . ast . Initializer ) node ) . parseStatements ( this . parser , enclosingTypeDeclaration , unit ) ; } else if ( node instanceof org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) { ( ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) node ) . parseMethods ( this . parser , unit ) ; } } this . parser . scanner . lineEnds = oldLineEnds ; this . parser . scanner . linePtr = oldLinePtr ; } } } if ( unit . scope != null ) { unit . scope . faultInTypes ( ) ; if ( unit . scope != null && verifyMethods ) { unit . scope . verifyMethods ( this . lookupEnvironment . methodVerifier ( ) ) ; } unit . resolve ( ) ; if ( analyzeCode ) unit . analyseCode ( ) ; if ( generateCode ) unit . generateCode ( ) ; unit . finalizeProblems ( ) ; } if ( this . unitsToProcess != null ) this . unitsToProcess [ <NUM_LIT:0> ] = null ; this . requestor . acceptResult ( unit . compilationResult . tagAsAccepted ( ) ) ; return unit ; } catch ( AbortCompilation e ) { this . handleInternalException ( e , unit ) ; return unit == null ? this . unitsToProcess [ <NUM_LIT:0> ] : unit ; } catch ( Error e ) { this . handleInternalException ( e , unit , null ) ; throw e ; } catch ( RuntimeException e ) { this . handleInternalException ( e , unit , null ) ; throw e ; } finally { } } public CompilationUnitDeclaration resolve ( org . eclipse . jdt . internal . compiler . env . ICompilationUnit sourceUnit , boolean verifyMethods , boolean analyzeCode , boolean generateCode ) { return resolve ( null , sourceUnit , null , verifyMethods , analyzeCode , generateCode ) ; } boolean resolvedRequestedSourcesAndKeys ( int unitIndexToProcess ) { if ( unitIndexToProcess < this . requestedSources . size ( ) && unitIndexToProcess < this . requestedKeys . size ( ) ) return false ; Object [ ] sources = this . requestedSources . valueTable ; for ( int i = <NUM_LIT:0> , l = sources . length ; i < l ; i ++ ) if ( sources [ i ] != null ) return false ; Object [ ] keys = this . requestedKeys . valueTable ; for ( int i = <NUM_LIT:0> , l = keys . length ; i < l ; i ++ ) if ( keys [ i ] != null ) return false ; return true ; } public CompilationUnitDeclaration resolve ( CompilationUnitDeclaration unit , org . eclipse . jdt . internal . compiler . env . ICompilationUnit sourceUnit , boolean verifyMethods , boolean analyzeCode , boolean generateCode ) { return resolve ( unit , sourceUnit , null , verifyMethods , analyzeCode , generateCode ) ; } private void worked ( int work ) { if ( this . monitor != null ) { if ( this . monitor . isCanceled ( ) ) throw new OperationCanceledException ( ) ; this . monitor . worked ( work ) ; } } } </s>
<s> package org . eclipse . jdt . core . dom ; public abstract class FileASTRequestor { CompilationUnitResolver compilationUnitResolver = null ; public void acceptAST ( String sourceFilePath , CompilationUnit ast ) { } public void acceptBinding ( String bindingKey , IBinding binding ) { } public final IBinding [ ] createBindings ( String [ ] bindingKeys ) { int length = bindingKeys . length ; IBinding [ ] result = new IBinding [ length ] ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { result [ i ] = null ; if ( this . compilationUnitResolver != null ) { result [ i ] = this . compilationUnitResolver . createBinding ( bindingKeys [ i ] ) ; } } return result ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class SwitchStatement extends Statement { public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( SwitchStatement . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; public static final ChildListPropertyDescriptor STATEMENTS_PROPERTY = new ChildListPropertyDescriptor ( SwitchStatement . class , "<STR_LIT>" , Statement . class , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( SwitchStatement . class , propertyList ) ; addProperty ( EXPRESSION_PROPERTY , propertyList ) ; addProperty ( STATEMENTS_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Expression expression = null ; private ASTNode . NodeList statements = new ASTNode . NodeList ( STATEMENTS_PROPERTY ) ; SwitchStatement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == STATEMENTS_PROPERTY ) { return statements ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return SWITCH_STATEMENT ; } ASTNode clone0 ( AST target ) { SwitchStatement result = new SwitchStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; result . setExpression ( ( Expression ) getExpression ( ) . clone ( target ) ) ; result . statements ( ) . addAll ( ASTNode . copySubtrees ( target , statements ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getExpression ( ) ) ; acceptChildren ( visitor , this . statements ) ; } visitor . endVisit ( this ) ; } public Expression getExpression ( ) { if ( this . expression == null ) { synchronized ( this ) { if ( this . expression == null ) { preLazyInit ( ) ; this . expression = new SimpleName ( this . ast ) ; postLazyInit ( this . expression , EXPRESSION_PROPERTY ) ; } } } return this . expression ; } public void setExpression ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . expression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . expression = expression ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } public List statements ( ) { return this . statements ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . expression == null ? <NUM_LIT:0> : getExpression ( ) . treeSize ( ) ) + this . statements . listSize ( ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; class DefaultASTVisitor extends ASTVisitor { public DefaultASTVisitor ( ) { super ( ) ; } public DefaultASTVisitor ( boolean visitDocTags ) { super ( visitDocTags ) ; } public void endVisit ( AnnotationTypeDeclaration node ) { endVisitNode ( node ) ; } public void endVisit ( AnnotationTypeMemberDeclaration node ) { endVisitNode ( node ) ; } public void endVisit ( AnonymousClassDeclaration node ) { endVisitNode ( node ) ; } public void endVisit ( ArrayAccess node ) { endVisitNode ( node ) ; } public void endVisit ( ArrayCreation node ) { endVisitNode ( node ) ; } public void endVisit ( ArrayInitializer node ) { endVisitNode ( node ) ; } public void endVisit ( ArrayType node ) { endVisitNode ( node ) ; } public void endVisit ( AssertStatement node ) { endVisitNode ( node ) ; } public void endVisit ( Assignment node ) { endVisitNode ( node ) ; } public void endVisit ( Block node ) { endVisitNode ( node ) ; } public void endVisit ( BlockComment node ) { endVisitNode ( node ) ; } public void endVisit ( BooleanLiteral node ) { endVisitNode ( node ) ; } public void endVisit ( BreakStatement node ) { endVisitNode ( node ) ; } public void endVisit ( CastExpression node ) { endVisitNode ( node ) ; } public void endVisit ( CatchClause node ) { endVisitNode ( node ) ; } public void endVisit ( CharacterLiteral node ) { endVisitNode ( node ) ; } public void endVisit ( ClassInstanceCreation node ) { endVisitNode ( node ) ; } public void endVisit ( CompilationUnit node ) { endVisitNode ( node ) ; } public void endVisit ( ConditionalExpression node ) { endVisitNode ( node ) ; } public void endVisit ( ConstructorInvocation node ) { endVisitNode ( node ) ; } public void endVisit ( ContinueStatement node ) { endVisitNode ( node ) ; } public void endVisit ( DoStatement node ) { endVisitNode ( node ) ; } public void endVisit ( EmptyStatement node ) { endVisitNode ( node ) ; } public void endVisit ( EnhancedForStatement node ) { endVisitNode ( node ) ; } public void endVisit ( EnumConstantDeclaration node ) { endVisitNode ( node ) ; } public void endVisit ( EnumDeclaration node ) { endVisitNode ( node ) ; } public void endVisit ( ExpressionStatement node ) { endVisitNode ( node ) ; } public void endVisit ( FieldAccess node ) { endVisitNode ( node ) ; } public void endVisit ( FieldDeclaration node ) { endVisitNode ( node ) ; } public void endVisit ( ForStatement node ) { endVisitNode ( node ) ; } public void endVisit ( IfStatement node ) { endVisitNode ( node ) ; } public void endVisit ( ImportDeclaration node ) { endVisitNode ( node ) ; } public void endVisit ( InfixExpression node ) { endVisitNode ( node ) ; } public void endVisit ( Initializer node ) { endVisitNode ( node ) ; } public void endVisit ( InstanceofExpression node ) { endVisitNode ( node ) ; } public void endVisit ( Javadoc node ) { endVisitNode ( node ) ; } public void endVisit ( LabeledStatement node ) { endVisitNode ( node ) ; } public void endVisit ( LineComment node ) { endVisitNode ( node ) ; } public void endVisit ( MarkerAnnotation node ) { endVisitNode ( node ) ; } public void endVisit ( MemberRef node ) { endVisitNode ( node ) ; } public void endVisit ( MemberValuePair node ) { endVisitNode ( node ) ; } public void endVisit ( MethodDeclaration node ) { endVisitNode ( node ) ; } public void endVisit ( MethodInvocation node ) { endVisitNode ( node ) ; } public void endVisit ( MethodRef node ) { endVisitNode ( node ) ; } public void endVisit ( MethodRefParameter node ) { endVisitNode ( node ) ; } public void endVisit ( NormalAnnotation node ) { endVisitNode ( node ) ; } public void endVisit ( NullLiteral node ) { endVisitNode ( node ) ; } public void endVisit ( NumberLiteral node ) { endVisitNode ( node ) ; } public void endVisit ( PackageDeclaration node ) { endVisitNode ( node ) ; } public void endVisit ( ParameterizedType node ) { endVisitNode ( node ) ; } public void endVisit ( ParenthesizedExpression node ) { endVisitNode ( node ) ; } public void endVisit ( PostfixExpression node ) { endVisitNode ( node ) ; } public void endVisit ( PrefixExpression node ) { endVisitNode ( node ) ; } public void endVisit ( PrimitiveType node ) { endVisitNode ( node ) ; } public void endVisit ( QualifiedName node ) { endVisitNode ( node ) ; } public void endVisit ( QualifiedType node ) { endVisitNode ( node ) ; } public void endVisit ( ReturnStatement node ) { endVisitNode ( node ) ; } public void endVisit ( SimpleName node ) { endVisitNode ( node ) ; } public void endVisit ( SimpleType node ) { endVisitNode ( node ) ; } public void endVisit ( SingleMemberAnnotation node ) { endVisitNode ( node ) ; } public void endVisit ( SingleVariableDeclaration node ) { endVisitNode ( node ) ; } public void endVisit ( StringLiteral node ) { endVisitNode ( node ) ; } public void endVisit ( SuperConstructorInvocation node ) { endVisitNode ( node ) ; } public void endVisit ( SuperFieldAccess node ) { endVisitNode ( node ) ; } public void endVisit ( SuperMethodInvocation node ) { endVisitNode ( node ) ; } public void endVisit ( SwitchCase node ) { endVisitNode ( node ) ; } public void endVisit ( SwitchStatement node ) { endVisitNode ( node ) ; } public void endVisit ( SynchronizedStatement node ) { endVisitNode ( node ) ; } public void endVisit ( TagElement node ) { endVisitNode ( node ) ; } public void endVisit ( TextElement node ) { endVisitNode ( node ) ; } public void endVisit ( ThisExpression node ) { endVisitNode ( node ) ; } public void endVisit ( ThrowStatement node ) { endVisitNode ( node ) ; } public void endVisit ( TryStatement node ) { endVisitNode ( node ) ; } public void endVisit ( TypeDeclaration node ) { endVisitNode ( node ) ; } public void endVisit ( TypeDeclarationStatement node ) { endVisitNode ( node ) ; } public void endVisit ( TypeLiteral node ) { endVisitNode ( node ) ; } public void endVisit ( TypeParameter node ) { endVisitNode ( node ) ; } public void endVisit ( VariableDeclarationExpression node ) { endVisitNode ( node ) ; } public void endVisit ( VariableDeclarationFragment node ) { endVisitNode ( node ) ; } public void endVisit ( VariableDeclarationStatement node ) { endVisitNode ( node ) ; } public void endVisit ( WhileStatement node ) { endVisitNode ( node ) ; } public void endVisit ( WildcardType node ) { endVisitNode ( node ) ; } protected void endVisitNode ( ASTNode node ) { } public boolean visit ( AnnotationTypeDeclaration node ) { return visitNode ( node ) ; } public boolean visit ( AnnotationTypeMemberDeclaration node ) { return visitNode ( node ) ; } public boolean visit ( AnonymousClassDeclaration node ) { return visitNode ( node ) ; } public boolean visit ( ArrayAccess node ) { return visitNode ( node ) ; } public boolean visit ( ArrayCreation node ) { return visitNode ( node ) ; } public boolean visit ( ArrayInitializer node ) { return visitNode ( node ) ; } public boolean visit ( ArrayType node ) { visitNode ( node ) ; return false ; } public boolean visit ( AssertStatement node ) { return visitNode ( node ) ; } public boolean visit ( Assignment node ) { return visitNode ( node ) ; } public boolean visit ( Block node ) { return visitNode ( node ) ; } public boolean visit ( BlockComment node ) { return visitNode ( node ) ; } public boolean visit ( BooleanLiteral node ) { return visitNode ( node ) ; } public boolean visit ( BreakStatement node ) { return visitNode ( node ) ; } public boolean visit ( CastExpression node ) { return visitNode ( node ) ; } public boolean visit ( CatchClause node ) { return visitNode ( node ) ; } public boolean visit ( CharacterLiteral node ) { return visitNode ( node ) ; } public boolean visit ( ClassInstanceCreation node ) { return visitNode ( node ) ; } public boolean visit ( CompilationUnit node ) { return visitNode ( node ) ; } public boolean visit ( ConditionalExpression node ) { return visitNode ( node ) ; } public boolean visit ( ConstructorInvocation node ) { return visitNode ( node ) ; } public boolean visit ( ContinueStatement node ) { return visitNode ( node ) ; } public boolean visit ( DoStatement node ) { return visitNode ( node ) ; } public boolean visit ( EmptyStatement node ) { return visitNode ( node ) ; } public boolean visit ( EnhancedForStatement node ) { return visitNode ( node ) ; } public boolean visit ( EnumConstantDeclaration node ) { return visitNode ( node ) ; } public boolean visit ( EnumDeclaration node ) { return visitNode ( node ) ; } public boolean visit ( ExpressionStatement node ) { return visitNode ( node ) ; } public boolean visit ( FieldAccess node ) { return visitNode ( node ) ; } public boolean visit ( FieldDeclaration node ) { return visitNode ( node ) ; } public boolean visit ( ForStatement node ) { return visitNode ( node ) ; } public boolean visit ( IfStatement node ) { return visitNode ( node ) ; } public boolean visit ( ImportDeclaration node ) { return visitNode ( node ) ; } public boolean visit ( InfixExpression node ) { return visitNode ( node ) ; } public boolean visit ( Initializer node ) { return visitNode ( node ) ; } public boolean visit ( InstanceofExpression node ) { return visitNode ( node ) ; } public boolean visit ( Javadoc node ) { if ( super . visit ( node ) ) { return visitNode ( node ) ; } return false ; } public boolean visit ( LabeledStatement node ) { return visitNode ( node ) ; } public boolean visit ( LineComment node ) { return visitNode ( node ) ; } public boolean visit ( MarkerAnnotation node ) { return visitNode ( node ) ; } public boolean visit ( MemberRef node ) { return visitNode ( node ) ; } public boolean visit ( MemberValuePair node ) { return visitNode ( node ) ; } public boolean visit ( MethodDeclaration node ) { return visitNode ( node ) ; } public boolean visit ( MethodInvocation node ) { return visitNode ( node ) ; } public boolean visit ( MethodRef node ) { return visitNode ( node ) ; } public boolean visit ( MethodRefParameter node ) { return visitNode ( node ) ; } public boolean visit ( NormalAnnotation node ) { return visitNode ( node ) ; } public boolean visit ( NullLiteral node ) { return visitNode ( node ) ; } public boolean visit ( NumberLiteral node ) { return visitNode ( node ) ; } public boolean visit ( PackageDeclaration node ) { return visitNode ( node ) ; } public boolean visit ( ParameterizedType node ) { return visitNode ( node ) ; } public boolean visit ( ParenthesizedExpression node ) { return visitNode ( node ) ; } public boolean visit ( PostfixExpression node ) { return visitNode ( node ) ; } public boolean visit ( PrefixExpression node ) { return visitNode ( node ) ; } public boolean visit ( PrimitiveType node ) { return visitNode ( node ) ; } public boolean visit ( QualifiedName node ) { return visitNode ( node ) ; } public boolean visit ( QualifiedType node ) { return visitNode ( node ) ; } public boolean visit ( ReturnStatement node ) { return visitNode ( node ) ; } public boolean visit ( SimpleName node ) { return visitNode ( node ) ; } public boolean visit ( SimpleType node ) { return visitNode ( node ) ; } public boolean visit ( SingleMemberAnnotation node ) { return visitNode ( node ) ; } public boolean visit ( SingleVariableDeclaration node ) { return visitNode ( node ) ; } public boolean visit ( StringLiteral node ) { return visitNode ( node ) ; } public boolean visit ( SuperConstructorInvocation node ) { return visitNode ( node ) ; } public boolean visit ( SuperFieldAccess node ) { return visitNode ( node ) ; } public boolean visit ( SuperMethodInvocation node ) { return visitNode ( node ) ; } public boolean visit ( SwitchCase node ) { return visitNode ( node ) ; } public boolean visit ( SwitchStatement node ) { return visitNode ( node ) ; } public boolean visit ( SynchronizedStatement node ) { return visitNode ( node ) ; } public boolean visit ( TagElement node ) { return visitNode ( node ) ; } public boolean visit ( TextElement node ) { return visitNode ( node ) ; } public boolean visit ( ThisExpression node ) { return visitNode ( node ) ; } public boolean visit ( ThrowStatement node ) { return visitNode ( node ) ; } public boolean visit ( TryStatement node ) { return visitNode ( node ) ; } public boolean visit ( TypeDeclaration node ) { return visitNode ( node ) ; } public boolean visit ( TypeDeclarationStatement node ) { return visitNode ( node ) ; } public boolean visit ( TypeLiteral node ) { return visitNode ( node ) ; } public boolean visit ( TypeParameter node ) { return visitNode ( node ) ; } public boolean visit ( VariableDeclarationExpression node ) { return visitNode ( node ) ; } public boolean visit ( VariableDeclarationFragment node ) { return visitNode ( node ) ; } public boolean visit ( VariableDeclarationStatement node ) { return visitNode ( node ) ; } public boolean visit ( WhileStatement node ) { return visitNode ( node ) ; } public boolean visit ( WildcardType node ) { return visitNode ( node ) ; } protected boolean visitNode ( ASTNode node ) { return true ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public final class TagElement extends ASTNode implements IDocElement { public static final SimplePropertyDescriptor TAG_NAME_PROPERTY = new SimplePropertyDescriptor ( TagElement . class , "<STR_LIT>" , String . class , OPTIONAL ) ; public static final ChildListPropertyDescriptor FRAGMENTS_PROPERTY = new ChildListPropertyDescriptor ( TagElement . class , "<STR_LIT>" , IDocElement . class , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( TagElement . class , propertyList ) ; addProperty ( TAG_NAME_PROPERTY , propertyList ) ; addProperty ( FRAGMENTS_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } public static final String TAG_AUTHOR = "<STR_LIT>" ; public static final String TAG_CODE = "<STR_LIT>" ; public static final String TAG_DEPRECATED = "<STR_LIT>" ; public static final String TAG_DOCROOT = "<STR_LIT>" ; public static final String TAG_EXCEPTION = "<STR_LIT>" ; public static final String TAG_INHERITDOC = "<STR_LIT>" ; public static final String TAG_LINK = "<STR_LIT>" ; public static final String TAG_LINKPLAIN = "<STR_LIT>" ; public static final String TAG_LITERAL = "<STR_LIT>" ; public static final String TAG_PARAM = "<STR_LIT>" ; public static final String TAG_RETURN = "<STR_LIT>" ; public static final String TAG_SEE = "<STR_LIT>" ; public static final String TAG_SERIAL = "<STR_LIT>" ; public static final String TAG_SERIALDATA = "<STR_LIT>" ; public static final String TAG_SERIALFIELD = "<STR_LIT>" ; public static final String TAG_SINCE = "<STR_LIT>" ; public static final String TAG_THROWS = "<STR_LIT>" ; public static final String TAG_VALUE = "<STR_LIT>" ; public static final String TAG_VERSION = "<STR_LIT>" ; private String optionalTagName = null ; private ASTNode . NodeList fragments = new ASTNode . NodeList ( FRAGMENTS_PROPERTY ) ; TagElement ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final Object internalGetSetObjectProperty ( SimplePropertyDescriptor property , boolean get , Object value ) { if ( property == TAG_NAME_PROPERTY ) { if ( get ) { return getTagName ( ) ; } else { setTagName ( ( String ) value ) ; return null ; } } return super . internalGetSetObjectProperty ( property , get , value ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == FRAGMENTS_PROPERTY ) { return fragments ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return TAG_ELEMENT ; } ASTNode clone0 ( AST target ) { TagElement result = new TagElement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setTagName ( getTagName ( ) ) ; result . fragments ( ) . addAll ( ASTNode . copySubtrees ( target , fragments ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChildren ( visitor , this . fragments ) ; } visitor . endVisit ( this ) ; } public String getTagName ( ) { return this . optionalTagName ; } public void setTagName ( String tagName ) { preValueChange ( TAG_NAME_PROPERTY ) ; this . optionalTagName = tagName ; postValueChange ( TAG_NAME_PROPERTY ) ; } public List fragments ( ) { return this . fragments ; } public boolean isNested ( ) { return ( getParent ( ) instanceof TagElement ) ; } int memSize ( ) { int size = BASE_NODE_SIZE + <NUM_LIT:2> * <NUM_LIT:4> + stringSize ( this . optionalTagName ) ; return size ; } int treeSize ( ) { return memSize ( ) + this . fragments . listSize ( ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class BooleanLiteral extends Expression { public static final SimplePropertyDescriptor BOOLEAN_VALUE_PROPERTY = new SimplePropertyDescriptor ( BooleanLiteral . class , "<STR_LIT>" , boolean . class , MANDATORY ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( BooleanLiteral . class , properyList ) ; addProperty ( BOOLEAN_VALUE_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private boolean value = false ; BooleanLiteral ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final boolean internalGetSetBooleanProperty ( SimplePropertyDescriptor property , boolean get , boolean newValue ) { if ( property == BOOLEAN_VALUE_PROPERTY ) { if ( get ) { return booleanValue ( ) ; } else { setBooleanValue ( newValue ) ; return false ; } } return super . internalGetSetBooleanProperty ( property , get , newValue ) ; } final int getNodeType0 ( ) { return BOOLEAN_LITERAL ; } ASTNode clone0 ( AST target ) { BooleanLiteral result = new BooleanLiteral ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setBooleanValue ( booleanValue ( ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { visitor . visit ( this ) ; visitor . endVisit ( this ) ; } public boolean booleanValue ( ) { return this . value ; } public void setBooleanValue ( boolean value ) { preValueChange ( BOOLEAN_VALUE_PROPERTY ) ; this . value = value ; postValueChange ( BOOLEAN_VALUE_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:1> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public final class BlockComment extends Comment { private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:1> ) ; createPropertyList ( BlockComment . class , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } BlockComment ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final int getNodeType0 ( ) { return BLOCK_COMMENT ; } ASTNode clone0 ( AST target ) { BlockComment result = new BlockComment ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { visitor . visit ( this ) ; visitor . endVisit ( this ) ; } int memSize ( ) { return super . memSize ( ) ; } int treeSize ( ) { return memSize ( ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; public abstract class Statement extends ASTNode { private String optionalLeadingComment = null ; Statement ( AST ast ) { super ( ast ) ; } public String getLeadingComment ( ) { return this . optionalLeadingComment ; } public void setLeadingComment ( String comment ) { if ( comment != null ) { char [ ] source = comment . toCharArray ( ) ; Scanner scanner = this . ast . scanner ; scanner . resetTo ( <NUM_LIT:0> , source . length ) ; scanner . setSource ( source ) ; try { int token ; boolean onlyOneComment = false ; while ( ( token = scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_JAVADOC : case TerminalTokens . TokenNameCOMMENT_LINE : if ( onlyOneComment ) { throw new IllegalArgumentException ( ) ; } onlyOneComment = true ; break ; default : onlyOneComment = false ; } } if ( ! onlyOneComment ) { throw new IllegalArgumentException ( ) ; } } catch ( InvalidInputException e ) { throw new IllegalArgumentException ( ) ; } } checkModifiable ( ) ; this . optionalLeadingComment = comment ; } void copyLeadingComment ( Statement source ) { setLeadingComment ( source . getLeadingComment ( ) ) ; } int memSize ( ) { int size = BASE_NODE_SIZE + <NUM_LIT:1> * <NUM_LIT:4> + stringSize ( getLeadingComment ( ) ) ; return size ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . Iterator ; import java . util . List ; public class ASTMatcher { private boolean matchDocTags ; public ASTMatcher ( ) { this ( false ) ; } public ASTMatcher ( boolean matchDocTags ) { this . matchDocTags = matchDocTags ; } public final boolean safeSubtreeListMatch ( List list1 , List list2 ) { int size1 = list1 . size ( ) ; int size2 = list2 . size ( ) ; if ( size1 != size2 ) { return false ; } for ( Iterator it1 = list1 . iterator ( ) , it2 = list2 . iterator ( ) ; it1 . hasNext ( ) ; ) { ASTNode n1 = ( ASTNode ) it1 . next ( ) ; ASTNode n2 = ( ASTNode ) it2 . next ( ) ; if ( ! n1 . subtreeMatch ( this , n2 ) ) { return false ; } } return true ; } public final boolean safeSubtreeMatch ( Object node1 , Object node2 ) { if ( node1 == null && node2 == null ) { return true ; } if ( node1 == null || node2 == null ) { return false ; } return ( ( ASTNode ) node1 ) . subtreeMatch ( this , node2 ) ; } public static boolean safeEquals ( Object o1 , Object o2 ) { if ( o1 == o2 ) { return true ; } if ( o1 == null || o2 == null ) { return false ; } return o1 . equals ( o2 ) ; } public boolean match ( AnnotationTypeDeclaration node , Object other ) { if ( ! ( other instanceof AnnotationTypeDeclaration ) ) { return false ; } AnnotationTypeDeclaration o = ( AnnotationTypeDeclaration ) other ; return ( safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) && safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . bodyDeclarations ( ) , o . bodyDeclarations ( ) ) ) ; } public boolean match ( AnnotationTypeMemberDeclaration node , Object other ) { if ( ! ( other instanceof AnnotationTypeMemberDeclaration ) ) { return false ; } AnnotationTypeMemberDeclaration o = ( AnnotationTypeMemberDeclaration ) other ; return ( safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) && safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) && safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeMatch ( node . getDefault ( ) , o . getDefault ( ) ) ) ; } public boolean match ( AnonymousClassDeclaration node , Object other ) { if ( ! ( other instanceof AnonymousClassDeclaration ) ) { return false ; } AnonymousClassDeclaration o = ( AnonymousClassDeclaration ) other ; return safeSubtreeListMatch ( node . bodyDeclarations ( ) , o . bodyDeclarations ( ) ) ; } public boolean match ( ArrayAccess node , Object other ) { if ( ! ( other instanceof ArrayAccess ) ) { return false ; } ArrayAccess o = ( ArrayAccess ) other ; return ( safeSubtreeMatch ( node . getArray ( ) , o . getArray ( ) ) && safeSubtreeMatch ( node . getIndex ( ) , o . getIndex ( ) ) ) ; } public boolean match ( ArrayCreation node , Object other ) { if ( ! ( other instanceof ArrayCreation ) ) { return false ; } ArrayCreation o = ( ArrayCreation ) other ; return ( safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeListMatch ( node . dimensions ( ) , o . dimensions ( ) ) && safeSubtreeMatch ( node . getInitializer ( ) , o . getInitializer ( ) ) ) ; } public boolean match ( ArrayInitializer node , Object other ) { if ( ! ( other instanceof ArrayInitializer ) ) { return false ; } ArrayInitializer o = ( ArrayInitializer ) other ; return safeSubtreeListMatch ( node . expressions ( ) , o . expressions ( ) ) ; } public boolean match ( ArrayType node , Object other ) { if ( ! ( other instanceof ArrayType ) ) { return false ; } ArrayType o = ( ArrayType ) other ; return safeSubtreeMatch ( node . getComponentType ( ) , o . getComponentType ( ) ) ; } public boolean match ( AssertStatement node , Object other ) { if ( ! ( other instanceof AssertStatement ) ) { return false ; } AssertStatement o = ( AssertStatement ) other ; return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getMessage ( ) , o . getMessage ( ) ) ) ; } public boolean match ( Assignment node , Object other ) { if ( ! ( other instanceof Assignment ) ) { return false ; } Assignment o = ( Assignment ) other ; return ( node . getOperator ( ) . equals ( o . getOperator ( ) ) && safeSubtreeMatch ( node . getLeftHandSide ( ) , o . getLeftHandSide ( ) ) && safeSubtreeMatch ( node . getRightHandSide ( ) , o . getRightHandSide ( ) ) ) ; } public boolean match ( Block node , Object other ) { if ( ! ( other instanceof Block ) ) { return false ; } Block o = ( Block ) other ; return safeSubtreeListMatch ( node . statements ( ) , o . statements ( ) ) ; } public boolean match ( BlockComment node , Object other ) { if ( ! ( other instanceof BlockComment ) ) { return false ; } return true ; } public boolean match ( BooleanLiteral node , Object other ) { if ( ! ( other instanceof BooleanLiteral ) ) { return false ; } BooleanLiteral o = ( BooleanLiteral ) other ; return node . booleanValue ( ) == o . booleanValue ( ) ; } public boolean match ( BreakStatement node , Object other ) { if ( ! ( other instanceof BreakStatement ) ) { return false ; } BreakStatement o = ( BreakStatement ) other ; return safeSubtreeMatch ( node . getLabel ( ) , o . getLabel ( ) ) ; } public boolean match ( CastExpression node , Object other ) { if ( ! ( other instanceof CastExpression ) ) { return false ; } CastExpression o = ( CastExpression ) other ; return ( safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) ) ; } public boolean match ( CatchClause node , Object other ) { if ( ! ( other instanceof CatchClause ) ) { return false ; } CatchClause o = ( CatchClause ) other ; return ( safeSubtreeMatch ( node . getException ( ) , o . getException ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( CharacterLiteral node , Object other ) { if ( ! ( other instanceof CharacterLiteral ) ) { return false ; } CharacterLiteral o = ( CharacterLiteral ) other ; return safeEquals ( node . getEscapedValue ( ) , o . getEscapedValue ( ) ) ; } public boolean match ( ClassInstanceCreation node , Object other ) { if ( ! ( other instanceof ClassInstanceCreation ) ) { return false ; } ClassInstanceCreation o = ( ClassInstanceCreation ) other ; int level = node . getAST ( ) . apiLevel ; if ( level == AST . JLS2_INTERNAL ) { if ( ! safeSubtreeMatch ( node . internalGetName ( ) , o . internalGetName ( ) ) ) { return false ; } } if ( level >= AST . JLS3 ) { if ( ! safeSubtreeListMatch ( node . typeArguments ( ) , o . typeArguments ( ) ) ) { return false ; } if ( ! safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) ) { return false ; } } return safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeListMatch ( node . arguments ( ) , o . arguments ( ) ) && safeSubtreeMatch ( node . getAnonymousClassDeclaration ( ) , o . getAnonymousClassDeclaration ( ) ) ; } public boolean match ( CompilationUnit node , Object other ) { if ( ! ( other instanceof CompilationUnit ) ) { return false ; } CompilationUnit o = ( CompilationUnit ) other ; return ( safeSubtreeMatch ( node . getPackage ( ) , o . getPackage ( ) ) && safeSubtreeListMatch ( node . imports ( ) , o . imports ( ) ) && safeSubtreeListMatch ( node . types ( ) , o . types ( ) ) ) ; } public boolean match ( ConditionalExpression node , Object other ) { if ( ! ( other instanceof ConditionalExpression ) ) { return false ; } ConditionalExpression o = ( ConditionalExpression ) other ; return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getThenExpression ( ) , o . getThenExpression ( ) ) && safeSubtreeMatch ( node . getElseExpression ( ) , o . getElseExpression ( ) ) ) ; } public boolean match ( ConstructorInvocation node , Object other ) { if ( ! ( other instanceof ConstructorInvocation ) ) { return false ; } ConstructorInvocation o = ( ConstructorInvocation ) other ; if ( node . getAST ( ) . apiLevel >= AST . JLS3 ) { if ( ! safeSubtreeListMatch ( node . typeArguments ( ) , o . typeArguments ( ) ) ) { return false ; } } return safeSubtreeListMatch ( node . arguments ( ) , o . arguments ( ) ) ; } public boolean match ( ContinueStatement node , Object other ) { if ( ! ( other instanceof ContinueStatement ) ) { return false ; } ContinueStatement o = ( ContinueStatement ) other ; return safeSubtreeMatch ( node . getLabel ( ) , o . getLabel ( ) ) ; } public boolean match ( DoStatement node , Object other ) { if ( ! ( other instanceof DoStatement ) ) { return false ; } DoStatement o = ( DoStatement ) other ; return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( EmptyStatement node , Object other ) { if ( ! ( other instanceof EmptyStatement ) ) { return false ; } return true ; } public boolean match ( EnhancedForStatement node , Object other ) { if ( ! ( other instanceof EnhancedForStatement ) ) { return false ; } EnhancedForStatement o = ( EnhancedForStatement ) other ; return ( safeSubtreeMatch ( node . getParameter ( ) , o . getParameter ( ) ) && safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( EnumConstantDeclaration node , Object other ) { if ( ! ( other instanceof EnumConstantDeclaration ) ) { return false ; } EnumConstantDeclaration o = ( EnumConstantDeclaration ) other ; return ( safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) && safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . arguments ( ) , o . arguments ( ) ) && safeSubtreeMatch ( node . getAnonymousClassDeclaration ( ) , o . getAnonymousClassDeclaration ( ) ) ) ; } public boolean match ( EnumDeclaration node , Object other ) { if ( ! ( other instanceof EnumDeclaration ) ) { return false ; } EnumDeclaration o = ( EnumDeclaration ) other ; return ( safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) && safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . superInterfaceTypes ( ) , o . superInterfaceTypes ( ) ) && safeSubtreeListMatch ( node . enumConstants ( ) , o . enumConstants ( ) ) && safeSubtreeListMatch ( node . bodyDeclarations ( ) , o . bodyDeclarations ( ) ) ) ; } public boolean match ( ExpressionStatement node , Object other ) { if ( ! ( other instanceof ExpressionStatement ) ) { return false ; } ExpressionStatement o = ( ExpressionStatement ) other ; return safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) ; } public boolean match ( FieldAccess node , Object other ) { if ( ! ( other instanceof FieldAccess ) ) { return false ; } FieldAccess o = ( FieldAccess ) other ; return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) ) ; } public boolean match ( FieldDeclaration node , Object other ) { if ( ! ( other instanceof FieldDeclaration ) ) { return false ; } FieldDeclaration o = ( FieldDeclaration ) other ; int level = node . getAST ( ) . apiLevel ; if ( level == AST . JLS2_INTERNAL ) { if ( node . getModifiers ( ) != o . getModifiers ( ) ) { return false ; } } if ( level >= AST . JLS3 ) { if ( ! safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) ) { return false ; } } return safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) && safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeListMatch ( node . fragments ( ) , o . fragments ( ) ) ; } public boolean match ( ForStatement node , Object other ) { if ( ! ( other instanceof ForStatement ) ) { return false ; } ForStatement o = ( ForStatement ) other ; return ( safeSubtreeListMatch ( node . initializers ( ) , o . initializers ( ) ) && safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeListMatch ( node . updaters ( ) , o . updaters ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( IfStatement node , Object other ) { if ( ! ( other instanceof IfStatement ) ) { return false ; } IfStatement o = ( IfStatement ) other ; return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getThenStatement ( ) , o . getThenStatement ( ) ) && safeSubtreeMatch ( node . getElseStatement ( ) , o . getElseStatement ( ) ) ) ; } public boolean match ( ImportDeclaration node , Object other ) { if ( ! ( other instanceof ImportDeclaration ) ) { return false ; } ImportDeclaration o = ( ImportDeclaration ) other ; if ( node . getAST ( ) . apiLevel >= AST . JLS3 ) { if ( node . isStatic ( ) != o . isStatic ( ) ) { return false ; } } return ( safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && node . isOnDemand ( ) == o . isOnDemand ( ) ) ; } public boolean match ( InfixExpression node , Object other ) { if ( ! ( other instanceof InfixExpression ) ) { return false ; } InfixExpression o = ( InfixExpression ) other ; if ( node . hasExtendedOperands ( ) && o . hasExtendedOperands ( ) ) { if ( ! safeSubtreeListMatch ( node . extendedOperands ( ) , o . extendedOperands ( ) ) ) { return false ; } } if ( node . hasExtendedOperands ( ) != o . hasExtendedOperands ( ) ) { return false ; } return ( node . getOperator ( ) . equals ( o . getOperator ( ) ) && safeSubtreeMatch ( node . getLeftOperand ( ) , o . getLeftOperand ( ) ) && safeSubtreeMatch ( node . getRightOperand ( ) , o . getRightOperand ( ) ) ) ; } public boolean match ( InstanceofExpression node , Object other ) { if ( ! ( other instanceof InstanceofExpression ) ) { return false ; } InstanceofExpression o = ( InstanceofExpression ) other ; return ( safeSubtreeMatch ( node . getLeftOperand ( ) , o . getLeftOperand ( ) ) && safeSubtreeMatch ( node . getRightOperand ( ) , o . getRightOperand ( ) ) ) ; } public boolean match ( Initializer node , Object other ) { if ( ! ( other instanceof Initializer ) ) { return false ; } Initializer o = ( Initializer ) other ; int level = node . getAST ( ) . apiLevel ; if ( level == AST . JLS2_INTERNAL ) { if ( node . getModifiers ( ) != o . getModifiers ( ) ) { return false ; } } if ( level >= AST . JLS3 ) { if ( ! safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) ) { return false ; } } return ( safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( Javadoc node , Object other ) { if ( ! ( other instanceof Javadoc ) ) { return false ; } Javadoc o = ( Javadoc ) other ; if ( this . matchDocTags ) { return safeSubtreeListMatch ( node . tags ( ) , o . tags ( ) ) ; } else { return compareDeprecatedComment ( node , o ) ; } } private boolean compareDeprecatedComment ( Javadoc first , Javadoc second ) { if ( first . getAST ( ) . apiLevel == AST . JLS2_INTERNAL ) { return safeEquals ( first . getComment ( ) , second . getComment ( ) ) ; } else { return true ; } } public boolean match ( LabeledStatement node , Object other ) { if ( ! ( other instanceof LabeledStatement ) ) { return false ; } LabeledStatement o = ( LabeledStatement ) other ; return ( safeSubtreeMatch ( node . getLabel ( ) , o . getLabel ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( LineComment node , Object other ) { if ( ! ( other instanceof LineComment ) ) { return false ; } return true ; } public boolean match ( MarkerAnnotation node , Object other ) { if ( ! ( other instanceof MarkerAnnotation ) ) { return false ; } MarkerAnnotation o = ( MarkerAnnotation ) other ; return safeSubtreeMatch ( node . getTypeName ( ) , o . getTypeName ( ) ) ; } public boolean match ( MemberRef node , Object other ) { if ( ! ( other instanceof MemberRef ) ) { return false ; } MemberRef o = ( MemberRef ) other ; return ( safeSubtreeMatch ( node . getQualifier ( ) , o . getQualifier ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) ) ; } public boolean match ( MemberValuePair node , Object other ) { if ( ! ( other instanceof MemberValuePair ) ) { return false ; } MemberValuePair o = ( MemberValuePair ) other ; return ( safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeMatch ( node . getValue ( ) , o . getValue ( ) ) ) ; } public boolean match ( MethodRef node , Object other ) { if ( ! ( other instanceof MethodRef ) ) { return false ; } MethodRef o = ( MethodRef ) other ; return ( safeSubtreeMatch ( node . getQualifier ( ) , o . getQualifier ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . parameters ( ) , o . parameters ( ) ) ) ; } public boolean match ( MethodRefParameter node , Object other ) { if ( ! ( other instanceof MethodRefParameter ) ) { return false ; } MethodRefParameter o = ( MethodRefParameter ) other ; int level = node . getAST ( ) . apiLevel ; if ( level >= AST . JLS3 ) { if ( node . isVarargs ( ) != o . isVarargs ( ) ) { return false ; } } return ( safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) ) ; } public boolean match ( MethodDeclaration node , Object other ) { if ( ! ( other instanceof MethodDeclaration ) ) { return false ; } MethodDeclaration o = ( MethodDeclaration ) other ; int level = node . getAST ( ) . apiLevel ; if ( level == AST . JLS2_INTERNAL ) { if ( node . getModifiers ( ) != o . getModifiers ( ) ) { return false ; } if ( ! safeSubtreeMatch ( node . internalGetReturnType ( ) , o . internalGetReturnType ( ) ) ) { return false ; } } if ( level >= AST . JLS3 ) { if ( ! safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) ) { return false ; } if ( ! safeSubtreeMatch ( node . getReturnType2 ( ) , o . getReturnType2 ( ) ) ) { return false ; } if ( ! safeSubtreeListMatch ( node . typeParameters ( ) , o . typeParameters ( ) ) ) { return false ; } } return ( ( node . isConstructor ( ) == o . isConstructor ( ) ) && safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . parameters ( ) , o . parameters ( ) ) && node . getExtraDimensions ( ) == o . getExtraDimensions ( ) && safeSubtreeListMatch ( node . thrownExceptions ( ) , o . thrownExceptions ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( MethodInvocation node , Object other ) { if ( ! ( other instanceof MethodInvocation ) ) { return false ; } MethodInvocation o = ( MethodInvocation ) other ; if ( node . getAST ( ) . apiLevel >= AST . JLS3 ) { if ( ! safeSubtreeListMatch ( node . typeArguments ( ) , o . typeArguments ( ) ) ) { return false ; } } return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . arguments ( ) , o . arguments ( ) ) ) ; } public boolean match ( Modifier node , Object other ) { if ( ! ( other instanceof Modifier ) ) { return false ; } Modifier o = ( Modifier ) other ; return ( node . getKeyword ( ) == o . getKeyword ( ) ) ; } public boolean match ( NormalAnnotation node , Object other ) { if ( ! ( other instanceof NormalAnnotation ) ) { return false ; } NormalAnnotation o = ( NormalAnnotation ) other ; return ( safeSubtreeMatch ( node . getTypeName ( ) , o . getTypeName ( ) ) && safeSubtreeListMatch ( node . values ( ) , o . values ( ) ) ) ; } public boolean match ( NullLiteral node , Object other ) { if ( ! ( other instanceof NullLiteral ) ) { return false ; } return true ; } public boolean match ( NumberLiteral node , Object other ) { if ( ! ( other instanceof NumberLiteral ) ) { return false ; } NumberLiteral o = ( NumberLiteral ) other ; return safeEquals ( node . getToken ( ) , o . getToken ( ) ) ; } public boolean match ( PackageDeclaration node , Object other ) { if ( ! ( other instanceof PackageDeclaration ) ) { return false ; } PackageDeclaration o = ( PackageDeclaration ) other ; if ( node . getAST ( ) . apiLevel >= AST . JLS3 ) { if ( ! safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) ) { return false ; } if ( ! safeSubtreeListMatch ( node . annotations ( ) , o . annotations ( ) ) ) { return false ; } } return safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) ; } public boolean match ( ParameterizedType node , Object other ) { if ( ! ( other instanceof ParameterizedType ) ) { return false ; } ParameterizedType o = ( ParameterizedType ) other ; return safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeListMatch ( node . typeArguments ( ) , o . typeArguments ( ) ) ; } public boolean match ( ParenthesizedExpression node , Object other ) { if ( ! ( other instanceof ParenthesizedExpression ) ) { return false ; } ParenthesizedExpression o = ( ParenthesizedExpression ) other ; return safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) ; } public boolean match ( PostfixExpression node , Object other ) { if ( ! ( other instanceof PostfixExpression ) ) { return false ; } PostfixExpression o = ( PostfixExpression ) other ; return ( node . getOperator ( ) . equals ( o . getOperator ( ) ) && safeSubtreeMatch ( node . getOperand ( ) , o . getOperand ( ) ) ) ; } public boolean match ( PrefixExpression node , Object other ) { if ( ! ( other instanceof PrefixExpression ) ) { return false ; } PrefixExpression o = ( PrefixExpression ) other ; return ( node . getOperator ( ) . equals ( o . getOperator ( ) ) && safeSubtreeMatch ( node . getOperand ( ) , o . getOperand ( ) ) ) ; } public boolean match ( PrimitiveType node , Object other ) { if ( ! ( other instanceof PrimitiveType ) ) { return false ; } PrimitiveType o = ( PrimitiveType ) other ; return ( node . getPrimitiveTypeCode ( ) == o . getPrimitiveTypeCode ( ) ) ; } public boolean match ( QualifiedName node , Object other ) { if ( ! ( other instanceof QualifiedName ) ) { return false ; } QualifiedName o = ( QualifiedName ) other ; return ( safeSubtreeMatch ( node . getQualifier ( ) , o . getQualifier ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) ) ; } public boolean match ( QualifiedType node , Object other ) { if ( ! ( other instanceof QualifiedType ) ) { return false ; } QualifiedType o = ( QualifiedType ) other ; return ( safeSubtreeMatch ( node . getQualifier ( ) , o . getQualifier ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) ) ; } public boolean match ( ReturnStatement node , Object other ) { if ( ! ( other instanceof ReturnStatement ) ) { return false ; } ReturnStatement o = ( ReturnStatement ) other ; return safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) ; } public boolean match ( SimpleName node , Object other ) { if ( ! ( other instanceof SimpleName ) ) { return false ; } SimpleName o = ( SimpleName ) other ; return node . getIdentifier ( ) . equals ( o . getIdentifier ( ) ) ; } public boolean match ( SimpleType node , Object other ) { if ( ! ( other instanceof SimpleType ) ) { return false ; } SimpleType o = ( SimpleType ) other ; return safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) ; } public boolean match ( SingleMemberAnnotation node , Object other ) { if ( ! ( other instanceof SingleMemberAnnotation ) ) { return false ; } SingleMemberAnnotation o = ( SingleMemberAnnotation ) other ; return ( safeSubtreeMatch ( node . getTypeName ( ) , o . getTypeName ( ) ) && safeSubtreeMatch ( node . getValue ( ) , o . getValue ( ) ) ) ; } public boolean match ( SingleVariableDeclaration node , Object other ) { if ( ! ( other instanceof SingleVariableDeclaration ) ) { return false ; } SingleVariableDeclaration o = ( SingleVariableDeclaration ) other ; int level = node . getAST ( ) . apiLevel ; if ( level == AST . JLS2_INTERNAL ) { if ( node . getModifiers ( ) != o . getModifiers ( ) ) { return false ; } } if ( level >= AST . JLS3 ) { if ( ! safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) ) { return false ; } if ( node . isVarargs ( ) != o . isVarargs ( ) ) { return false ; } } return safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && node . getExtraDimensions ( ) == o . getExtraDimensions ( ) && safeSubtreeMatch ( node . getInitializer ( ) , o . getInitializer ( ) ) ; } public boolean match ( StringLiteral node , Object other ) { if ( ! ( other instanceof StringLiteral ) ) { return false ; } StringLiteral o = ( StringLiteral ) other ; return safeEquals ( node . getEscapedValue ( ) , o . getEscapedValue ( ) ) ; } public boolean match ( SuperConstructorInvocation node , Object other ) { if ( ! ( other instanceof SuperConstructorInvocation ) ) { return false ; } SuperConstructorInvocation o = ( SuperConstructorInvocation ) other ; if ( node . getAST ( ) . apiLevel >= AST . JLS3 ) { if ( ! safeSubtreeListMatch ( node . typeArguments ( ) , o . typeArguments ( ) ) ) { return false ; } } return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeListMatch ( node . arguments ( ) , o . arguments ( ) ) ) ; } public boolean match ( SuperFieldAccess node , Object other ) { if ( ! ( other instanceof SuperFieldAccess ) ) { return false ; } SuperFieldAccess o = ( SuperFieldAccess ) other ; return ( safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeMatch ( node . getQualifier ( ) , o . getQualifier ( ) ) ) ; } public boolean match ( SuperMethodInvocation node , Object other ) { if ( ! ( other instanceof SuperMethodInvocation ) ) { return false ; } SuperMethodInvocation o = ( SuperMethodInvocation ) other ; if ( node . getAST ( ) . apiLevel >= AST . JLS3 ) { if ( ! safeSubtreeListMatch ( node . typeArguments ( ) , o . typeArguments ( ) ) ) { return false ; } } return ( safeSubtreeMatch ( node . getQualifier ( ) , o . getQualifier ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . arguments ( ) , o . arguments ( ) ) ) ; } public boolean match ( SwitchCase node , Object other ) { if ( ! ( other instanceof SwitchCase ) ) { return false ; } SwitchCase o = ( SwitchCase ) other ; return safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) ; } public boolean match ( SwitchStatement node , Object other ) { if ( ! ( other instanceof SwitchStatement ) ) { return false ; } SwitchStatement o = ( SwitchStatement ) other ; return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeListMatch ( node . statements ( ) , o . statements ( ) ) ) ; } public boolean match ( SynchronizedStatement node , Object other ) { if ( ! ( other instanceof SynchronizedStatement ) ) { return false ; } SynchronizedStatement o = ( SynchronizedStatement ) other ; return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( TagElement node , Object other ) { if ( ! ( other instanceof TagElement ) ) { return false ; } TagElement o = ( TagElement ) other ; return ( safeEquals ( node . getTagName ( ) , o . getTagName ( ) ) && safeSubtreeListMatch ( node . fragments ( ) , o . fragments ( ) ) ) ; } public boolean match ( TextElement node , Object other ) { if ( ! ( other instanceof TextElement ) ) { return false ; } TextElement o = ( TextElement ) other ; return safeEquals ( node . getText ( ) , o . getText ( ) ) ; } public boolean match ( ThisExpression node , Object other ) { if ( ! ( other instanceof ThisExpression ) ) { return false ; } ThisExpression o = ( ThisExpression ) other ; return safeSubtreeMatch ( node . getQualifier ( ) , o . getQualifier ( ) ) ; } public boolean match ( ThrowStatement node , Object other ) { if ( ! ( other instanceof ThrowStatement ) ) { return false ; } ThrowStatement o = ( ThrowStatement ) other ; return safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) ; } public boolean match ( TryStatement node , Object other ) { if ( ! ( other instanceof TryStatement ) ) { return false ; } TryStatement o = ( TryStatement ) other ; return ( safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) && safeSubtreeListMatch ( node . catchClauses ( ) , o . catchClauses ( ) ) && safeSubtreeMatch ( node . getFinally ( ) , o . getFinally ( ) ) ) ; } public boolean match ( TypeDeclaration node , Object other ) { if ( ! ( other instanceof TypeDeclaration ) ) { return false ; } TypeDeclaration o = ( TypeDeclaration ) other ; int level = node . getAST ( ) . apiLevel ; if ( level == AST . JLS2_INTERNAL ) { if ( node . getModifiers ( ) != o . getModifiers ( ) ) { return false ; } if ( ! safeSubtreeMatch ( node . internalGetSuperclass ( ) , o . internalGetSuperclass ( ) ) ) { return false ; } if ( ! safeSubtreeListMatch ( node . internalSuperInterfaces ( ) , o . internalSuperInterfaces ( ) ) ) { return false ; } } if ( level >= AST . JLS3 ) { if ( ! safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) ) { return false ; } if ( ! safeSubtreeListMatch ( node . typeParameters ( ) , o . typeParameters ( ) ) ) { return false ; } if ( ! safeSubtreeMatch ( node . getSuperclassType ( ) , o . getSuperclassType ( ) ) ) { return false ; } if ( ! safeSubtreeListMatch ( node . superInterfaceTypes ( ) , o . superInterfaceTypes ( ) ) ) { return false ; } } return ( ( node . isInterface ( ) == o . isInterface ( ) ) && safeSubtreeMatch ( node . getJavadoc ( ) , o . getJavadoc ( ) ) && safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . bodyDeclarations ( ) , o . bodyDeclarations ( ) ) ) ; } public boolean match ( TypeDeclarationStatement node , Object other ) { if ( ! ( other instanceof TypeDeclarationStatement ) ) { return false ; } TypeDeclarationStatement o = ( TypeDeclarationStatement ) other ; return safeSubtreeMatch ( node . getDeclaration ( ) , o . getDeclaration ( ) ) ; } public boolean match ( TypeLiteral node , Object other ) { if ( ! ( other instanceof TypeLiteral ) ) { return false ; } TypeLiteral o = ( TypeLiteral ) other ; return safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) ; } public boolean match ( TypeParameter node , Object other ) { if ( ! ( other instanceof TypeParameter ) ) { return false ; } TypeParameter o = ( TypeParameter ) other ; return safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && safeSubtreeListMatch ( node . typeBounds ( ) , o . typeBounds ( ) ) ; } public boolean match ( VariableDeclarationExpression node , Object other ) { if ( ! ( other instanceof VariableDeclarationExpression ) ) { return false ; } VariableDeclarationExpression o = ( VariableDeclarationExpression ) other ; int level = node . getAST ( ) . apiLevel ; if ( level == AST . JLS2_INTERNAL ) { if ( node . getModifiers ( ) != o . getModifiers ( ) ) { return false ; } } if ( level >= AST . JLS3 ) { if ( ! safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) ) { return false ; } } return safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeListMatch ( node . fragments ( ) , o . fragments ( ) ) ; } public boolean match ( VariableDeclarationFragment node , Object other ) { if ( ! ( other instanceof VariableDeclarationFragment ) ) { return false ; } VariableDeclarationFragment o = ( VariableDeclarationFragment ) other ; return safeSubtreeMatch ( node . getName ( ) , o . getName ( ) ) && node . getExtraDimensions ( ) == o . getExtraDimensions ( ) && safeSubtreeMatch ( node . getInitializer ( ) , o . getInitializer ( ) ) ; } public boolean match ( VariableDeclarationStatement node , Object other ) { if ( ! ( other instanceof VariableDeclarationStatement ) ) { return false ; } VariableDeclarationStatement o = ( VariableDeclarationStatement ) other ; int level = node . getAST ( ) . apiLevel ; if ( level == AST . JLS2_INTERNAL ) { if ( node . getModifiers ( ) != o . getModifiers ( ) ) { return false ; } } if ( level >= AST . JLS3 ) { if ( ! safeSubtreeListMatch ( node . modifiers ( ) , o . modifiers ( ) ) ) { return false ; } } return safeSubtreeMatch ( node . getType ( ) , o . getType ( ) ) && safeSubtreeListMatch ( node . fragments ( ) , o . fragments ( ) ) ; } public boolean match ( WhileStatement node , Object other ) { if ( ! ( other instanceof WhileStatement ) ) { return false ; } WhileStatement o = ( WhileStatement ) other ; return ( safeSubtreeMatch ( node . getExpression ( ) , o . getExpression ( ) ) && safeSubtreeMatch ( node . getBody ( ) , o . getBody ( ) ) ) ; } public boolean match ( WildcardType node , Object other ) { if ( ! ( other instanceof WildcardType ) ) { return false ; } WildcardType o = ( WildcardType ) other ; return node . isUpperBound ( ) == o . isUpperBound ( ) && safeSubtreeMatch ( node . getBound ( ) , o . getBound ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . HashSet ; import java . util . Iterator ; import java . util . List ; import java . util . Map ; import java . util . Set ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . OperationCanceledException ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . compiler . IProblem ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . core . dom . Modifier . ModifierKeyword ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . AbstractVariableDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Argument ; import org . eclipse . jdt . internal . compiler . ast . ForeachStatement ; import org . eclipse . jdt . internal . compiler . ast . JavadocArgumentExpression ; import org . eclipse . jdt . internal . compiler . ast . JavadocFieldReference ; import org . eclipse . jdt . internal . compiler . ast . JavadocMessageSend ; import org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ; import org . eclipse . jdt . internal . compiler . ast . MessageSend ; import org . eclipse . jdt . internal . compiler . ast . OperatorIds ; import org . eclipse . jdt . internal . compiler . ast . ParameterizedQualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . ParameterizedSingleTypeReference ; import org . eclipse . jdt . internal . compiler . ast . QualifiedAllocationExpression ; import org . eclipse . jdt . internal . compiler . ast . QualifiedTypeReference ; import org . eclipse . jdt . internal . compiler . ast . SingleNameReference ; import org . eclipse . jdt . internal . compiler . ast . SingleTypeReference ; import org . eclipse . jdt . internal . compiler . ast . StringLiteralConcatenation ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; import org . eclipse . jdt . internal . compiler . ast . Wildcard ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . lookup . BlockScope ; import org . eclipse . jdt . internal . compiler . lookup . CompilationUnitScope ; import org . eclipse . jdt . internal . compiler . lookup . ExtraCompilerModifiers ; import org . eclipse . jdt . internal . compiler . lookup . Scope ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . compiler . parser . RecoveryScanner ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; import org . eclipse . jdt . internal . core . util . Util ; class ASTConverter { protected AST ast ; protected Comment [ ] commentsTable ; char [ ] compilationUnitSource ; int compilationUnitSourceLength ; protected DocCommentParser docParser ; protected boolean insideComments ; protected IProgressMonitor monitor ; protected Set pendingNameScopeResolution ; protected Set pendingThisExpressionScopeResolution ; protected boolean resolveBindings ; Scanner scanner ; private DefaultCommentMapper commentMapper ; private boolean scannerUsable = true ; public ASTConverter ( Map options , boolean resolveBindings , IProgressMonitor monitor ) { this . resolveBindings = resolveBindings ; Object sourceModeSetting = options . get ( JavaCore . COMPILER_SOURCE ) ; long sourceLevel = CompilerOptions . versionToJdkLevel ( sourceModeSetting ) ; if ( sourceLevel == <NUM_LIT:0> ) { sourceLevel = ClassFileConstants . JDK1_3 ; } this . scanner = new Scanner ( true , false , false , sourceLevel , null , null , true ) ; this . monitor = monitor ; this . insideComments = JavaCore . ENABLED . equals ( options . get ( JavaCore . COMPILER_DOC_COMMENT_SUPPORT ) ) ; } protected void adjustSourcePositionsForParent ( org . eclipse . jdt . internal . compiler . ast . Expression expression ) { int start = expression . sourceStart ; int end = expression . sourceEnd ; int leftParentCount = <NUM_LIT:1> ; int rightParentCount = <NUM_LIT:0> ; this . scanner . resetTo ( start , end ) ; try { int token = this . scanner . getNextToken ( ) ; expression . sourceStart = this . scanner . currentPosition ; boolean stop = false ; while ( ! stop && ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) ) { switch ( token ) { case TerminalTokens . TokenNameLPAREN : leftParentCount ++ ; break ; case TerminalTokens . TokenNameRPAREN : rightParentCount ++ ; if ( rightParentCount == leftParentCount ) { stop = true ; } } } expression . sourceEnd = this . scanner . startPosition - <NUM_LIT:1> ; } catch ( InvalidInputException e ) { } } protected void buildBodyDeclarations ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration typeDeclaration , AbstractTypeDeclaration typeDecl ) { org . eclipse . jdt . internal . compiler . ast . TypeDeclaration [ ] members = typeDeclaration . memberTypes ; org . eclipse . jdt . internal . compiler . ast . FieldDeclaration [ ] fields = typeDeclaration . fields ; org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration [ ] methods = typeDeclaration . methods ; int fieldsLength = fields == null ? <NUM_LIT:0> : fields . length ; int methodsLength = methods == null ? <NUM_LIT:0> : methods . length ; int membersLength = members == null ? <NUM_LIT:0> : members . length ; int fieldsIndex = <NUM_LIT:0> ; int methodsIndex = <NUM_LIT:0> ; int membersIndex = <NUM_LIT:0> ; while ( ( fieldsIndex < fieldsLength ) || ( membersIndex < membersLength ) || ( methodsIndex < methodsLength ) ) { org . eclipse . jdt . internal . compiler . ast . FieldDeclaration nextFieldDeclaration = null ; org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration nextMethodDeclaration = null ; org . eclipse . jdt . internal . compiler . ast . TypeDeclaration nextMemberDeclaration = null ; int position = Integer . MAX_VALUE ; int nextDeclarationType = - <NUM_LIT:1> ; if ( fieldsIndex < fieldsLength ) { nextFieldDeclaration = fields [ fieldsIndex ] ; if ( nextFieldDeclaration . declarationSourceStart < position ) { position = nextFieldDeclaration . declarationSourceStart ; nextDeclarationType = <NUM_LIT:0> ; } } if ( methodsIndex < methodsLength ) { nextMethodDeclaration = methods [ methodsIndex ] ; if ( nextMethodDeclaration . declarationSourceStart < position ) { position = nextMethodDeclaration . declarationSourceStart ; nextDeclarationType = <NUM_LIT:1> ; } } if ( membersIndex < membersLength ) { nextMemberDeclaration = members [ membersIndex ] ; if ( nextMemberDeclaration . declarationSourceStart < position ) { position = nextMemberDeclaration . declarationSourceStart ; nextDeclarationType = <NUM_LIT:2> ; } } switch ( nextDeclarationType ) { case <NUM_LIT:0> : if ( nextFieldDeclaration . getKind ( ) == AbstractVariableDeclaration . ENUM_CONSTANT ) { typeDecl . bodyDeclarations ( ) . add ( convert ( nextFieldDeclaration ) ) ; } else { checkAndAddMultipleFieldDeclaration ( fields , fieldsIndex , typeDecl . bodyDeclarations ( ) ) ; } fieldsIndex ++ ; break ; case <NUM_LIT:1> : methodsIndex ++ ; if ( ! nextMethodDeclaration . isDefaultConstructor ( ) && ! nextMethodDeclaration . isClinit ( ) ) { boolean originalValue = this . scannerUsable ; try { this . scannerUsable = typeDeclaration . isScannerUsableOnThisDeclaration ( ) ; typeDecl . bodyDeclarations ( ) . add ( convert ( nextMethodDeclaration ) ) ; } finally { this . scannerUsable = originalValue ; } } break ; case <NUM_LIT:2> : membersIndex ++ ; ASTNode node = convert ( nextMemberDeclaration ) ; if ( node == null ) { typeDecl . setFlags ( typeDecl . getFlags ( ) | ASTNode . MALFORMED ) ; } else { typeDecl . bodyDeclarations ( ) . add ( node ) ; } } } convert ( typeDeclaration . javadoc , typeDecl ) ; } protected void buildBodyDeclarations ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration enumDeclaration2 , EnumDeclaration enumDeclaration ) { org . eclipse . jdt . internal . compiler . ast . TypeDeclaration [ ] members = enumDeclaration2 . memberTypes ; org . eclipse . jdt . internal . compiler . ast . FieldDeclaration [ ] fields = enumDeclaration2 . fields ; org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration [ ] methods = enumDeclaration2 . methods ; int fieldsLength = fields == null ? <NUM_LIT:0> : fields . length ; int methodsLength = methods == null ? <NUM_LIT:0> : methods . length ; int membersLength = members == null ? <NUM_LIT:0> : members . length ; int fieldsIndex = <NUM_LIT:0> ; int methodsIndex = <NUM_LIT:0> ; int membersIndex = <NUM_LIT:0> ; while ( ( fieldsIndex < fieldsLength ) || ( membersIndex < membersLength ) || ( methodsIndex < methodsLength ) ) { org . eclipse . jdt . internal . compiler . ast . FieldDeclaration nextFieldDeclaration = null ; org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration nextMethodDeclaration = null ; org . eclipse . jdt . internal . compiler . ast . TypeDeclaration nextMemberDeclaration = null ; int position = Integer . MAX_VALUE ; int nextDeclarationType = - <NUM_LIT:1> ; if ( fieldsIndex < fieldsLength ) { nextFieldDeclaration = fields [ fieldsIndex ] ; if ( nextFieldDeclaration . declarationSourceStart < position ) { position = nextFieldDeclaration . declarationSourceStart ; nextDeclarationType = <NUM_LIT:0> ; } } if ( methodsIndex < methodsLength ) { nextMethodDeclaration = methods [ methodsIndex ] ; if ( nextMethodDeclaration . declarationSourceStart < position ) { position = nextMethodDeclaration . declarationSourceStart ; nextDeclarationType = <NUM_LIT:1> ; } } if ( membersIndex < membersLength ) { nextMemberDeclaration = members [ membersIndex ] ; if ( nextMemberDeclaration . declarationSourceStart < position ) { position = nextMemberDeclaration . declarationSourceStart ; nextDeclarationType = <NUM_LIT:2> ; } } switch ( nextDeclarationType ) { case <NUM_LIT:0> : if ( nextFieldDeclaration . getKind ( ) == AbstractVariableDeclaration . ENUM_CONSTANT ) { enumDeclaration . enumConstants ( ) . add ( convert ( nextFieldDeclaration ) ) ; } else { checkAndAddMultipleFieldDeclaration ( fields , fieldsIndex , enumDeclaration . bodyDeclarations ( ) ) ; } fieldsIndex ++ ; break ; case <NUM_LIT:1> : methodsIndex ++ ; if ( ! nextMethodDeclaration . isDefaultConstructor ( ) && ! nextMethodDeclaration . isClinit ( ) ) { enumDeclaration . bodyDeclarations ( ) . add ( convert ( nextMethodDeclaration ) ) ; } break ; case <NUM_LIT:2> : membersIndex ++ ; enumDeclaration . bodyDeclarations ( ) . add ( convert ( nextMemberDeclaration ) ) ; break ; } } convert ( enumDeclaration2 . javadoc , enumDeclaration ) ; } protected void buildBodyDeclarations ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration expression , AnonymousClassDeclaration anonymousClassDeclaration ) { org . eclipse . jdt . internal . compiler . ast . TypeDeclaration [ ] members = expression . memberTypes ; org . eclipse . jdt . internal . compiler . ast . FieldDeclaration [ ] fields = expression . fields ; org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration [ ] methods = expression . methods ; int fieldsLength = fields == null ? <NUM_LIT:0> : fields . length ; int methodsLength = methods == null ? <NUM_LIT:0> : methods . length ; int membersLength = members == null ? <NUM_LIT:0> : members . length ; int fieldsIndex = <NUM_LIT:0> ; int methodsIndex = <NUM_LIT:0> ; int membersIndex = <NUM_LIT:0> ; while ( ( fieldsIndex < fieldsLength ) || ( membersIndex < membersLength ) || ( methodsIndex < methodsLength ) ) { org . eclipse . jdt . internal . compiler . ast . FieldDeclaration nextFieldDeclaration = null ; org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration nextMethodDeclaration = null ; org . eclipse . jdt . internal . compiler . ast . TypeDeclaration nextMemberDeclaration = null ; int position = Integer . MAX_VALUE ; int nextDeclarationType = - <NUM_LIT:1> ; if ( fieldsIndex < fieldsLength ) { nextFieldDeclaration = fields [ fieldsIndex ] ; if ( nextFieldDeclaration . declarationSourceStart < position ) { position = nextFieldDeclaration . declarationSourceStart ; nextDeclarationType = <NUM_LIT:0> ; } } if ( methodsIndex < methodsLength ) { nextMethodDeclaration = methods [ methodsIndex ] ; if ( nextMethodDeclaration . declarationSourceStart < position ) { position = nextMethodDeclaration . declarationSourceStart ; nextDeclarationType = <NUM_LIT:1> ; } } if ( membersIndex < membersLength ) { nextMemberDeclaration = members [ membersIndex ] ; if ( nextMemberDeclaration . declarationSourceStart < position ) { position = nextMemberDeclaration . declarationSourceStart ; nextDeclarationType = <NUM_LIT:2> ; } } switch ( nextDeclarationType ) { case <NUM_LIT:0> : if ( nextFieldDeclaration . getKind ( ) == AbstractVariableDeclaration . ENUM_CONSTANT ) { anonymousClassDeclaration . bodyDeclarations ( ) . add ( convert ( nextFieldDeclaration ) ) ; } else { checkAndAddMultipleFieldDeclaration ( fields , fieldsIndex , anonymousClassDeclaration . bodyDeclarations ( ) ) ; } fieldsIndex ++ ; break ; case <NUM_LIT:1> : methodsIndex ++ ; if ( ! nextMethodDeclaration . isDefaultConstructor ( ) && ! nextMethodDeclaration . isClinit ( ) ) { anonymousClassDeclaration . bodyDeclarations ( ) . add ( convert ( nextMethodDeclaration ) ) ; } break ; case <NUM_LIT:2> : membersIndex ++ ; ASTNode node = convert ( nextMemberDeclaration ) ; if ( node == null ) { anonymousClassDeclaration . setFlags ( anonymousClassDeclaration . getFlags ( ) | ASTNode . MALFORMED ) ; } else { anonymousClassDeclaration . bodyDeclarations ( ) . add ( node ) ; } } } } void buildCommentsTable ( CompilationUnit compilationUnit , int [ ] [ ] comments ) { this . commentsTable = new Comment [ comments . length ] ; int nbr = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < comments . length ; i ++ ) { Comment comment = createComment ( comments [ i ] ) ; if ( comment != null ) { comment . setAlternateRoot ( compilationUnit ) ; this . commentsTable [ nbr ++ ] = comment ; } } if ( nbr < comments . length ) { Comment [ ] newCommentsTable = new Comment [ nbr ] ; System . arraycopy ( this . commentsTable , <NUM_LIT:0> , newCommentsTable , <NUM_LIT:0> , nbr ) ; this . commentsTable = newCommentsTable ; } compilationUnit . setCommentTable ( this . commentsTable ) ; } protected void checkAndAddMultipleFieldDeclaration ( org . eclipse . jdt . internal . compiler . ast . FieldDeclaration [ ] fields , int index , List bodyDeclarations ) { if ( fields [ index ] instanceof org . eclipse . jdt . internal . compiler . ast . Initializer ) { org . eclipse . jdt . internal . compiler . ast . Initializer oldInitializer = ( org . eclipse . jdt . internal . compiler . ast . Initializer ) fields [ index ] ; Initializer initializer = new Initializer ( this . ast ) ; initializer . setBody ( convert ( oldInitializer . block ) ) ; setModifiers ( initializer , oldInitializer ) ; initializer . setSourceRange ( oldInitializer . declarationSourceStart , oldInitializer . sourceEnd - oldInitializer . declarationSourceStart + <NUM_LIT:1> ) ; convert ( oldInitializer . javadoc , initializer ) ; bodyDeclarations . add ( initializer ) ; return ; } if ( index > <NUM_LIT:0> && fields [ index - <NUM_LIT:1> ] . declarationSourceStart == fields [ index ] . declarationSourceStart ) { FieldDeclaration fieldDeclaration = ( FieldDeclaration ) bodyDeclarations . get ( bodyDeclarations . size ( ) - <NUM_LIT:1> ) ; fieldDeclaration . fragments ( ) . add ( convertToVariableDeclarationFragment ( fields [ index ] ) ) ; } else { bodyDeclarations . add ( convertToFieldDeclaration ( fields [ index ] ) ) ; } } protected void checkAndAddMultipleLocalDeclaration ( org . eclipse . jdt . internal . compiler . ast . Statement [ ] stmts , int index , List blockStatements ) { if ( index > <NUM_LIT:0> && stmts [ index - <NUM_LIT:1> ] instanceof org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ) { org . eclipse . jdt . internal . compiler . ast . LocalDeclaration local1 = ( org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ) stmts [ index - <NUM_LIT:1> ] ; org . eclipse . jdt . internal . compiler . ast . LocalDeclaration local2 = ( org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ) stmts [ index ] ; if ( local1 . declarationSourceStart == local2 . declarationSourceStart ) { VariableDeclarationStatement variableDeclarationStatement = ( VariableDeclarationStatement ) blockStatements . get ( blockStatements . size ( ) - <NUM_LIT:1> ) ; variableDeclarationStatement . fragments ( ) . add ( convertToVariableDeclarationFragment ( ( org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ) stmts [ index ] ) ) ; } else { blockStatements . add ( convertToVariableDeclarationStatement ( ( org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ) stmts [ index ] ) ) ; } } else { blockStatements . add ( convertToVariableDeclarationStatement ( ( org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ) stmts [ index ] ) ) ; } } protected void checkCanceled ( ) { if ( this . monitor != null && this . monitor . isCanceled ( ) ) throw new OperationCanceledException ( ) ; } protected void completeRecord ( ArrayType arrayType , org . eclipse . jdt . internal . compiler . ast . ASTNode astNode ) { ArrayType array = arrayType ; int dimensions = array . getDimensions ( ) ; for ( int i = <NUM_LIT:0> ; i < dimensions ; i ++ ) { Type componentType = array . getComponentType ( ) ; this . recordNodes ( componentType , astNode ) ; if ( componentType . isArrayType ( ) ) { array = ( ArrayType ) componentType ; } } } public ASTNode convert ( org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration methodDeclaration ) { checkCanceled ( ) ; if ( methodDeclaration instanceof org . eclipse . jdt . internal . compiler . ast . AnnotationMethodDeclaration ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . AnnotationMethodDeclaration ) methodDeclaration ) ; } MethodDeclaration methodDecl = new MethodDeclaration ( this . ast ) ; setModifiers ( methodDecl , methodDeclaration ) ; boolean isConstructor = methodDeclaration . isConstructor ( ) ; methodDecl . setConstructor ( isConstructor ) ; final SimpleName methodName = new SimpleName ( this . ast ) ; methodName . internalSetIdentifier ( new String ( methodDeclaration . selector ) ) ; int start = methodDeclaration . sourceStart ; int end = ( scannerAvailable ( methodDeclaration . scope ) ? retrieveIdentifierEndPosition ( start , methodDeclaration . sourceEnd ) : methodDeclaration . sourceEnd ) ; methodName . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; methodDecl . setName ( methodName ) ; org . eclipse . jdt . internal . compiler . ast . TypeReference [ ] thrownExceptions = methodDeclaration . thrownExceptions ; int methodHeaderEnd = methodDeclaration . sourceEnd ; int thrownExceptionsLength = thrownExceptions == null ? <NUM_LIT:0> : thrownExceptions . length ; if ( thrownExceptionsLength > <NUM_LIT:0> ) { Name thrownException ; int i = <NUM_LIT:0> ; do { thrownException = convert ( thrownExceptions [ i ++ ] ) ; methodDecl . thrownExceptions ( ) . add ( thrownException ) ; } while ( i < thrownExceptionsLength ) ; methodHeaderEnd = thrownException . getStartPosition ( ) + thrownException . getLength ( ) ; } org . eclipse . jdt . internal . compiler . ast . Argument [ ] parameters = methodDeclaration . arguments ; int parametersLength = parameters == null ? <NUM_LIT:0> : parameters . length ; if ( parametersLength > <NUM_LIT:0> ) { SingleVariableDeclaration parameter ; int i = <NUM_LIT:0> ; do { BlockScope origScope = null ; if ( parameters [ i ] . binding != null ) { origScope = parameters [ i ] . binding . declaringScope ; parameters [ i ] . binding . declaringScope = methodDeclaration . scope ; } parameter = convert ( parameters [ i ++ ] ) ; if ( parameters [ i - <NUM_LIT:1> ] . binding != null ) { parameters [ i - <NUM_LIT:1> ] . binding . declaringScope = origScope ; } methodDecl . parameters ( ) . add ( parameter ) ; } while ( i < parametersLength ) ; if ( thrownExceptionsLength == <NUM_LIT:0> ) { methodHeaderEnd = parameter . getStartPosition ( ) + parameter . getLength ( ) ; } } org . eclipse . jdt . internal . compiler . ast . ExplicitConstructorCall explicitConstructorCall = null ; if ( isConstructor ) { org . eclipse . jdt . internal . compiler . ast . ConstructorDeclaration constructorDeclaration = ( org . eclipse . jdt . internal . compiler . ast . ConstructorDeclaration ) methodDeclaration ; explicitConstructorCall = constructorDeclaration . constructorCall ; switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : PrimitiveType returnType = new PrimitiveType ( this . ast ) ; returnType . setPrimitiveTypeCode ( PrimitiveType . VOID ) ; returnType . setSourceRange ( methodDeclaration . sourceStart , <NUM_LIT:0> ) ; methodDecl . internalSetReturnType ( returnType ) ; break ; case AST . JLS3 : methodDecl . setReturnType2 ( null ) ; } } else if ( methodDeclaration instanceof org . eclipse . jdt . internal . compiler . ast . MethodDeclaration ) { org . eclipse . jdt . internal . compiler . ast . MethodDeclaration method = ( org . eclipse . jdt . internal . compiler . ast . MethodDeclaration ) methodDeclaration ; org . eclipse . jdt . internal . compiler . ast . TypeReference typeReference = method . returnType ; if ( typeReference != null ) { Type returnType = convertType ( typeReference ) ; int rightParenthesisPosition = retrieveEndOfRightParenthesisPosition ( end , method . bodyEnd ) ; int extraDimensions = retrieveExtraDimension ( rightParenthesisPosition , method . bodyEnd ) ; methodDecl . setExtraDimensions ( extraDimensions ) ; setTypeForMethodDeclaration ( methodDecl , returnType , extraDimensions ) ; } else { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : methodDecl . setFlags ( methodDecl . getFlags ( ) | ASTNode . MALFORMED ) ; break ; case AST . JLS3 : methodDecl . setReturnType2 ( null ) ; } } } int declarationSourceStart = methodDeclaration . declarationSourceStart ; int declarationSourceEnd = methodDeclaration . bodyEnd ; methodDecl . setSourceRange ( declarationSourceStart , declarationSourceEnd - declarationSourceStart + <NUM_LIT:1> ) ; int closingPosition = retrieveRightBraceOrSemiColonPosition ( methodDeclaration . bodyEnd + <NUM_LIT:1> , methodDeclaration . declarationSourceEnd ) ; if ( closingPosition != - <NUM_LIT:1> ) { int startPosition = methodDecl . getStartPosition ( ) ; methodDecl . setSourceRange ( startPosition , closingPosition - startPosition + <NUM_LIT:1> ) ; org . eclipse . jdt . internal . compiler . ast . Statement [ ] statements = methodDeclaration . statements ; start = retrieveStartBlockPosition ( methodHeaderEnd , methodDeclaration . bodyStart ) ; if ( start == - <NUM_LIT:1> ) start = methodDeclaration . bodyStart ; end = retrieveRightBrace ( methodDeclaration . bodyEnd , methodDeclaration . declarationSourceEnd ) ; Block block = null ; if ( start != - <NUM_LIT:1> && end != - <NUM_LIT:1> ) { block = new Block ( this . ast ) ; block . setSourceRange ( start , closingPosition - start + <NUM_LIT:1> ) ; methodDecl . setBody ( block ) ; } if ( block != null && ( statements != null || explicitConstructorCall != null ) ) { if ( explicitConstructorCall != null && explicitConstructorCall . accessMode != org . eclipse . jdt . internal . compiler . ast . ExplicitConstructorCall . ImplicitSuper ) { block . statements ( ) . add ( convert ( explicitConstructorCall ) ) ; } int statementsLength = statements == null ? <NUM_LIT:0> : statements . length ; for ( int i = <NUM_LIT:0> ; i < statementsLength ; i ++ ) { if ( statements [ i ] instanceof org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ) { checkAndAddMultipleLocalDeclaration ( statements , i , block . statements ( ) ) ; } else { final Statement statement = convert ( statements [ i ] ) ; if ( statement != null ) { block . statements ( ) . add ( statement ) ; } } } } if ( block != null && ( Modifier . isAbstract ( methodDecl . getModifiers ( ) ) || Modifier . isNative ( methodDecl . getModifiers ( ) ) ) ) { methodDecl . setFlags ( methodDecl . getFlags ( ) | ASTNode . MALFORMED ) ; } } else { methodDecl . setFlags ( methodDecl . getFlags ( ) | ASTNode . MALFORMED ) ; if ( ! methodDeclaration . isNative ( ) && ! methodDeclaration . isAbstract ( ) ) { start = retrieveStartBlockPosition ( methodHeaderEnd , declarationSourceEnd ) ; if ( start == - <NUM_LIT:1> ) start = methodDeclaration . bodyStart ; end = methodDeclaration . bodyEnd ; CategorizedProblem [ ] problems = methodDeclaration . compilationResult ( ) . problems ; if ( problems != null ) { for ( int i = <NUM_LIT:0> , max = methodDeclaration . compilationResult ( ) . problemCount ; i < max ; i ++ ) { CategorizedProblem currentProblem = problems [ i ] ; if ( currentProblem . getSourceStart ( ) == start && currentProblem . getID ( ) == IProblem . ParsingErrorInsertToComplete ) { end = currentProblem . getSourceEnd ( ) ; break ; } } } int startPosition = methodDecl . getStartPosition ( ) ; methodDecl . setSourceRange ( startPosition , end - startPosition + <NUM_LIT:1> ) ; if ( start != - <NUM_LIT:1> && end != - <NUM_LIT:1> ) { Block block = new Block ( this . ast ) ; block . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; methodDecl . setBody ( block ) ; } } } org . eclipse . jdt . internal . compiler . ast . TypeParameter [ ] typeParameters = methodDeclaration . typeParameters ( ) ; if ( typeParameters != null ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : methodDecl . setFlags ( methodDecl . getFlags ( ) | ASTNode . MALFORMED ) ; break ; case AST . JLS3 : for ( int i = <NUM_LIT:0> , max = typeParameters . length ; i < max ; i ++ ) { methodDecl . typeParameters ( ) . add ( convert ( typeParameters [ i ] ) ) ; } } } convert ( methodDeclaration . javadoc , methodDecl ) ; if ( this . resolveBindings ) { recordNodes ( methodDecl , methodDeclaration ) ; recordNodes ( methodName , methodDeclaration ) ; methodDecl . resolveBinding ( ) ; } return methodDecl ; } private boolean scannerAvailable ( Scope scope ) { if ( ! scannerUsable ) { return false ; } if ( scope != null ) { CompilationUnitScope cuScope = scope . compilationUnitScope ( ) ; if ( cuScope != null ) { return cuScope . scannerAvailable ( ) ; } } return true ; } public ClassInstanceCreation convert ( org . eclipse . jdt . internal . compiler . ast . AllocationExpression expression ) { ClassInstanceCreation classInstanceCreation = new ClassInstanceCreation ( this . ast ) ; if ( this . resolveBindings ) { recordNodes ( classInstanceCreation , expression ) ; } if ( expression . typeArguments != null ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : classInstanceCreation . setFlags ( classInstanceCreation . getFlags ( ) | ASTNode . MALFORMED ) ; break ; case AST . JLS3 : for ( int i = <NUM_LIT:0> , max = expression . typeArguments . length ; i < max ; i ++ ) { classInstanceCreation . typeArguments ( ) . add ( convertType ( expression . typeArguments [ i ] ) ) ; } } } switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : classInstanceCreation . internalSetName ( convert ( expression . type ) ) ; break ; case AST . JLS3 : classInstanceCreation . setType ( convertType ( expression . type ) ) ; } classInstanceCreation . setSourceRange ( expression . sourceStart , expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ) ; org . eclipse . jdt . internal . compiler . ast . Expression [ ] arguments = expression . arguments ; if ( arguments != null ) { int length = arguments . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { classInstanceCreation . arguments ( ) . add ( convert ( arguments [ i ] ) ) ; } } removeTrailingCommentFromExpressionEndingWithAParen ( classInstanceCreation ) ; return classInstanceCreation ; } public Expression convert ( org . eclipse . jdt . internal . compiler . ast . AND_AND_Expression expression ) { InfixExpression infixExpression = new InfixExpression ( this . ast ) ; infixExpression . setOperator ( InfixExpression . Operator . CONDITIONAL_AND ) ; if ( this . resolveBindings ) { this . recordNodes ( infixExpression , expression ) ; } final int expressionOperatorID = ( expression . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorMASK ) > > org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorSHIFT ; if ( expression . left instanceof org . eclipse . jdt . internal . compiler . ast . BinaryExpression && ( ( expression . left . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedMASK ) == <NUM_LIT:0> ) ) { infixExpression . extendedOperands ( ) . add ( convert ( expression . right ) ) ; org . eclipse . jdt . internal . compiler . ast . Expression leftOperand = expression . left ; org . eclipse . jdt . internal . compiler . ast . Expression rightOperand = null ; do { rightOperand = ( ( org . eclipse . jdt . internal . compiler . ast . BinaryExpression ) leftOperand ) . right ; if ( ( ( ( leftOperand . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorMASK ) > > org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorSHIFT ) != expressionOperatorID && ( ( leftOperand . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedMASK ) == <NUM_LIT:0> ) ) || ( ( rightOperand instanceof org . eclipse . jdt . internal . compiler . ast . BinaryExpression && ( ( rightOperand . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorMASK ) > > org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorSHIFT ) != expressionOperatorID ) && ( ( rightOperand . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedMASK ) == <NUM_LIT:0> ) ) ) { List extendedOperands = infixExpression . extendedOperands ( ) ; InfixExpression temp = new InfixExpression ( this . ast ) ; if ( this . resolveBindings ) { this . recordNodes ( temp , expression ) ; } temp . setOperator ( getOperatorFor ( expressionOperatorID ) ) ; Expression leftSide = convert ( leftOperand ) ; temp . setLeftOperand ( leftSide ) ; temp . setSourceRange ( leftSide . getStartPosition ( ) , leftSide . getLength ( ) ) ; int size = extendedOperands . size ( ) ; for ( int i = <NUM_LIT:0> ; i < size - <NUM_LIT:1> ; i ++ ) { Expression expr = temp ; temp = new InfixExpression ( this . ast ) ; if ( this . resolveBindings ) { this . recordNodes ( temp , expression ) ; } temp . setLeftOperand ( expr ) ; temp . setOperator ( getOperatorFor ( expressionOperatorID ) ) ; temp . setSourceRange ( expr . getStartPosition ( ) , expr . getLength ( ) ) ; } infixExpression = temp ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { Expression extendedOperand = ( Expression ) extendedOperands . remove ( size - <NUM_LIT:1> - i ) ; temp . setRightOperand ( extendedOperand ) ; int startPosition = temp . getLeftOperand ( ) . getStartPosition ( ) ; temp . setSourceRange ( startPosition , extendedOperand . getStartPosition ( ) + extendedOperand . getLength ( ) - startPosition ) ; if ( temp . getLeftOperand ( ) . getNodeType ( ) == ASTNode . INFIX_EXPRESSION ) { temp = ( InfixExpression ) temp . getLeftOperand ( ) ; } } int startPosition = infixExpression . getLeftOperand ( ) . getStartPosition ( ) ; infixExpression . setSourceRange ( startPosition , expression . sourceEnd - startPosition + <NUM_LIT:1> ) ; if ( this . resolveBindings ) { this . recordNodes ( infixExpression , expression ) ; } return infixExpression ; } infixExpression . extendedOperands ( ) . add ( <NUM_LIT:0> , convert ( rightOperand ) ) ; leftOperand = ( ( org . eclipse . jdt . internal . compiler . ast . BinaryExpression ) leftOperand ) . left ; } while ( leftOperand instanceof org . eclipse . jdt . internal . compiler . ast . BinaryExpression && ( ( leftOperand . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedMASK ) == <NUM_LIT:0> ) ) ; Expression leftExpression = convert ( leftOperand ) ; infixExpression . setLeftOperand ( leftExpression ) ; infixExpression . setRightOperand ( ( Expression ) infixExpression . extendedOperands ( ) . remove ( <NUM_LIT:0> ) ) ; int startPosition = leftExpression . getStartPosition ( ) ; infixExpression . setSourceRange ( startPosition , expression . sourceEnd - startPosition + <NUM_LIT:1> ) ; return infixExpression ; } Expression leftExpression = convert ( expression . left ) ; infixExpression . setLeftOperand ( leftExpression ) ; infixExpression . setRightOperand ( convert ( expression . right ) ) ; infixExpression . setOperator ( InfixExpression . Operator . CONDITIONAL_AND ) ; int startPosition = leftExpression . getStartPosition ( ) ; infixExpression . setSourceRange ( startPosition , expression . sourceEnd - startPosition + <NUM_LIT:1> ) ; return infixExpression ; } private AnnotationTypeDeclaration convertToAnnotationDeclaration ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration typeDeclaration ) { checkCanceled ( ) ; if ( this . scanner . sourceLevel < ClassFileConstants . JDK1_5 ) return null ; AnnotationTypeDeclaration typeDecl = this . ast . newAnnotationTypeDeclaration ( ) ; setModifiers ( typeDecl , typeDeclaration ) ; final SimpleName typeName = new SimpleName ( this . ast ) ; typeName . internalSetIdentifier ( new String ( typeDeclaration . name ) ) ; typeName . setSourceRange ( typeDeclaration . sourceStart , typeDeclaration . sourceEnd - typeDeclaration . sourceStart + <NUM_LIT:1> ) ; typeDecl . setName ( typeName ) ; typeDecl . setSourceRange ( typeDeclaration . declarationSourceStart , typeDeclaration . bodyEnd - typeDeclaration . declarationSourceStart + <NUM_LIT:1> ) ; buildBodyDeclarations ( typeDeclaration , typeDecl ) ; if ( this . resolveBindings ) { recordNodes ( typeDecl , typeDeclaration ) ; recordNodes ( typeName , typeDeclaration ) ; typeDecl . resolveBinding ( ) ; } return typeDecl ; } public ASTNode convert ( org . eclipse . jdt . internal . compiler . ast . AnnotationMethodDeclaration annotationTypeMemberDeclaration ) { checkCanceled ( ) ; if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { return null ; } AnnotationTypeMemberDeclaration annotationTypeMemberDeclaration2 = new AnnotationTypeMemberDeclaration ( this . ast ) ; setModifiers ( annotationTypeMemberDeclaration2 , annotationTypeMemberDeclaration ) ; final SimpleName methodName = new SimpleName ( this . ast ) ; methodName . internalSetIdentifier ( new String ( annotationTypeMemberDeclaration . selector ) ) ; int start = annotationTypeMemberDeclaration . sourceStart ; int end = retrieveIdentifierEndPosition ( start , annotationTypeMemberDeclaration . sourceEnd ) ; methodName . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; annotationTypeMemberDeclaration2 . setName ( methodName ) ; org . eclipse . jdt . internal . compiler . ast . TypeReference typeReference = annotationTypeMemberDeclaration . returnType ; if ( typeReference != null ) { Type returnType = convertType ( typeReference ) ; setTypeForMethodDeclaration ( annotationTypeMemberDeclaration2 , returnType , <NUM_LIT:0> ) ; } int declarationSourceStart = annotationTypeMemberDeclaration . declarationSourceStart ; int declarationSourceEnd = annotationTypeMemberDeclaration . bodyEnd ; annotationTypeMemberDeclaration2 . setSourceRange ( declarationSourceStart , declarationSourceEnd - declarationSourceStart + <NUM_LIT:1> ) ; convert ( annotationTypeMemberDeclaration . javadoc , annotationTypeMemberDeclaration2 ) ; org . eclipse . jdt . internal . compiler . ast . Expression memberValue = annotationTypeMemberDeclaration . defaultValue ; if ( memberValue != null ) { annotationTypeMemberDeclaration2 . setDefault ( convert ( memberValue ) ) ; } if ( this . resolveBindings ) { recordNodes ( annotationTypeMemberDeclaration2 , annotationTypeMemberDeclaration ) ; recordNodes ( methodName , annotationTypeMemberDeclaration ) ; annotationTypeMemberDeclaration2 . resolveBinding ( ) ; } return annotationTypeMemberDeclaration2 ; } public SingleVariableDeclaration convert ( org . eclipse . jdt . internal . compiler . ast . Argument argument ) { SingleVariableDeclaration variableDecl = new SingleVariableDeclaration ( this . ast ) ; setModifiers ( variableDecl , argument ) ; final SimpleName name = new SimpleName ( this . ast ) ; name . internalSetIdentifier ( new String ( argument . name ) ) ; int start = argument . sourceStart ; int nameEnd = argument . sourceEnd ; name . setSourceRange ( start , nameEnd - start + <NUM_LIT:1> ) ; variableDecl . setName ( name ) ; final int typeSourceEnd = argument . type . sourceEnd ; final int extraDimensions = retrieveExtraDimension ( nameEnd + <NUM_LIT:1> , typeSourceEnd ) ; variableDecl . setExtraDimensions ( extraDimensions ) ; final boolean isVarArgs = argument . isVarArgs ( ) ; if ( argument . binding != null && scannerAvailable ( argument . binding . declaringScope ) && isVarArgs && extraDimensions == <NUM_LIT:0> ) { argument . type . sourceEnd = retrieveEllipsisStartPosition ( argument . type . sourceStart , typeSourceEnd ) ; } Type type = convertType ( argument . type ) ; int typeEnd = type . getStartPosition ( ) + type . getLength ( ) - <NUM_LIT:1> ; int rightEnd = Math . max ( typeEnd , argument . declarationSourceEnd ) ; if ( isVarArgs ) { setTypeForSingleVariableDeclaration ( variableDecl , type , extraDimensions + <NUM_LIT:1> ) ; if ( extraDimensions != <NUM_LIT:0> ) { variableDecl . setFlags ( variableDecl . getFlags ( ) | ASTNode . MALFORMED ) ; } } else { setTypeForSingleVariableDeclaration ( variableDecl , type , extraDimensions ) ; } variableDecl . setSourceRange ( argument . declarationSourceStart , rightEnd - argument . declarationSourceStart + <NUM_LIT:1> ) ; if ( isVarArgs ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : variableDecl . setFlags ( variableDecl . getFlags ( ) | ASTNode . MALFORMED ) ; break ; case AST . JLS3 : variableDecl . setVarargs ( true ) ; } } if ( this . resolveBindings ) { recordNodes ( name , argument ) ; recordNodes ( variableDecl , argument ) ; variableDecl . resolveBinding ( ) ; } return variableDecl ; } public Annotation convert ( org . eclipse . jdt . internal . compiler . ast . Annotation annotation ) { if ( annotation instanceof org . eclipse . jdt . internal . compiler . ast . SingleMemberAnnotation ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . SingleMemberAnnotation ) annotation ) ; } else if ( annotation instanceof org . eclipse . jdt . internal . compiler . ast . MarkerAnnotation ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . MarkerAnnotation ) annotation ) ; } else { return convert ( ( org . eclipse . jdt . internal . compiler . ast . NormalAnnotation ) annotation ) ; } } public ArrayCreation convert ( org . eclipse . jdt . internal . compiler . ast . ArrayAllocationExpression expression ) { ArrayCreation arrayCreation = new ArrayCreation ( this . ast ) ; if ( this . resolveBindings ) { recordNodes ( arrayCreation , expression ) ; } arrayCreation . setSourceRange ( expression . sourceStart , expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ) ; org . eclipse . jdt . internal . compiler . ast . Expression [ ] dimensions = expression . dimensions ; int dimensionsLength = dimensions . length ; for ( int i = <NUM_LIT:0> ; i < dimensionsLength ; i ++ ) { if ( dimensions [ i ] != null ) { Expression dimension = convert ( dimensions [ i ] ) ; if ( this . resolveBindings ) { recordNodes ( dimension , dimensions [ i ] ) ; } arrayCreation . dimensions ( ) . add ( dimension ) ; } } Type type = convertType ( expression . type ) ; if ( this . resolveBindings ) { recordNodes ( type , expression . type ) ; } ArrayType arrayType = null ; if ( type . isArrayType ( ) ) { arrayType = ( ArrayType ) type ; } else { arrayType = this . ast . newArrayType ( type , dimensionsLength ) ; if ( this . resolveBindings ) { completeRecord ( arrayType , expression ) ; } int start = type . getStartPosition ( ) ; int end = type . getStartPosition ( ) + type . getLength ( ) ; int previousSearchStart = end - <NUM_LIT:1> ; ArrayType componentType = ( ArrayType ) type . getParent ( ) ; for ( int i = <NUM_LIT:0> ; i < dimensionsLength ; i ++ ) { previousSearchStart = retrieveRightBracketPosition ( previousSearchStart + <NUM_LIT:1> , this . compilationUnitSourceLength ) ; componentType . setSourceRange ( start , previousSearchStart - start + <NUM_LIT:1> ) ; componentType = ( ArrayType ) componentType . getParent ( ) ; } } arrayCreation . setType ( arrayType ) ; if ( this . resolveBindings ) { recordNodes ( arrayType , expression ) ; } if ( expression . initializer != null ) { arrayCreation . setInitializer ( convert ( expression . initializer ) ) ; } return arrayCreation ; } public ArrayInitializer convert ( org . eclipse . jdt . internal . compiler . ast . ArrayInitializer expression ) { ArrayInitializer arrayInitializer = new ArrayInitializer ( this . ast ) ; if ( this . resolveBindings ) { recordNodes ( arrayInitializer , expression ) ; } arrayInitializer . setSourceRange ( expression . sourceStart , expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ) ; org . eclipse . jdt . internal . compiler . ast . Expression [ ] expressions = expression . expressions ; if ( expressions != null ) { int length = expressions . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { Expression expr = convert ( expressions [ i ] ) ; if ( this . resolveBindings ) { recordNodes ( expr , expressions [ i ] ) ; } arrayInitializer . expressions ( ) . add ( expr ) ; } } return arrayInitializer ; } public ArrayAccess convert ( org . eclipse . jdt . internal . compiler . ast . ArrayReference reference ) { ArrayAccess arrayAccess = new ArrayAccess ( this . ast ) ; if ( this . resolveBindings ) { recordNodes ( arrayAccess , reference ) ; } arrayAccess . setSourceRange ( reference . sourceStart , reference . sourceEnd - reference . sourceStart + <NUM_LIT:1> ) ; arrayAccess . setArray ( convert ( reference . receiver ) ) ; arrayAccess . setIndex ( convert ( reference . position ) ) ; return arrayAccess ; } public AssertStatement convert ( org . eclipse . jdt . internal . compiler . ast . AssertStatement statement ) { AssertStatement assertStatement = new AssertStatement ( this . ast ) ; final Expression assertExpression = convert ( statement . assertExpression ) ; Expression searchingNode = assertExpression ; assertStatement . setExpression ( assertExpression ) ; org . eclipse . jdt . internal . compiler . ast . Expression exceptionArgument = statement . exceptionArgument ; if ( exceptionArgument != null ) { final Expression exceptionMessage = convert ( exceptionArgument ) ; assertStatement . setMessage ( exceptionMessage ) ; searchingNode = exceptionMessage ; } int start = statement . sourceStart ; int sourceEnd = retrieveSemiColonPosition ( searchingNode ) ; if ( sourceEnd == - <NUM_LIT:1> ) { sourceEnd = searchingNode . getStartPosition ( ) + searchingNode . getLength ( ) - <NUM_LIT:1> ; assertStatement . setSourceRange ( start , sourceEnd - start + <NUM_LIT:1> ) ; } else { assertStatement . setSourceRange ( start , sourceEnd - start + <NUM_LIT:1> ) ; } return assertStatement ; } public Assignment convert ( org . eclipse . jdt . internal . compiler . ast . Assignment expression ) { Assignment assignment = new Assignment ( this . ast ) ; if ( this . resolveBindings ) { recordNodes ( assignment , expression ) ; } Expression lhs = convert ( expression . lhs ) ; assignment . setLeftHandSide ( lhs ) ; assignment . setOperator ( Assignment . Operator . ASSIGN ) ; assignment . setRightHandSide ( convert ( expression . expression ) ) ; int start = lhs . getStartPosition ( ) ; assignment . setSourceRange ( start , expression . sourceEnd - start + <NUM_LIT:1> ) ; return assignment ; } public TypeDeclaration convert ( org . eclipse . jdt . internal . compiler . ast . ASTNode [ ] nodes ) { final TypeDeclaration typeDecl = new TypeDeclaration ( this . ast ) ; typeDecl . setInterface ( false ) ; int nodesLength = nodes . length ; for ( int i = <NUM_LIT:0> ; i < nodesLength ; i ++ ) { org . eclipse . jdt . internal . compiler . ast . ASTNode node = nodes [ i ] ; if ( node instanceof org . eclipse . jdt . internal . compiler . ast . Initializer ) { org . eclipse . jdt . internal . compiler . ast . Initializer oldInitializer = ( org . eclipse . jdt . internal . compiler . ast . Initializer ) node ; Initializer initializer = new Initializer ( this . ast ) ; initializer . setBody ( convert ( oldInitializer . block ) ) ; setModifiers ( initializer , oldInitializer ) ; initializer . setSourceRange ( oldInitializer . declarationSourceStart , oldInitializer . sourceEnd - oldInitializer . declarationSourceStart + <NUM_LIT:1> ) ; convert ( oldInitializer . javadoc , initializer ) ; typeDecl . bodyDeclarations ( ) . add ( initializer ) ; } else if ( node instanceof org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ) { org . eclipse . jdt . internal . compiler . ast . FieldDeclaration fieldDeclaration = ( org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ) node ; if ( i > <NUM_LIT:0> && ( nodes [ i - <NUM_LIT:1> ] instanceof org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ) && ( ( org . eclipse . jdt . internal . compiler . ast . FieldDeclaration ) nodes [ i - <NUM_LIT:1> ] ) . declarationSourceStart == fieldDeclaration . declarationSourceStart ) { FieldDeclaration currentFieldDeclaration = ( FieldDeclaration ) typeDecl . bodyDeclarations ( ) . get ( typeDecl . bodyDeclarations ( ) . size ( ) - <NUM_LIT:1> ) ; currentFieldDeclaration . fragments ( ) . add ( convertToVariableDeclarationFragment ( fieldDeclaration ) ) ; } else { typeDecl . bodyDeclarations ( ) . add ( convertToFieldDeclaration ( fieldDeclaration ) ) ; } } else if ( node instanceof org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ) { AbstractMethodDeclaration nextMethodDeclaration = ( AbstractMethodDeclaration ) node ; if ( ! nextMethodDeclaration . isDefaultConstructor ( ) && ! nextMethodDeclaration . isClinit ( ) ) { typeDecl . bodyDeclarations ( ) . add ( convert ( nextMethodDeclaration ) ) ; } } else if ( node instanceof org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) { org . eclipse . jdt . internal . compiler . ast . TypeDeclaration nextMemberDeclaration = ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) node ; ASTNode nextMemberDeclarationNode = convert ( nextMemberDeclaration ) ; if ( nextMemberDeclarationNode == null ) { typeDecl . setFlags ( typeDecl . getFlags ( ) | ASTNode . MALFORMED ) ; } else { typeDecl . bodyDeclarations ( ) . add ( nextMemberDeclarationNode ) ; } } } return typeDecl ; } public Expression convert ( org . eclipse . jdt . internal . compiler . ast . BinaryExpression expression ) { InfixExpression infixExpression = new InfixExpression ( this . ast ) ; if ( this . resolveBindings ) { this . recordNodes ( infixExpression , expression ) ; } int expressionOperatorID = ( expression . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorMASK ) > > org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorSHIFT ; switch ( expressionOperatorID ) { case org . eclipse . jdt . internal . compiler . ast . OperatorIds . EQUAL_EQUAL : infixExpression . setOperator ( InfixExpression . Operator . EQUALS ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . LESS_EQUAL : infixExpression . setOperator ( InfixExpression . Operator . LESS_EQUALS ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . GREATER_EQUAL : infixExpression . setOperator ( InfixExpression . Operator . GREATER_EQUALS ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . NOT_EQUAL : infixExpression . setOperator ( InfixExpression . Operator . NOT_EQUALS ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . LEFT_SHIFT : infixExpression . setOperator ( InfixExpression . Operator . LEFT_SHIFT ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . RIGHT_SHIFT : infixExpression . setOperator ( InfixExpression . Operator . RIGHT_SHIFT_SIGNED ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . UNSIGNED_RIGHT_SHIFT : infixExpression . setOperator ( InfixExpression . Operator . RIGHT_SHIFT_UNSIGNED ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . OR_OR : infixExpression . setOperator ( InfixExpression . Operator . CONDITIONAL_OR ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . AND_AND : infixExpression . setOperator ( InfixExpression . Operator . CONDITIONAL_AND ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . PLUS : infixExpression . setOperator ( InfixExpression . Operator . PLUS ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . MINUS : infixExpression . setOperator ( InfixExpression . Operator . MINUS ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . REMAINDER : infixExpression . setOperator ( InfixExpression . Operator . REMAINDER ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . XOR : infixExpression . setOperator ( InfixExpression . Operator . XOR ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . AND : infixExpression . setOperator ( InfixExpression . Operator . AND ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . MULTIPLY : infixExpression . setOperator ( InfixExpression . Operator . TIMES ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . OR : infixExpression . setOperator ( InfixExpression . Operator . OR ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . DIVIDE : infixExpression . setOperator ( InfixExpression . Operator . DIVIDE ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . GREATER : infixExpression . setOperator ( InfixExpression . Operator . GREATER ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . LESS : infixExpression . setOperator ( InfixExpression . Operator . LESS ) ; } if ( expression . left instanceof org . eclipse . jdt . internal . compiler . ast . BinaryExpression && ( ( expression . left . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedMASK ) == <NUM_LIT:0> ) ) { infixExpression . extendedOperands ( ) . add ( convert ( expression . right ) ) ; org . eclipse . jdt . internal . compiler . ast . Expression leftOperand = expression . left ; org . eclipse . jdt . internal . compiler . ast . Expression rightOperand = null ; do { rightOperand = ( ( org . eclipse . jdt . internal . compiler . ast . BinaryExpression ) leftOperand ) . right ; if ( ( ( ( leftOperand . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorMASK ) > > org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorSHIFT ) != expressionOperatorID && ( ( leftOperand . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedMASK ) == <NUM_LIT:0> ) ) || ( ( rightOperand instanceof org . eclipse . jdt . internal . compiler . ast . BinaryExpression && ( ( rightOperand . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorMASK ) > > org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorSHIFT ) != expressionOperatorID ) && ( ( rightOperand . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedMASK ) == <NUM_LIT:0> ) ) ) { List extendedOperands = infixExpression . extendedOperands ( ) ; InfixExpression temp = new InfixExpression ( this . ast ) ; if ( this . resolveBindings ) { this . recordNodes ( temp , expression ) ; } temp . setOperator ( getOperatorFor ( expressionOperatorID ) ) ; Expression leftSide = convert ( leftOperand ) ; temp . setLeftOperand ( leftSide ) ; temp . setSourceRange ( leftSide . getStartPosition ( ) , leftSide . getLength ( ) ) ; int size = extendedOperands . size ( ) ; for ( int i = <NUM_LIT:0> ; i < size - <NUM_LIT:1> ; i ++ ) { Expression expr = temp ; temp = new InfixExpression ( this . ast ) ; if ( this . resolveBindings ) { this . recordNodes ( temp , expression ) ; } temp . setLeftOperand ( expr ) ; temp . setOperator ( getOperatorFor ( expressionOperatorID ) ) ; temp . setSourceRange ( expr . getStartPosition ( ) , expr . getLength ( ) ) ; } infixExpression = temp ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { Expression extendedOperand = ( Expression ) extendedOperands . remove ( size - <NUM_LIT:1> - i ) ; temp . setRightOperand ( extendedOperand ) ; int startPosition = temp . getLeftOperand ( ) . getStartPosition ( ) ; temp . setSourceRange ( startPosition , extendedOperand . getStartPosition ( ) + extendedOperand . getLength ( ) - startPosition ) ; if ( temp . getLeftOperand ( ) . getNodeType ( ) == ASTNode . INFIX_EXPRESSION ) { temp = ( InfixExpression ) temp . getLeftOperand ( ) ; } } int startPosition = infixExpression . getLeftOperand ( ) . getStartPosition ( ) ; infixExpression . setSourceRange ( startPosition , expression . sourceEnd - startPosition + <NUM_LIT:1> ) ; if ( this . resolveBindings ) { this . recordNodes ( infixExpression , expression ) ; } return infixExpression ; } infixExpression . extendedOperands ( ) . add ( <NUM_LIT:0> , convert ( rightOperand ) ) ; leftOperand = ( ( org . eclipse . jdt . internal . compiler . ast . BinaryExpression ) leftOperand ) . left ; } while ( leftOperand instanceof org . eclipse . jdt . internal . compiler . ast . BinaryExpression && ( ( leftOperand . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedMASK ) == <NUM_LIT:0> ) ) ; Expression leftExpression = convert ( leftOperand ) ; infixExpression . setLeftOperand ( leftExpression ) ; infixExpression . setRightOperand ( ( Expression ) infixExpression . extendedOperands ( ) . remove ( <NUM_LIT:0> ) ) ; int startPosition = leftExpression . getStartPosition ( ) ; infixExpression . setSourceRange ( startPosition , expression . sourceEnd - startPosition + <NUM_LIT:1> ) ; return infixExpression ; } else if ( expression . left instanceof StringLiteralConcatenation && ( ( expression . left . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedMASK ) == <NUM_LIT:0> ) && ( OperatorIds . PLUS == expressionOperatorID ) ) { StringLiteralConcatenation literal = ( StringLiteralConcatenation ) expression . left ; final org . eclipse . jdt . internal . compiler . ast . Expression [ ] stringLiterals = literal . literals ; infixExpression . setLeftOperand ( convert ( stringLiterals [ <NUM_LIT:0> ] ) ) ; infixExpression . setRightOperand ( convert ( stringLiterals [ <NUM_LIT:1> ] ) ) ; for ( int i = <NUM_LIT:2> ; i < literal . counter ; i ++ ) { infixExpression . extendedOperands ( ) . add ( convert ( stringLiterals [ i ] ) ) ; } infixExpression . extendedOperands ( ) . add ( convert ( expression . right ) ) ; int startPosition = literal . sourceStart ; infixExpression . setSourceRange ( startPosition , expression . sourceEnd - startPosition + <NUM_LIT:1> ) ; return infixExpression ; } Expression leftExpression = convert ( expression . left ) ; infixExpression . setLeftOperand ( leftExpression ) ; infixExpression . setRightOperand ( convert ( expression . right ) ) ; int startPosition = leftExpression . getStartPosition ( ) ; infixExpression . setSourceRange ( startPosition , expression . sourceEnd - startPosition + <NUM_LIT:1> ) ; return infixExpression ; } public Block convert ( org . eclipse . jdt . internal . compiler . ast . Block statement ) { Block block = new Block ( this . ast ) ; if ( statement . sourceEnd > <NUM_LIT:0> ) { block . setSourceRange ( statement . sourceStart , statement . sourceEnd - statement . sourceStart + <NUM_LIT:1> ) ; } org . eclipse . jdt . internal . compiler . ast . Statement [ ] statements = statement . statements ; if ( statements != null ) { int statementsLength = statements . length ; for ( int i = <NUM_LIT:0> ; i < statementsLength ; i ++ ) { if ( statements [ i ] instanceof org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ) { checkAndAddMultipleLocalDeclaration ( statements , i , block . statements ( ) ) ; } else { Statement statement2 = convert ( statements [ i ] ) ; if ( statement2 != null ) { block . statements ( ) . add ( statement2 ) ; } } } } return block ; } public BreakStatement convert ( org . eclipse . jdt . internal . compiler . ast . BreakStatement statement ) { BreakStatement breakStatement = new BreakStatement ( this . ast ) ; breakStatement . setSourceRange ( statement . sourceStart , statement . sourceEnd - statement . sourceStart + <NUM_LIT:1> ) ; if ( statement . label != null ) { final SimpleName name = new SimpleName ( this . ast ) ; name . internalSetIdentifier ( new String ( statement . label ) ) ; retrieveIdentifierAndSetPositions ( statement . sourceStart , statement . sourceEnd , name ) ; breakStatement . setLabel ( name ) ; } return breakStatement ; } public SwitchCase convert ( org . eclipse . jdt . internal . compiler . ast . CaseStatement statement ) { SwitchCase switchCase = new SwitchCase ( this . ast ) ; org . eclipse . jdt . internal . compiler . ast . Expression constantExpression = statement . constantExpression ; if ( constantExpression == null ) { switchCase . setExpression ( null ) ; } else { switchCase . setExpression ( convert ( constantExpression ) ) ; } switchCase . setSourceRange ( statement . sourceStart , statement . sourceEnd - statement . sourceStart + <NUM_LIT:1> ) ; retrieveColonPosition ( switchCase ) ; return switchCase ; } public CastExpression convert ( org . eclipse . jdt . internal . compiler . ast . CastExpression expression ) { CastExpression castExpression = new CastExpression ( this . ast ) ; castExpression . setSourceRange ( expression . sourceStart , expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ) ; org . eclipse . jdt . internal . compiler . ast . Expression type = expression . type ; trimWhiteSpacesAndComments ( type ) ; if ( type instanceof org . eclipse . jdt . internal . compiler . ast . TypeReference ) { castExpression . setType ( convertType ( ( org . eclipse . jdt . internal . compiler . ast . TypeReference ) type ) ) ; } else if ( type instanceof org . eclipse . jdt . internal . compiler . ast . NameReference ) { castExpression . setType ( convertToType ( ( org . eclipse . jdt . internal . compiler . ast . NameReference ) type ) ) ; } castExpression . setExpression ( convert ( expression . expression ) ) ; if ( this . resolveBindings ) { recordNodes ( castExpression , expression ) ; } return castExpression ; } public CharacterLiteral convert ( org . eclipse . jdt . internal . compiler . ast . CharLiteral expression ) { int length = expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ; int sourceStart = expression . sourceStart ; CharacterLiteral literal = new CharacterLiteral ( this . ast ) ; if ( this . resolveBindings ) { this . recordNodes ( literal , expression ) ; } literal . internalSetEscapedValue ( new String ( this . compilationUnitSource , sourceStart , length ) ) ; literal . setSourceRange ( sourceStart , length ) ; removeLeadingAndTrailingCommentsFromLiteral ( literal ) ; return literal ; } public Expression convert ( org . eclipse . jdt . internal . compiler . ast . ClassLiteralAccess expression ) { TypeLiteral typeLiteral = new TypeLiteral ( this . ast ) ; if ( this . resolveBindings ) { this . recordNodes ( typeLiteral , expression ) ; } typeLiteral . setSourceRange ( expression . sourceStart , expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ) ; typeLiteral . setType ( convertType ( expression . type ) ) ; return typeLiteral ; } public CompilationUnit convert ( org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration unit , char [ ] source ) { try { if ( unit . compilationResult . recoveryScannerData != null ) { RecoveryScanner recoveryScanner = new RecoveryScanner ( this . scanner , unit . compilationResult . recoveryScannerData . removeUnused ( ) ) ; this . scanner = recoveryScanner ; this . docParser . scanner = this . scanner ; } this . compilationUnitSource = source ; this . compilationUnitSourceLength = source . length ; this . scanner . setSource ( source , unit . compilationResult ) ; CompilationUnit compilationUnit = unit . getSpecialDomCompilationUnit ( this . ast ) ; if ( compilationUnit == null ) { compilationUnit = new CompilationUnit ( this . ast ) ; } compilationUnit . setStatementsRecoveryData ( unit . compilationResult . recoveryScannerData ) ; int [ ] [ ] comments = unit . comments ; if ( comments != null ) { buildCommentsTable ( compilationUnit , comments ) ; } if ( this . resolveBindings ) { recordNodes ( compilationUnit , unit ) ; } if ( unit . currentPackage != null ) { PackageDeclaration packageDeclaration = convertPackage ( unit ) ; compilationUnit . setPackage ( packageDeclaration ) ; } org . eclipse . jdt . internal . compiler . ast . ImportReference [ ] imports = unit . imports ; if ( imports != null ) { int importLength = imports . length ; for ( int i = <NUM_LIT:0> ; i < importLength ; i ++ ) { compilationUnit . imports ( ) . add ( convertImport ( imports [ i ] ) ) ; } } org . eclipse . jdt . internal . compiler . ast . TypeDeclaration [ ] types = unit . types ; if ( types != null ) { int typesLength = types . length ; for ( int i = <NUM_LIT:0> ; i < typesLength ; i ++ ) { org . eclipse . jdt . internal . compiler . ast . TypeDeclaration declaration = types [ i ] ; if ( CharOperation . equals ( declaration . name , TypeConstants . PACKAGE_INFO_NAME ) ) { continue ; } ASTNode type = convert ( declaration ) ; if ( type == null ) { compilationUnit . setFlags ( compilationUnit . getFlags ( ) | ASTNode . MALFORMED ) ; } else { compilationUnit . types ( ) . add ( type ) ; } } } compilationUnit . setSourceRange ( unit . sourceStart , unit . sourceEnd - unit . sourceStart + <NUM_LIT:1> ) ; int problemLength = unit . compilationResult . problemCount ; if ( problemLength != <NUM_LIT:0> ) { CategorizedProblem [ ] resizedProblems = null ; final CategorizedProblem [ ] problems = unit . compilationResult . getProblems ( ) ; final int realProblemLength = problems . length ; if ( realProblemLength == problemLength ) { resizedProblems = problems ; } else { System . arraycopy ( problems , <NUM_LIT:0> , ( resizedProblems = new CategorizedProblem [ realProblemLength ] ) , <NUM_LIT:0> , realProblemLength ) ; } ASTSyntaxErrorPropagator syntaxErrorPropagator = new ASTSyntaxErrorPropagator ( resizedProblems ) ; compilationUnit . accept ( syntaxErrorPropagator ) ; ASTRecoveryPropagator recoveryPropagator = new ASTRecoveryPropagator ( resizedProblems , unit . compilationResult . recoveryScannerData ) ; compilationUnit . accept ( recoveryPropagator ) ; compilationUnit . setProblems ( resizedProblems ) ; } if ( this . resolveBindings ) { lookupForScopes ( ) ; } compilationUnit . initCommentMapper ( this . scanner ) ; return compilationUnit ; } catch ( IllegalArgumentException e ) { StringBuffer message = new StringBuffer ( "<STR_LIT>" ) ; String lineDelimiter = Util . findLineSeparator ( source ) ; if ( lineDelimiter == null ) lineDelimiter = System . getProperty ( "<STR_LIT>" ) ; message . append ( lineDelimiter ) ; message . append ( "<STR_LIT>" ) ; message . append ( lineDelimiter ) ; message . append ( source ) ; message . append ( lineDelimiter ) ; message . append ( "<STR_LIT>" ) ; Util . log ( e , message . toString ( ) ) ; throw e ; } } public Assignment convert ( org . eclipse . jdt . internal . compiler . ast . CompoundAssignment expression ) { Assignment assignment = new Assignment ( this . ast ) ; Expression lhs = convert ( expression . lhs ) ; assignment . setLeftHandSide ( lhs ) ; int start = lhs . getStartPosition ( ) ; assignment . setSourceRange ( start , expression . sourceEnd - start + <NUM_LIT:1> ) ; switch ( expression . operator ) { case org . eclipse . jdt . internal . compiler . ast . OperatorIds . PLUS : assignment . setOperator ( Assignment . Operator . PLUS_ASSIGN ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . MINUS : assignment . setOperator ( Assignment . Operator . MINUS_ASSIGN ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . MULTIPLY : assignment . setOperator ( Assignment . Operator . TIMES_ASSIGN ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . DIVIDE : assignment . setOperator ( Assignment . Operator . DIVIDE_ASSIGN ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . AND : assignment . setOperator ( Assignment . Operator . BIT_AND_ASSIGN ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . OR : assignment . setOperator ( Assignment . Operator . BIT_OR_ASSIGN ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . XOR : assignment . setOperator ( Assignment . Operator . BIT_XOR_ASSIGN ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . REMAINDER : assignment . setOperator ( Assignment . Operator . REMAINDER_ASSIGN ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . LEFT_SHIFT : assignment . setOperator ( Assignment . Operator . LEFT_SHIFT_ASSIGN ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . RIGHT_SHIFT : assignment . setOperator ( Assignment . Operator . RIGHT_SHIFT_SIGNED_ASSIGN ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . UNSIGNED_RIGHT_SHIFT : assignment . setOperator ( Assignment . Operator . RIGHT_SHIFT_UNSIGNED_ASSIGN ) ; break ; } assignment . setRightHandSide ( convert ( expression . expression ) ) ; if ( this . resolveBindings ) { recordNodes ( assignment , expression ) ; } return assignment ; } public ConditionalExpression convert ( org . eclipse . jdt . internal . compiler . ast . ConditionalExpression expression ) { ConditionalExpression conditionalExpression = new ConditionalExpression ( this . ast ) ; if ( this . resolveBindings ) { recordNodes ( conditionalExpression , expression ) ; } conditionalExpression . setSourceRange ( expression . sourceStart , expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ) ; conditionalExpression . setExpression ( convert ( expression . condition ) ) ; conditionalExpression . setThenExpression ( convert ( expression . valueIfTrue ) ) ; conditionalExpression . setElseExpression ( convert ( expression . valueIfFalse ) ) ; return conditionalExpression ; } public ContinueStatement convert ( org . eclipse . jdt . internal . compiler . ast . ContinueStatement statement ) { ContinueStatement continueStatement = new ContinueStatement ( this . ast ) ; continueStatement . setSourceRange ( statement . sourceStart , statement . sourceEnd - statement . sourceStart + <NUM_LIT:1> ) ; if ( statement . label != null ) { final SimpleName name = new SimpleName ( this . ast ) ; name . internalSetIdentifier ( new String ( statement . label ) ) ; retrieveIdentifierAndSetPositions ( statement . sourceStart , statement . sourceEnd , name ) ; continueStatement . setLabel ( name ) ; } return continueStatement ; } public DoStatement convert ( org . eclipse . jdt . internal . compiler . ast . DoStatement statement ) { DoStatement doStatement = new DoStatement ( this . ast ) ; doStatement . setSourceRange ( statement . sourceStart , statement . sourceEnd - statement . sourceStart + <NUM_LIT:1> ) ; doStatement . setExpression ( convert ( statement . condition ) ) ; final Statement action = convert ( statement . action ) ; if ( action == null ) return null ; doStatement . setBody ( action ) ; return doStatement ; } public NumberLiteral convert ( org . eclipse . jdt . internal . compiler . ast . DoubleLiteral expression ) { int length = expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ; int sourceStart = expression . sourceStart ; NumberLiteral literal = new NumberLiteral ( this . ast ) ; literal . internalSetToken ( new String ( this . compilationUnitSource , sourceStart , length ) ) ; if ( this . resolveBindings ) { this . recordNodes ( literal , expression ) ; } literal . setSourceRange ( sourceStart , length ) ; removeLeadingAndTrailingCommentsFromLiteral ( literal ) ; return literal ; } public EmptyStatement convert ( org . eclipse . jdt . internal . compiler . ast . EmptyStatement statement ) { EmptyStatement emptyStatement = new EmptyStatement ( this . ast ) ; emptyStatement . setSourceRange ( statement . sourceStart , statement . sourceEnd - statement . sourceStart + <NUM_LIT:1> ) ; return emptyStatement ; } public EnumConstantDeclaration convert ( org . eclipse . jdt . internal . compiler . ast . FieldDeclaration enumConstant ) { checkCanceled ( ) ; EnumConstantDeclaration enumConstantDeclaration = new EnumConstantDeclaration ( this . ast ) ; final SimpleName typeName = new SimpleName ( this . ast ) ; typeName . internalSetIdentifier ( new String ( enumConstant . name ) ) ; typeName . setSourceRange ( enumConstant . sourceStart , enumConstant . sourceEnd - enumConstant . sourceStart + <NUM_LIT:1> ) ; enumConstantDeclaration . setName ( typeName ) ; int declarationSourceStart = enumConstant . declarationSourceStart ; int declarationSourceEnd = enumConstant . declarationSourceEnd ; final org . eclipse . jdt . internal . compiler . ast . Expression initialization = enumConstant . initialization ; if ( initialization != null ) { if ( initialization instanceof QualifiedAllocationExpression ) { org . eclipse . jdt . internal . compiler . ast . TypeDeclaration anonymousType = ( ( QualifiedAllocationExpression ) initialization ) . anonymousType ; if ( anonymousType != null ) { AnonymousClassDeclaration anonymousClassDeclaration = new AnonymousClassDeclaration ( this . ast ) ; int start = retrieveStartBlockPosition ( anonymousType . sourceEnd , anonymousType . bodyEnd ) ; int end = retrieveRightBrace ( anonymousType . bodyEnd , declarationSourceEnd ) ; if ( end == - <NUM_LIT:1> ) end = anonymousType . bodyEnd ; anonymousClassDeclaration . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; enumConstantDeclaration . setAnonymousClassDeclaration ( anonymousClassDeclaration ) ; buildBodyDeclarations ( anonymousType , anonymousClassDeclaration ) ; if ( this . resolveBindings ) { recordNodes ( anonymousClassDeclaration , anonymousType ) ; anonymousClassDeclaration . resolveBinding ( ) ; } enumConstantDeclaration . setSourceRange ( declarationSourceStart , end - declarationSourceStart + <NUM_LIT:1> ) ; } } else { enumConstantDeclaration . setSourceRange ( declarationSourceStart , declarationSourceEnd - declarationSourceStart + <NUM_LIT:1> ) ; } final org . eclipse . jdt . internal . compiler . ast . Expression [ ] arguments = ( ( org . eclipse . jdt . internal . compiler . ast . AllocationExpression ) initialization ) . arguments ; if ( arguments != null ) { for ( int i = <NUM_LIT:0> , max = arguments . length ; i < max ; i ++ ) { enumConstantDeclaration . arguments ( ) . add ( convert ( arguments [ i ] ) ) ; } } } else { enumConstantDeclaration . setSourceRange ( declarationSourceStart , declarationSourceEnd - declarationSourceStart + <NUM_LIT:1> ) ; } setModifiers ( enumConstantDeclaration , enumConstant ) ; if ( this . resolveBindings ) { recordNodes ( enumConstantDeclaration , enumConstant ) ; recordNodes ( typeName , enumConstant ) ; enumConstantDeclaration . resolveVariable ( ) ; } convert ( enumConstant . javadoc , enumConstantDeclaration ) ; return enumConstantDeclaration ; } public Expression convert ( org . eclipse . jdt . internal . compiler . ast . EqualExpression expression ) { InfixExpression infixExpression = new InfixExpression ( this . ast ) ; if ( this . resolveBindings ) { recordNodes ( infixExpression , expression ) ; } Expression leftExpression = convert ( expression . left ) ; infixExpression . setLeftOperand ( leftExpression ) ; infixExpression . setRightOperand ( convert ( expression . right ) ) ; int startPosition = leftExpression . getStartPosition ( ) ; infixExpression . setSourceRange ( startPosition , expression . sourceEnd - startPosition + <NUM_LIT:1> ) ; switch ( ( expression . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorMASK ) > > org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorSHIFT ) { case org . eclipse . jdt . internal . compiler . ast . OperatorIds . EQUAL_EQUAL : infixExpression . setOperator ( InfixExpression . Operator . EQUALS ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . NOT_EQUAL : infixExpression . setOperator ( InfixExpression . Operator . NOT_EQUALS ) ; } return infixExpression ; } public Statement convert ( org . eclipse . jdt . internal . compiler . ast . ExplicitConstructorCall statement ) { Statement newStatement ; int sourceStart = statement . sourceStart ; if ( statement . isSuperAccess ( ) || statement . isSuper ( ) ) { SuperConstructorInvocation superConstructorInvocation = new SuperConstructorInvocation ( this . ast ) ; if ( statement . qualification != null ) { superConstructorInvocation . setExpression ( convert ( statement . qualification ) ) ; } org . eclipse . jdt . internal . compiler . ast . Expression [ ] arguments = statement . arguments ; if ( arguments != null ) { int length = arguments . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { superConstructorInvocation . arguments ( ) . add ( convert ( arguments [ i ] ) ) ; } } if ( statement . typeArguments != null ) { if ( sourceStart > statement . typeArgumentsSourceStart ) { sourceStart = statement . typeArgumentsSourceStart ; } switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : superConstructorInvocation . setFlags ( superConstructorInvocation . getFlags ( ) | ASTNode . MALFORMED ) ; break ; case AST . JLS3 : for ( int i = <NUM_LIT:0> , max = statement . typeArguments . length ; i < max ; i ++ ) { superConstructorInvocation . typeArguments ( ) . add ( convertType ( statement . typeArguments [ i ] ) ) ; } break ; } } newStatement = superConstructorInvocation ; } else { ConstructorInvocation constructorInvocation = new ConstructorInvocation ( this . ast ) ; org . eclipse . jdt . internal . compiler . ast . Expression [ ] arguments = statement . arguments ; if ( arguments != null ) { int length = arguments . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { constructorInvocation . arguments ( ) . add ( convert ( arguments [ i ] ) ) ; } } if ( statement . typeArguments != null ) { if ( sourceStart > statement . typeArgumentsSourceStart ) { sourceStart = statement . typeArgumentsSourceStart ; } switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : constructorInvocation . setFlags ( constructorInvocation . getFlags ( ) | ASTNode . MALFORMED ) ; break ; case AST . JLS3 : for ( int i = <NUM_LIT:0> , max = statement . typeArguments . length ; i < max ; i ++ ) { constructorInvocation . typeArguments ( ) . add ( convertType ( statement . typeArguments [ i ] ) ) ; } break ; } } if ( statement . qualification != null ) { constructorInvocation . setFlags ( constructorInvocation . getFlags ( ) | ASTNode . MALFORMED ) ; } newStatement = constructorInvocation ; } newStatement . setSourceRange ( sourceStart , statement . sourceEnd - sourceStart + <NUM_LIT:1> ) ; if ( this . resolveBindings ) { recordNodes ( newStatement , statement ) ; } return newStatement ; } public Expression convert ( org . eclipse . jdt . internal . compiler . ast . Expression expression ) { if ( ( expression . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedMASK ) != <NUM_LIT:0> ) { return convertToParenthesizedExpression ( expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . Annotation ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . Annotation ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . CastExpression ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . CastExpression ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . ArrayAllocationExpression ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . ArrayAllocationExpression ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . QualifiedAllocationExpression ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . QualifiedAllocationExpression ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . AllocationExpression ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . AllocationExpression ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . ArrayInitializer ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . ArrayInitializer ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . PrefixExpression ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . PrefixExpression ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . PostfixExpression ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . PostfixExpression ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . CompoundAssignment ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . CompoundAssignment ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . Assignment ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . Assignment ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . ClassLiteralAccess ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . ClassLiteralAccess ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . FalseLiteral ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . FalseLiteral ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . TrueLiteral ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . TrueLiteral ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . NullLiteral ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . NullLiteral ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . CharLiteral ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . CharLiteral ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . DoubleLiteral ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . DoubleLiteral ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . FloatLiteral ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . FloatLiteral ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . IntLiteralMinValue ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . IntLiteralMinValue ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . IntLiteral ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . IntLiteral ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . LongLiteralMinValue ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . LongLiteralMinValue ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . LongLiteral ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . LongLiteral ) expression ) ; } if ( expression instanceof StringLiteralConcatenation ) { return convert ( ( StringLiteralConcatenation ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . ExtendedStringLiteral ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . ExtendedStringLiteral ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . StringLiteral ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . StringLiteral ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . AND_AND_Expression ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . AND_AND_Expression ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . OR_OR_Expression ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . OR_OR_Expression ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . EqualExpression ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . EqualExpression ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . BinaryExpression ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . BinaryExpression ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . InstanceOfExpression ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . InstanceOfExpression ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . UnaryExpression ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . UnaryExpression ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . ConditionalExpression ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . ConditionalExpression ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . MessageSend ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . MessageSend ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . Reference ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . Reference ) expression ) ; } if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . TypeReference ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . TypeReference ) expression ) ; } return null ; } public StringLiteral convert ( org . eclipse . jdt . internal . compiler . ast . ExtendedStringLiteral expression ) { expression . computeConstant ( ) ; StringLiteral literal = new StringLiteral ( this . ast ) ; if ( this . resolveBindings ) { this . recordNodes ( literal , expression ) ; } literal . setLiteralValue ( expression . constant . stringValue ( ) ) ; literal . setSourceRange ( expression . sourceStart , expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ) ; return literal ; } public BooleanLiteral convert ( org . eclipse . jdt . internal . compiler . ast . FalseLiteral expression ) { final BooleanLiteral literal = new BooleanLiteral ( this . ast ) ; literal . setBooleanValue ( false ) ; if ( this . resolveBindings ) { this . recordNodes ( literal , expression ) ; } literal . setSourceRange ( expression . sourceStart , expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ) ; return literal ; } public Expression convert ( org . eclipse . jdt . internal . compiler . ast . FieldReference reference ) { if ( reference . receiver . isSuper ( ) ) { final SuperFieldAccess superFieldAccess = new SuperFieldAccess ( this . ast ) ; if ( this . resolveBindings ) { recordNodes ( superFieldAccess , reference ) ; } if ( reference . receiver instanceof org . eclipse . jdt . internal . compiler . ast . QualifiedSuperReference ) { Name qualifier = convert ( ( org . eclipse . jdt . internal . compiler . ast . QualifiedSuperReference ) reference . receiver ) ; superFieldAccess . setQualifier ( qualifier ) ; if ( this . resolveBindings ) { recordNodes ( qualifier , reference . receiver ) ; } } final SimpleName simpleName = new SimpleName ( this . ast ) ; simpleName . internalSetIdentifier ( new String ( reference . token ) ) ; int sourceStart = ( int ) ( reference . nameSourcePosition > > > <NUM_LIT:32> ) ; int length = ( int ) ( reference . nameSourcePosition & <NUM_LIT> ) - sourceStart + <NUM_LIT:1> ; simpleName . setSourceRange ( sourceStart , length ) ; superFieldAccess . setName ( simpleName ) ; if ( this . resolveBindings ) { recordNodes ( simpleName , reference ) ; } superFieldAccess . setSourceRange ( reference . receiver . sourceStart , reference . sourceEnd - reference . receiver . sourceStart + <NUM_LIT:1> ) ; return superFieldAccess ; } else { final FieldAccess fieldAccess = new FieldAccess ( this . ast ) ; if ( this . resolveBindings ) { recordNodes ( fieldAccess , reference ) ; } Expression receiver = convert ( reference . receiver ) ; fieldAccess . setExpression ( receiver ) ; final SimpleName simpleName = new SimpleName ( this . ast ) ; simpleName . internalSetIdentifier ( new String ( reference . token ) ) ; int sourceStart = ( int ) ( reference . nameSourcePosition > > > <NUM_LIT:32> ) ; int length = ( int ) ( reference . nameSourcePosition & <NUM_LIT> ) - sourceStart + <NUM_LIT:1> ; simpleName . setSourceRange ( sourceStart , length ) ; fieldAccess . setName ( simpleName ) ; if ( this . resolveBindings ) { recordNodes ( simpleName , reference ) ; } fieldAccess . setSourceRange ( receiver . getStartPosition ( ) , reference . sourceEnd - receiver . getStartPosition ( ) + <NUM_LIT:1> ) ; return fieldAccess ; } } public NumberLiteral convert ( org . eclipse . jdt . internal . compiler . ast . FloatLiteral expression ) { int length = expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ; int sourceStart = expression . sourceStart ; NumberLiteral literal = new NumberLiteral ( this . ast ) ; literal . internalSetToken ( new String ( this . compilationUnitSource , sourceStart , length ) ) ; if ( this . resolveBindings ) { this . recordNodes ( literal , expression ) ; } literal . setSourceRange ( sourceStart , length ) ; removeLeadingAndTrailingCommentsFromLiteral ( literal ) ; return literal ; } public Statement convert ( ForeachStatement statement ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : return createFakeEmptyStatement ( statement ) ; case AST . JLS3 : EnhancedForStatement enhancedForStatement = new EnhancedForStatement ( this . ast ) ; enhancedForStatement . setParameter ( convertToSingleVariableDeclaration ( statement . elementVariable ) ) ; org . eclipse . jdt . internal . compiler . ast . Expression collection = statement . collection ; if ( collection == null ) return null ; enhancedForStatement . setExpression ( convert ( collection ) ) ; final Statement action = convert ( statement . action ) ; if ( action == null ) return null ; enhancedForStatement . setBody ( action ) ; int start = statement . sourceStart ; int end = statement . sourceEnd ; enhancedForStatement . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; return enhancedForStatement ; default : return createFakeEmptyStatement ( statement ) ; } } public ForStatement convert ( org . eclipse . jdt . internal . compiler . ast . ForStatement statement ) { ForStatement forStatement = new ForStatement ( this . ast ) ; forStatement . setSourceRange ( statement . sourceStart , statement . sourceEnd - statement . sourceStart + <NUM_LIT:1> ) ; org . eclipse . jdt . internal . compiler . ast . Statement [ ] initializations = statement . initializations ; if ( initializations != null ) { if ( initializations [ <NUM_LIT:0> ] instanceof org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ) { org . eclipse . jdt . internal . compiler . ast . LocalDeclaration initialization = ( org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ) initializations [ <NUM_LIT:0> ] ; VariableDeclarationExpression variableDeclarationExpression = convertToVariableDeclarationExpression ( initialization ) ; int initializationsLength = initializations . length ; for ( int i = <NUM_LIT:1> ; i < initializationsLength ; i ++ ) { initialization = ( org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ) initializations [ i ] ; variableDeclarationExpression . fragments ( ) . add ( convertToVariableDeclarationFragment ( initialization ) ) ; } if ( initializationsLength != <NUM_LIT:1> ) { int start = variableDeclarationExpression . getStartPosition ( ) ; int end = ( ( org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ) initializations [ initializationsLength - <NUM_LIT:1> ] ) . declarationSourceEnd ; variableDeclarationExpression . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; } forStatement . initializers ( ) . add ( variableDeclarationExpression ) ; } else { int initializationsLength = initializations . length ; for ( int i = <NUM_LIT:0> ; i < initializationsLength ; i ++ ) { Expression initializer = convertToExpression ( initializations [ i ] ) ; if ( initializer != null ) { forStatement . initializers ( ) . add ( initializer ) ; } else { forStatement . setFlags ( forStatement . getFlags ( ) | ASTNode . MALFORMED ) ; } } } } if ( statement . condition != null ) { forStatement . setExpression ( convert ( statement . condition ) ) ; } org . eclipse . jdt . internal . compiler . ast . Statement [ ] increments = statement . increments ; if ( increments != null ) { int incrementsLength = increments . length ; for ( int i = <NUM_LIT:0> ; i < incrementsLength ; i ++ ) { forStatement . updaters ( ) . add ( convertToExpression ( increments [ i ] ) ) ; } } final Statement action = convert ( statement . action ) ; if ( action == null ) return null ; forStatement . setBody ( action ) ; return forStatement ; } public IfStatement convert ( org . eclipse . jdt . internal . compiler . ast . IfStatement statement ) { IfStatement ifStatement = new IfStatement ( this . ast ) ; ifStatement . setSourceRange ( statement . sourceStart , statement . sourceEnd - statement . sourceStart + <NUM_LIT:1> ) ; ifStatement . setExpression ( convert ( statement . condition ) ) ; final Statement thenStatement = convert ( statement . thenStatement ) ; if ( thenStatement == null ) return null ; ifStatement . setThenStatement ( thenStatement ) ; org . eclipse . jdt . internal . compiler . ast . Statement statement2 = statement . elseStatement ; if ( statement2 != null ) { final Statement elseStatement = convert ( statement2 ) ; if ( elseStatement != null ) { ifStatement . setElseStatement ( elseStatement ) ; } } return ifStatement ; } public InstanceofExpression convert ( org . eclipse . jdt . internal . compiler . ast . InstanceOfExpression expression ) { InstanceofExpression instanceOfExpression = new InstanceofExpression ( this . ast ) ; if ( this . resolveBindings ) { recordNodes ( instanceOfExpression , expression ) ; } Expression leftExpression = convert ( expression . expression ) ; instanceOfExpression . setLeftOperand ( leftExpression ) ; final Type convertType = convertType ( expression . type ) ; instanceOfExpression . setRightOperand ( convertType ) ; int startPosition = leftExpression . getStartPosition ( ) ; int sourceEnd = convertType . getStartPosition ( ) + convertType . getLength ( ) - <NUM_LIT:1> ; instanceOfExpression . setSourceRange ( startPosition , sourceEnd - startPosition + <NUM_LIT:1> ) ; return instanceOfExpression ; } public NumberLiteral convert ( org . eclipse . jdt . internal . compiler . ast . IntLiteral expression ) { int length = expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ; int sourceStart = expression . sourceStart ; final NumberLiteral literal = new NumberLiteral ( this . ast ) ; literal . internalSetToken ( new String ( this . compilationUnitSource , sourceStart , length ) ) ; if ( this . resolveBindings ) { this . recordNodes ( literal , expression ) ; } literal . setSourceRange ( sourceStart , length ) ; removeLeadingAndTrailingCommentsFromLiteral ( literal ) ; return literal ; } public NumberLiteral convert ( org . eclipse . jdt . internal . compiler . ast . IntLiteralMinValue expression ) { int length = expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ; int sourceStart = expression . sourceStart ; NumberLiteral literal = new NumberLiteral ( this . ast ) ; literal . internalSetToken ( new String ( this . compilationUnitSource , sourceStart , length ) ) ; if ( this . resolveBindings ) { this . recordNodes ( literal , expression ) ; } literal . setSourceRange ( sourceStart , length ) ; removeLeadingAndTrailingCommentsFromLiteral ( literal ) ; return literal ; } public void convert ( org . eclipse . jdt . internal . compiler . ast . Javadoc javadoc , BodyDeclaration bodyDeclaration ) { if ( bodyDeclaration . getJavadoc ( ) == null ) { if ( javadoc != null ) { if ( this . commentMapper == null || ! this . commentMapper . hasSameTable ( this . commentsTable ) ) { this . commentMapper = new DefaultCommentMapper ( this . commentsTable ) ; } Comment comment = this . commentMapper . getComment ( javadoc . sourceStart ) ; if ( comment != null && comment . isDocComment ( ) && comment . getParent ( ) == null ) { Javadoc docComment = ( Javadoc ) comment ; if ( this . resolveBindings ) { recordNodes ( docComment , javadoc ) ; Iterator tags = docComment . tags ( ) . listIterator ( ) ; while ( tags . hasNext ( ) ) { recordNodes ( javadoc , ( TagElement ) tags . next ( ) ) ; } } bodyDeclaration . setJavadoc ( docComment ) ; } } } } public void convert ( org . eclipse . jdt . internal . compiler . ast . Javadoc javadoc , PackageDeclaration packageDeclaration ) { if ( this . ast . apiLevel == AST . JLS3 && packageDeclaration . getJavadoc ( ) == null ) { if ( javadoc != null ) { if ( this . commentMapper == null || ! this . commentMapper . hasSameTable ( this . commentsTable ) ) { this . commentMapper = new DefaultCommentMapper ( this . commentsTable ) ; } Comment comment = this . commentMapper . getComment ( javadoc . sourceStart ) ; if ( comment != null && comment . isDocComment ( ) && comment . getParent ( ) == null ) { Javadoc docComment = ( Javadoc ) comment ; if ( this . resolveBindings ) { recordNodes ( docComment , javadoc ) ; Iterator tags = docComment . tags ( ) . listIterator ( ) ; while ( tags . hasNext ( ) ) { recordNodes ( javadoc , ( TagElement ) tags . next ( ) ) ; } } packageDeclaration . setJavadoc ( docComment ) ; } } } } public LabeledStatement convert ( org . eclipse . jdt . internal . compiler . ast . LabeledStatement statement ) { LabeledStatement labeledStatement = new LabeledStatement ( this . ast ) ; final int sourceStart = statement . sourceStart ; labeledStatement . setSourceRange ( sourceStart , statement . sourceEnd - sourceStart + <NUM_LIT:1> ) ; Statement body = convert ( statement . statement ) ; if ( body == null ) return null ; labeledStatement . setBody ( body ) ; final SimpleName name = new SimpleName ( this . ast ) ; name . internalSetIdentifier ( new String ( statement . label ) ) ; name . setSourceRange ( sourceStart , statement . labelEnd - sourceStart + <NUM_LIT:1> ) ; labeledStatement . setLabel ( name ) ; return labeledStatement ; } public NumberLiteral convert ( org . eclipse . jdt . internal . compiler . ast . LongLiteral expression ) { int length = expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ; int sourceStart = expression . sourceStart ; final NumberLiteral literal = new NumberLiteral ( this . ast ) ; literal . internalSetToken ( new String ( this . compilationUnitSource , sourceStart , length ) ) ; if ( this . resolveBindings ) { this . recordNodes ( literal , expression ) ; } literal . setSourceRange ( sourceStart , length ) ; removeLeadingAndTrailingCommentsFromLiteral ( literal ) ; return literal ; } public NumberLiteral convert ( org . eclipse . jdt . internal . compiler . ast . LongLiteralMinValue expression ) { int length = expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ; int sourceStart = expression . sourceStart ; final NumberLiteral literal = new NumberLiteral ( this . ast ) ; literal . internalSetToken ( new String ( this . compilationUnitSource , sourceStart , length ) ) ; if ( this . resolveBindings ) { this . recordNodes ( literal , expression ) ; } literal . setSourceRange ( sourceStart , length ) ; removeLeadingAndTrailingCommentsFromLiteral ( literal ) ; return literal ; } public Expression convert ( MessageSend expression ) { Expression expr ; int sourceStart = expression . sourceStart ; if ( expression . isSuperAccess ( ) ) { final SuperMethodInvocation superMethodInvocation = new SuperMethodInvocation ( this . ast ) ; if ( this . resolveBindings ) { recordNodes ( superMethodInvocation , expression ) ; } final SimpleName name = new SimpleName ( this . ast ) ; name . internalSetIdentifier ( new String ( expression . selector ) ) ; int nameSourceStart = ( int ) ( expression . nameSourcePosition > > > <NUM_LIT:32> ) ; int nameSourceLength = ( ( int ) expression . nameSourcePosition ) - nameSourceStart + <NUM_LIT:1> ; name . setSourceRange ( nameSourceStart , nameSourceLength ) ; if ( this . resolveBindings ) { recordNodes ( name , expression ) ; } superMethodInvocation . setName ( name ) ; if ( expression . receiver instanceof org . eclipse . jdt . internal . compiler . ast . QualifiedSuperReference ) { Name qualifier = convert ( ( org . eclipse . jdt . internal . compiler . ast . QualifiedSuperReference ) expression . receiver ) ; superMethodInvocation . setQualifier ( qualifier ) ; if ( this . resolveBindings ) { recordNodes ( qualifier , expression . receiver ) ; } if ( qualifier != null ) { sourceStart = qualifier . getStartPosition ( ) ; } } org . eclipse . jdt . internal . compiler . ast . Expression [ ] arguments = expression . arguments ; if ( arguments != null ) { int argumentsLength = arguments . length ; for ( int i = <NUM_LIT:0> ; i < argumentsLength ; i ++ ) { Expression expri = convert ( arguments [ i ] ) ; if ( this . resolveBindings ) { recordNodes ( expri , arguments [ i ] ) ; } superMethodInvocation . arguments ( ) . add ( expri ) ; } } final TypeReference [ ] typeArguments = expression . typeArguments ; if ( typeArguments != null ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : superMethodInvocation . setFlags ( superMethodInvocation . getFlags ( ) | ASTNode . MALFORMED ) ; break ; case AST . JLS3 : for ( int i = <NUM_LIT:0> , max = typeArguments . length ; i < max ; i ++ ) { superMethodInvocation . typeArguments ( ) . add ( convertType ( typeArguments [ i ] ) ) ; } break ; } } expr = superMethodInvocation ; } else { final MethodInvocation methodInvocation = new MethodInvocation ( this . ast ) ; if ( this . resolveBindings ) { recordNodes ( methodInvocation , expression ) ; } final SimpleName name = new SimpleName ( this . ast ) ; name . internalSetIdentifier ( new String ( expression . selector ) ) ; int nameSourceStart = ( int ) ( expression . nameSourcePosition > > > <NUM_LIT:32> ) ; int nameSourceLength = ( ( int ) expression . nameSourcePosition ) - nameSourceStart + <NUM_LIT:1> ; name . setSourceRange ( nameSourceStart , nameSourceLength ) ; methodInvocation . setName ( name ) ; if ( this . resolveBindings ) { recordNodes ( name , expression ) ; } org . eclipse . jdt . internal . compiler . ast . Expression [ ] arguments = expression . arguments ; if ( arguments != null ) { int argumentsLength = arguments . length ; for ( int i = <NUM_LIT:0> ; i < argumentsLength ; i ++ ) { Expression expri = convert ( arguments [ i ] ) ; if ( this . resolveBindings ) { recordNodes ( expri , arguments [ i ] ) ; } methodInvocation . arguments ( ) . add ( expri ) ; } } Expression qualifier = null ; org . eclipse . jdt . internal . compiler . ast . Expression receiver = expression . receiver ; if ( receiver instanceof MessageSend ) { if ( ( receiver . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedMASK ) != <NUM_LIT:0> ) { qualifier = convertToParenthesizedExpression ( receiver ) ; } else { qualifier = convert ( ( MessageSend ) receiver ) ; } } else { qualifier = convert ( receiver ) ; } if ( qualifier instanceof Name && this . resolveBindings ) { recordNodes ( qualifier , receiver ) ; } methodInvocation . setExpression ( qualifier ) ; if ( qualifier != null ) { sourceStart = qualifier . getStartPosition ( ) ; } final TypeReference [ ] typeArguments = expression . typeArguments ; if ( typeArguments != null ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : methodInvocation . setFlags ( methodInvocation . getFlags ( ) | ASTNode . MALFORMED ) ; break ; case AST . JLS3 : for ( int i = <NUM_LIT:0> , max = typeArguments . length ; i < max ; i ++ ) { methodInvocation . typeArguments ( ) . add ( convertType ( typeArguments [ i ] ) ) ; } break ; } } expr = methodInvocation ; } expr . setSourceRange ( sourceStart , expression . sourceEnd - sourceStart + <NUM_LIT:1> ) ; removeTrailingCommentFromExpressionEndingWithAParen ( expr ) ; return expr ; } public MarkerAnnotation convert ( org . eclipse . jdt . internal . compiler . ast . MarkerAnnotation annotation ) { final MarkerAnnotation markerAnnotation = new MarkerAnnotation ( this . ast ) ; setTypeNameForAnnotation ( annotation , markerAnnotation ) ; int start = annotation . sourceStart ; int end = annotation . declarationSourceEnd ; markerAnnotation . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; if ( this . resolveBindings ) { recordNodes ( markerAnnotation , annotation ) ; markerAnnotation . resolveAnnotationBinding ( ) ; } return markerAnnotation ; } public MemberValuePair convert ( org . eclipse . jdt . internal . compiler . ast . MemberValuePair memberValuePair ) { final MemberValuePair pair = new MemberValuePair ( this . ast ) ; final SimpleName simpleName = new SimpleName ( this . ast ) ; simpleName . internalSetIdentifier ( new String ( memberValuePair . name ) ) ; int start = memberValuePair . sourceStart ; int end = memberValuePair . sourceEnd ; simpleName . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; pair . setName ( simpleName ) ; final Expression value = convert ( memberValuePair . value ) ; pair . setValue ( value ) ; start = memberValuePair . sourceStart ; end = value . getStartPosition ( ) + value . getLength ( ) - <NUM_LIT:1> ; pair . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; if ( memberValuePair . value instanceof SingleNameReference && ( ( SingleNameReference ) memberValuePair . value ) . token == RecoveryScanner . FAKE_IDENTIFIER ) { pair . setFlags ( pair . getFlags ( ) | ASTNode . RECOVERED ) ; } if ( this . resolveBindings ) { recordNodes ( simpleName , memberValuePair ) ; recordNodes ( pair , memberValuePair ) ; } return pair ; } public Name convert ( org . eclipse . jdt . internal . compiler . ast . NameReference reference ) { if ( reference instanceof org . eclipse . jdt . internal . compiler . ast . QualifiedNameReference ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . QualifiedNameReference ) reference ) ; } else { return convert ( ( org . eclipse . jdt . internal . compiler . ast . SingleNameReference ) reference ) ; } } public InfixExpression convert ( StringLiteralConcatenation expression ) { expression . computeConstant ( ) ; final InfixExpression infixExpression = new InfixExpression ( this . ast ) ; infixExpression . setOperator ( InfixExpression . Operator . PLUS ) ; org . eclipse . jdt . internal . compiler . ast . Expression [ ] stringLiterals = expression . literals ; infixExpression . setLeftOperand ( convert ( stringLiterals [ <NUM_LIT:0> ] ) ) ; infixExpression . setRightOperand ( convert ( stringLiterals [ <NUM_LIT:1> ] ) ) ; for ( int i = <NUM_LIT:2> ; i < expression . counter ; i ++ ) { infixExpression . extendedOperands ( ) . add ( convert ( stringLiterals [ i ] ) ) ; } if ( this . resolveBindings ) { this . recordNodes ( infixExpression , expression ) ; } infixExpression . setSourceRange ( expression . sourceStart , expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ) ; return infixExpression ; } public NormalAnnotation convert ( org . eclipse . jdt . internal . compiler . ast . NormalAnnotation annotation ) { final NormalAnnotation normalAnnotation = new NormalAnnotation ( this . ast ) ; setTypeNameForAnnotation ( annotation , normalAnnotation ) ; int start = annotation . sourceStart ; int end = annotation . declarationSourceEnd ; org . eclipse . jdt . internal . compiler . ast . MemberValuePair [ ] memberValuePairs = annotation . memberValuePairs ; if ( memberValuePairs != null ) { for ( int i = <NUM_LIT:0> , max = memberValuePairs . length ; i < max ; i ++ ) { MemberValuePair memberValuePair = convert ( memberValuePairs [ i ] ) ; int memberValuePairEnd = memberValuePair . getStartPosition ( ) + memberValuePair . getLength ( ) - <NUM_LIT:1> ; if ( end == memberValuePairEnd ) { normalAnnotation . setFlags ( normalAnnotation . getFlags ( ) | ASTNode . RECOVERED ) ; } normalAnnotation . values ( ) . add ( memberValuePair ) ; } } normalAnnotation . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; if ( this . resolveBindings ) { recordNodes ( normalAnnotation , annotation ) ; normalAnnotation . resolveAnnotationBinding ( ) ; } return normalAnnotation ; } public NullLiteral convert ( org . eclipse . jdt . internal . compiler . ast . NullLiteral expression ) { final NullLiteral literal = new NullLiteral ( this . ast ) ; if ( this . resolveBindings ) { this . recordNodes ( literal , expression ) ; } literal . setSourceRange ( expression . sourceStart , expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ) ; return literal ; } public Expression convert ( org . eclipse . jdt . internal . compiler . ast . OR_OR_Expression expression ) { InfixExpression infixExpression = new InfixExpression ( this . ast ) ; infixExpression . setOperator ( InfixExpression . Operator . CONDITIONAL_OR ) ; if ( this . resolveBindings ) { this . recordNodes ( infixExpression , expression ) ; } final int expressionOperatorID = ( expression . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorMASK ) > > org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorSHIFT ; if ( expression . left instanceof org . eclipse . jdt . internal . compiler . ast . BinaryExpression && ( ( expression . left . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedMASK ) == <NUM_LIT:0> ) ) { infixExpression . extendedOperands ( ) . add ( convert ( expression . right ) ) ; org . eclipse . jdt . internal . compiler . ast . Expression leftOperand = expression . left ; org . eclipse . jdt . internal . compiler . ast . Expression rightOperand = null ; do { rightOperand = ( ( org . eclipse . jdt . internal . compiler . ast . BinaryExpression ) leftOperand ) . right ; if ( ( ( ( leftOperand . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorMASK ) > > org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorSHIFT ) != expressionOperatorID && ( ( leftOperand . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedMASK ) == <NUM_LIT:0> ) ) || ( ( rightOperand instanceof org . eclipse . jdt . internal . compiler . ast . BinaryExpression && ( ( rightOperand . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorMASK ) > > org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorSHIFT ) != expressionOperatorID ) && ( ( rightOperand . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedMASK ) == <NUM_LIT:0> ) ) ) { List extendedOperands = infixExpression . extendedOperands ( ) ; InfixExpression temp = new InfixExpression ( this . ast ) ; if ( this . resolveBindings ) { this . recordNodes ( temp , expression ) ; } temp . setOperator ( getOperatorFor ( expressionOperatorID ) ) ; Expression leftSide = convert ( leftOperand ) ; temp . setLeftOperand ( leftSide ) ; temp . setSourceRange ( leftSide . getStartPosition ( ) , leftSide . getLength ( ) ) ; int size = extendedOperands . size ( ) ; for ( int i = <NUM_LIT:0> ; i < size - <NUM_LIT:1> ; i ++ ) { Expression expr = temp ; temp = new InfixExpression ( this . ast ) ; if ( this . resolveBindings ) { this . recordNodes ( temp , expression ) ; } temp . setLeftOperand ( expr ) ; temp . setOperator ( getOperatorFor ( expressionOperatorID ) ) ; temp . setSourceRange ( expr . getStartPosition ( ) , expr . getLength ( ) ) ; } infixExpression = temp ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { Expression extendedOperand = ( Expression ) extendedOperands . remove ( size - <NUM_LIT:1> - i ) ; temp . setRightOperand ( extendedOperand ) ; int startPosition = temp . getLeftOperand ( ) . getStartPosition ( ) ; temp . setSourceRange ( startPosition , extendedOperand . getStartPosition ( ) + extendedOperand . getLength ( ) - startPosition ) ; if ( temp . getLeftOperand ( ) . getNodeType ( ) == ASTNode . INFIX_EXPRESSION ) { temp = ( InfixExpression ) temp . getLeftOperand ( ) ; } } int startPosition = infixExpression . getLeftOperand ( ) . getStartPosition ( ) ; infixExpression . setSourceRange ( startPosition , expression . sourceEnd - startPosition + <NUM_LIT:1> ) ; if ( this . resolveBindings ) { this . recordNodes ( infixExpression , expression ) ; } return infixExpression ; } infixExpression . extendedOperands ( ) . add ( <NUM_LIT:0> , convert ( rightOperand ) ) ; leftOperand = ( ( org . eclipse . jdt . internal . compiler . ast . BinaryExpression ) leftOperand ) . left ; } while ( leftOperand instanceof org . eclipse . jdt . internal . compiler . ast . BinaryExpression && ( ( leftOperand . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedMASK ) == <NUM_LIT:0> ) ) ; Expression leftExpression = convert ( leftOperand ) ; infixExpression . setLeftOperand ( leftExpression ) ; infixExpression . setRightOperand ( ( Expression ) infixExpression . extendedOperands ( ) . remove ( <NUM_LIT:0> ) ) ; int startPosition = leftExpression . getStartPosition ( ) ; infixExpression . setSourceRange ( startPosition , expression . sourceEnd - startPosition + <NUM_LIT:1> ) ; return infixExpression ; } Expression leftExpression = convert ( expression . left ) ; infixExpression . setLeftOperand ( leftExpression ) ; infixExpression . setRightOperand ( convert ( expression . right ) ) ; infixExpression . setOperator ( InfixExpression . Operator . CONDITIONAL_OR ) ; int startPosition = leftExpression . getStartPosition ( ) ; infixExpression . setSourceRange ( startPosition , expression . sourceEnd - startPosition + <NUM_LIT:1> ) ; return infixExpression ; } public PostfixExpression convert ( org . eclipse . jdt . internal . compiler . ast . PostfixExpression expression ) { final PostfixExpression postfixExpression = new PostfixExpression ( this . ast ) ; if ( this . resolveBindings ) { recordNodes ( postfixExpression , expression ) ; } postfixExpression . setSourceRange ( expression . sourceStart , expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ) ; postfixExpression . setOperand ( convert ( expression . lhs ) ) ; switch ( expression . operator ) { case org . eclipse . jdt . internal . compiler . ast . OperatorIds . PLUS : postfixExpression . setOperator ( PostfixExpression . Operator . INCREMENT ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . MINUS : postfixExpression . setOperator ( PostfixExpression . Operator . DECREMENT ) ; break ; } return postfixExpression ; } public PrefixExpression convert ( org . eclipse . jdt . internal . compiler . ast . PrefixExpression expression ) { final PrefixExpression prefixExpression = new PrefixExpression ( this . ast ) ; if ( this . resolveBindings ) { recordNodes ( prefixExpression , expression ) ; } prefixExpression . setSourceRange ( expression . sourceStart , expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ) ; prefixExpression . setOperand ( convert ( expression . lhs ) ) ; switch ( expression . operator ) { case org . eclipse . jdt . internal . compiler . ast . OperatorIds . PLUS : prefixExpression . setOperator ( PrefixExpression . Operator . INCREMENT ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . MINUS : prefixExpression . setOperator ( PrefixExpression . Operator . DECREMENT ) ; break ; } return prefixExpression ; } public Expression convert ( org . eclipse . jdt . internal . compiler . ast . QualifiedAllocationExpression allocation ) { final ClassInstanceCreation classInstanceCreation = new ClassInstanceCreation ( this . ast ) ; if ( allocation . enclosingInstance != null ) { classInstanceCreation . setExpression ( convert ( allocation . enclosingInstance ) ) ; } switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : classInstanceCreation . internalSetName ( convert ( allocation . type ) ) ; break ; case AST . JLS3 : classInstanceCreation . setType ( convertType ( allocation . type ) ) ; } org . eclipse . jdt . internal . compiler . ast . Expression [ ] arguments = allocation . arguments ; if ( arguments != null ) { int length = arguments . length ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { Expression argument = convert ( arguments [ i ] ) ; if ( this . resolveBindings ) { recordNodes ( argument , arguments [ i ] ) ; } classInstanceCreation . arguments ( ) . add ( argument ) ; } } if ( allocation . typeArguments != null ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : classInstanceCreation . setFlags ( classInstanceCreation . getFlags ( ) | ASTNode . MALFORMED ) ; break ; case AST . JLS3 : for ( int i = <NUM_LIT:0> , max = allocation . typeArguments . length ; i < max ; i ++ ) { classInstanceCreation . typeArguments ( ) . add ( convertType ( allocation . typeArguments [ i ] ) ) ; } } } if ( allocation . anonymousType != null ) { int declarationSourceStart = allocation . sourceStart ; classInstanceCreation . setSourceRange ( declarationSourceStart , allocation . anonymousType . bodyEnd - declarationSourceStart + <NUM_LIT:1> ) ; final AnonymousClassDeclaration anonymousClassDeclaration = new AnonymousClassDeclaration ( this . ast ) ; int start = retrieveStartBlockPosition ( allocation . anonymousType . sourceEnd , allocation . anonymousType . bodyEnd ) ; anonymousClassDeclaration . setSourceRange ( start , allocation . anonymousType . bodyEnd - start + <NUM_LIT:1> ) ; classInstanceCreation . setAnonymousClassDeclaration ( anonymousClassDeclaration ) ; buildBodyDeclarations ( allocation . anonymousType , anonymousClassDeclaration ) ; if ( this . resolveBindings ) { recordNodes ( classInstanceCreation , allocation . anonymousType ) ; recordNodes ( anonymousClassDeclaration , allocation . anonymousType ) ; anonymousClassDeclaration . resolveBinding ( ) ; } return classInstanceCreation ; } else { final int start = allocation . sourceStart ; classInstanceCreation . setSourceRange ( start , allocation . sourceEnd - start + <NUM_LIT:1> ) ; if ( this . resolveBindings ) { recordNodes ( classInstanceCreation , allocation ) ; } removeTrailingCommentFromExpressionEndingWithAParen ( classInstanceCreation ) ; return classInstanceCreation ; } } public Name convert ( org . eclipse . jdt . internal . compiler . ast . QualifiedNameReference nameReference ) { return setQualifiedNameNameAndSourceRanges ( nameReference . tokens , nameReference . sourcePositions , nameReference ) ; } public Name convert ( org . eclipse . jdt . internal . compiler . ast . QualifiedSuperReference reference ) { return convert ( reference . qualification ) ; } public ThisExpression convert ( org . eclipse . jdt . internal . compiler . ast . QualifiedThisReference reference ) { final ThisExpression thisExpression = new ThisExpression ( this . ast ) ; thisExpression . setSourceRange ( reference . sourceStart , reference . sourceEnd - reference . sourceStart + <NUM_LIT:1> ) ; thisExpression . setQualifier ( convert ( reference . qualification ) ) ; if ( this . resolveBindings ) { recordNodes ( thisExpression , reference ) ; recordPendingThisExpressionScopeResolution ( thisExpression ) ; } return thisExpression ; } public Expression convert ( org . eclipse . jdt . internal . compiler . ast . Reference reference ) { if ( reference instanceof org . eclipse . jdt . internal . compiler . ast . NameReference ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . NameReference ) reference ) ; } if ( reference instanceof org . eclipse . jdt . internal . compiler . ast . ThisReference ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . ThisReference ) reference ) ; } if ( reference instanceof org . eclipse . jdt . internal . compiler . ast . ArrayReference ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . ArrayReference ) reference ) ; } if ( reference instanceof org . eclipse . jdt . internal . compiler . ast . FieldReference ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . FieldReference ) reference ) ; } return null ; } public ReturnStatement convert ( org . eclipse . jdt . internal . compiler . ast . ReturnStatement statement ) { final ReturnStatement returnStatement = new ReturnStatement ( this . ast ) ; returnStatement . setSourceRange ( statement . sourceStart , statement . sourceEnd - statement . sourceStart + <NUM_LIT:1> ) ; if ( statement . expression != null ) { returnStatement . setExpression ( convert ( statement . expression ) ) ; } return returnStatement ; } public SingleMemberAnnotation convert ( org . eclipse . jdt . internal . compiler . ast . SingleMemberAnnotation annotation ) { final SingleMemberAnnotation singleMemberAnnotation = new SingleMemberAnnotation ( this . ast ) ; setTypeNameForAnnotation ( annotation , singleMemberAnnotation ) ; singleMemberAnnotation . setValue ( convert ( annotation . memberValue ) ) ; int start = annotation . sourceStart ; int end = annotation . declarationSourceEnd ; singleMemberAnnotation . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; if ( this . resolveBindings ) { recordNodes ( singleMemberAnnotation , annotation ) ; singleMemberAnnotation . resolveAnnotationBinding ( ) ; } return singleMemberAnnotation ; } public SimpleName convert ( org . eclipse . jdt . internal . compiler . ast . SingleNameReference nameReference ) { final SimpleName name = new SimpleName ( this . ast ) ; name . internalSetIdentifier ( new String ( nameReference . token ) ) ; if ( this . resolveBindings ) { recordNodes ( name , nameReference ) ; } name . setSourceRange ( nameReference . sourceStart , nameReference . sourceEnd - nameReference . sourceStart + <NUM_LIT:1> ) ; return name ; } public Statement convert ( org . eclipse . jdt . internal . compiler . ast . Statement statement ) { if ( statement instanceof ForeachStatement ) { return convert ( ( ForeachStatement ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ) { org . eclipse . jdt . internal . compiler . ast . LocalDeclaration localDeclaration = ( org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ) statement ; return convertToVariableDeclarationStatement ( localDeclaration ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . AssertStatement ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . AssertStatement ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . Block ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . Block ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . BreakStatement ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . BreakStatement ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . ContinueStatement ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . ContinueStatement ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . CaseStatement ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . CaseStatement ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . DoStatement ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . DoStatement ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . EmptyStatement ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . EmptyStatement ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . ExplicitConstructorCall ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . ExplicitConstructorCall ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . ForStatement ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . ForStatement ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . IfStatement ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . IfStatement ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . LabeledStatement ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . LabeledStatement ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . ReturnStatement ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . ReturnStatement ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . SwitchStatement ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . SwitchStatement ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . SynchronizedStatement ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . SynchronizedStatement ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . ThrowStatement ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . ThrowStatement ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . TryStatement ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . TryStatement ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) { ASTNode result = convert ( ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) statement ) ; if ( result == null ) { return createFakeEmptyStatement ( statement ) ; } switch ( result . getNodeType ( ) ) { case ASTNode . ENUM_DECLARATION : switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : return createFakeEmptyStatement ( statement ) ; case AST . JLS3 : final TypeDeclarationStatement typeDeclarationStatement = new TypeDeclarationStatement ( this . ast ) ; typeDeclarationStatement . setDeclaration ( ( EnumDeclaration ) result ) ; AbstractTypeDeclaration typeDecl = typeDeclarationStatement . getDeclaration ( ) ; typeDeclarationStatement . setSourceRange ( typeDecl . getStartPosition ( ) , typeDecl . getLength ( ) ) ; return typeDeclarationStatement ; } break ; case ASTNode . ANNOTATION_TYPE_DECLARATION : switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : return createFakeEmptyStatement ( statement ) ; case AST . JLS3 : TypeDeclarationStatement typeDeclarationStatement = new TypeDeclarationStatement ( this . ast ) ; typeDeclarationStatement . setDeclaration ( ( AnnotationTypeDeclaration ) result ) ; AbstractTypeDeclaration typeDecl = typeDeclarationStatement . getDeclaration ( ) ; typeDeclarationStatement . setSourceRange ( typeDecl . getStartPosition ( ) , typeDecl . getLength ( ) ) ; return typeDeclarationStatement ; } break ; default : TypeDeclaration typeDeclaration = ( TypeDeclaration ) result ; TypeDeclarationStatement typeDeclarationStatement = new TypeDeclarationStatement ( this . ast ) ; typeDeclarationStatement . setDeclaration ( typeDeclaration ) ; switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : TypeDeclaration typeDecl = typeDeclarationStatement . internalGetTypeDeclaration ( ) ; typeDeclarationStatement . setSourceRange ( typeDecl . getStartPosition ( ) , typeDecl . getLength ( ) ) ; break ; case AST . JLS3 : AbstractTypeDeclaration typeDeclAST3 = typeDeclarationStatement . getDeclaration ( ) ; typeDeclarationStatement . setSourceRange ( typeDeclAST3 . getStartPosition ( ) , typeDeclAST3 . getLength ( ) ) ; break ; } return typeDeclarationStatement ; } } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . WhileStatement ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . WhileStatement ) statement ) ; } if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . Expression ) { org . eclipse . jdt . internal . compiler . ast . Expression statement2 = ( org . eclipse . jdt . internal . compiler . ast . Expression ) statement ; final Expression expr = convert ( statement2 ) ; final ExpressionStatement stmt = new ExpressionStatement ( this . ast ) ; stmt . setExpression ( expr ) ; int sourceStart = expr . getStartPosition ( ) ; int sourceEnd = statement2 . statementEnd ; stmt . setSourceRange ( sourceStart , sourceEnd - sourceStart + <NUM_LIT:1> ) ; return stmt ; } return createFakeEmptyStatement ( statement ) ; } public Expression convert ( org . eclipse . jdt . internal . compiler . ast . StringLiteral expression ) { if ( expression instanceof StringLiteralConcatenation ) { return convert ( ( StringLiteralConcatenation ) expression ) ; } int length = expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ; int sourceStart = expression . sourceStart ; StringLiteral literal = new StringLiteral ( this . ast ) ; if ( this . resolveBindings ) { this . recordNodes ( literal , expression ) ; } literal . internalSetEscapedValue ( new String ( this . compilationUnitSource , sourceStart , length ) ) ; literal . setSourceRange ( expression . sourceStart , expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ) ; return literal ; } public SwitchStatement convert ( org . eclipse . jdt . internal . compiler . ast . SwitchStatement statement ) { SwitchStatement switchStatement = new SwitchStatement ( this . ast ) ; switchStatement . setSourceRange ( statement . sourceStart , statement . sourceEnd - statement . sourceStart + <NUM_LIT:1> ) ; switchStatement . setExpression ( convert ( statement . expression ) ) ; org . eclipse . jdt . internal . compiler . ast . Statement [ ] statements = statement . statements ; if ( statements != null ) { int statementsLength = statements . length ; for ( int i = <NUM_LIT:0> ; i < statementsLength ; i ++ ) { if ( statements [ i ] instanceof org . eclipse . jdt . internal . compiler . ast . LocalDeclaration ) { checkAndAddMultipleLocalDeclaration ( statements , i , switchStatement . statements ( ) ) ; } else { final Statement currentStatement = convert ( statements [ i ] ) ; if ( currentStatement != null ) { switchStatement . statements ( ) . add ( currentStatement ) ; } } } } return switchStatement ; } public SynchronizedStatement convert ( org . eclipse . jdt . internal . compiler . ast . SynchronizedStatement statement ) { SynchronizedStatement synchronizedStatement = new SynchronizedStatement ( this . ast ) ; synchronizedStatement . setSourceRange ( statement . sourceStart , statement . sourceEnd - statement . sourceStart + <NUM_LIT:1> ) ; synchronizedStatement . setBody ( convert ( statement . block ) ) ; synchronizedStatement . setExpression ( convert ( statement . expression ) ) ; return synchronizedStatement ; } public Expression convert ( org . eclipse . jdt . internal . compiler . ast . ThisReference reference ) { if ( reference . isImplicitThis ( ) ) { return null ; } else if ( reference instanceof org . eclipse . jdt . internal . compiler . ast . QualifiedSuperReference ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . QualifiedSuperReference ) reference ) ; } else if ( reference instanceof org . eclipse . jdt . internal . compiler . ast . QualifiedThisReference ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . QualifiedThisReference ) reference ) ; } else { ThisExpression thisExpression = new ThisExpression ( this . ast ) ; thisExpression . setSourceRange ( reference . sourceStart , reference . sourceEnd - reference . sourceStart + <NUM_LIT:1> ) ; if ( this . resolveBindings ) { recordNodes ( thisExpression , reference ) ; recordPendingThisExpressionScopeResolution ( thisExpression ) ; } return thisExpression ; } } public ThrowStatement convert ( org . eclipse . jdt . internal . compiler . ast . ThrowStatement statement ) { final ThrowStatement throwStatement = new ThrowStatement ( this . ast ) ; throwStatement . setSourceRange ( statement . sourceStart , statement . sourceEnd - statement . sourceStart + <NUM_LIT:1> ) ; throwStatement . setExpression ( convert ( statement . exception ) ) ; return throwStatement ; } public BooleanLiteral convert ( org . eclipse . jdt . internal . compiler . ast . TrueLiteral expression ) { final BooleanLiteral literal = new BooleanLiteral ( this . ast ) ; literal . setBooleanValue ( true ) ; if ( this . resolveBindings ) { this . recordNodes ( literal , expression ) ; } literal . setSourceRange ( expression . sourceStart , expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ) ; return literal ; } public TryStatement convert ( org . eclipse . jdt . internal . compiler . ast . TryStatement statement ) { final TryStatement tryStatement = new TryStatement ( this . ast ) ; tryStatement . setSourceRange ( statement . sourceStart , statement . sourceEnd - statement . sourceStart + <NUM_LIT:1> ) ; tryStatement . setBody ( convert ( statement . tryBlock ) ) ; org . eclipse . jdt . internal . compiler . ast . Argument [ ] catchArguments = statement . catchArguments ; if ( catchArguments != null ) { int catchArgumentsLength = catchArguments . length ; org . eclipse . jdt . internal . compiler . ast . Block [ ] catchBlocks = statement . catchBlocks ; int start = statement . tryBlock . sourceEnd ; for ( int i = <NUM_LIT:0> ; i < catchArgumentsLength ; i ++ ) { CatchClause catchClause = new CatchClause ( this . ast ) ; int catchClauseSourceStart = retrieveStartingCatchPosition ( start , catchArguments [ i ] . sourceStart ) ; catchClause . setSourceRange ( catchClauseSourceStart , catchBlocks [ i ] . sourceEnd - catchClauseSourceStart + <NUM_LIT:1> ) ; catchClause . setBody ( convert ( catchBlocks [ i ] ) ) ; catchClause . setException ( convert ( catchArguments [ i ] ) ) ; tryStatement . catchClauses ( ) . add ( catchClause ) ; start = catchBlocks [ i ] . sourceEnd ; } } if ( statement . finallyBlock != null ) { tryStatement . setFinally ( convert ( statement . finallyBlock ) ) ; } return tryStatement ; } public ASTNode convert ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration typeDeclaration ) { int kind = org . eclipse . jdt . internal . compiler . ast . TypeDeclaration . kind ( typeDeclaration . modifiers ) ; switch ( kind ) { case org . eclipse . jdt . internal . compiler . ast . TypeDeclaration . ENUM_DECL : if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { return null ; } else { return convertToEnumDeclaration ( typeDeclaration ) ; } case org . eclipse . jdt . internal . compiler . ast . TypeDeclaration . ANNOTATION_TYPE_DECL : if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { return null ; } else { return convertToAnnotationDeclaration ( typeDeclaration ) ; } } checkCanceled ( ) ; TypeDeclaration typeDecl = new TypeDeclaration ( this . ast ) ; if ( typeDeclaration . modifiersSourceStart != - <NUM_LIT:1> ) { setModifiers ( typeDecl , typeDeclaration ) ; } typeDecl . setInterface ( kind == org . eclipse . jdt . internal . compiler . ast . TypeDeclaration . INTERFACE_DECL ) ; final SimpleName typeName = new SimpleName ( this . ast ) ; typeName . internalSetIdentifier ( new String ( typeDeclaration . name ) ) ; typeName . setSourceRange ( typeDeclaration . sourceStart , typeDeclaration . sourceEnd - typeDeclaration . sourceStart + <NUM_LIT:1> ) ; typeDecl . setName ( typeName ) ; typeDecl . setSourceRange ( typeDeclaration . declarationSourceStart , typeDeclaration . bodyEnd - typeDeclaration . declarationSourceStart + <NUM_LIT:1> ) ; if ( typeDeclaration . superclass != null ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : typeDecl . internalSetSuperclass ( convert ( typeDeclaration . superclass ) ) ; break ; case AST . JLS3 : typeDecl . setSuperclassType ( convertType ( typeDeclaration . superclass ) ) ; break ; } } org . eclipse . jdt . internal . compiler . ast . TypeReference [ ] superInterfaces = typeDeclaration . superInterfaces ; if ( superInterfaces != null ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : for ( int index = <NUM_LIT:0> , length = superInterfaces . length ; index < length ; index ++ ) { typeDecl . internalSuperInterfaces ( ) . add ( convert ( superInterfaces [ index ] ) ) ; } break ; case AST . JLS3 : for ( int index = <NUM_LIT:0> , length = superInterfaces . length ; index < length ; index ++ ) { typeDecl . superInterfaceTypes ( ) . add ( convertType ( superInterfaces [ index ] ) ) ; } } } org . eclipse . jdt . internal . compiler . ast . TypeParameter [ ] typeParameters = typeDeclaration . typeParameters ; if ( typeParameters != null ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : typeDecl . setFlags ( typeDecl . getFlags ( ) | ASTNode . MALFORMED ) ; break ; case AST . JLS3 : for ( int index = <NUM_LIT:0> , length = typeParameters . length ; index < length ; index ++ ) { typeDecl . typeParameters ( ) . add ( convert ( typeParameters [ index ] ) ) ; } } } buildBodyDeclarations ( typeDeclaration , typeDecl ) ; if ( this . resolveBindings ) { recordNodes ( typeDecl , typeDeclaration ) ; recordNodes ( typeName , typeDeclaration ) ; typeDecl . resolveBinding ( ) ; } return typeDecl ; } public TypeParameter convert ( org . eclipse . jdt . internal . compiler . ast . TypeParameter typeParameter ) { final TypeParameter typeParameter2 = new TypeParameter ( this . ast ) ; final SimpleName simpleName = new SimpleName ( this . ast ) ; simpleName . internalSetIdentifier ( new String ( typeParameter . name ) ) ; int start = typeParameter . sourceStart ; int end = typeParameter . sourceEnd ; simpleName . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; typeParameter2 . setName ( simpleName ) ; final TypeReference superType = typeParameter . type ; end = typeParameter . declarationSourceEnd ; if ( superType != null ) { Type type = convertType ( superType ) ; typeParameter2 . typeBounds ( ) . add ( type ) ; end = type . getStartPosition ( ) + type . getLength ( ) - <NUM_LIT:1> ; } TypeReference [ ] bounds = typeParameter . bounds ; if ( bounds != null ) { Type type = null ; for ( int index = <NUM_LIT:0> , length = bounds . length ; index < length ; index ++ ) { type = convertType ( bounds [ index ] ) ; typeParameter2 . typeBounds ( ) . add ( type ) ; end = type . getStartPosition ( ) + type . getLength ( ) - <NUM_LIT:1> ; } } start = typeParameter . declarationSourceStart ; end = retrieveClosingAngleBracketPosition ( end ) ; typeParameter2 . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; if ( this . resolveBindings ) { recordName ( simpleName , typeParameter ) ; recordNodes ( typeParameter2 , typeParameter ) ; typeParameter2 . resolveBinding ( ) ; } return typeParameter2 ; } public Name convert ( org . eclipse . jdt . internal . compiler . ast . TypeReference typeReference ) { char [ ] [ ] typeName = typeReference . getTypeName ( ) ; int length = typeName . length ; if ( length > <NUM_LIT:1> ) { org . eclipse . jdt . internal . compiler . ast . QualifiedTypeReference qualifiedTypeReference = ( org . eclipse . jdt . internal . compiler . ast . QualifiedTypeReference ) typeReference ; final long [ ] positions = qualifiedTypeReference . sourcePositions ; return setQualifiedNameNameAndSourceRanges ( typeName , positions , typeReference ) ; } else { final SimpleName name = new SimpleName ( this . ast ) ; name . internalSetIdentifier ( new String ( typeName [ <NUM_LIT:0> ] ) ) ; name . setSourceRange ( typeReference . sourceStart , typeReference . sourceEnd - typeReference . sourceStart + <NUM_LIT:1> ) ; name . index = <NUM_LIT:1> ; if ( this . resolveBindings ) { recordNodes ( name , typeReference ) ; } return name ; } } public PrefixExpression convert ( org . eclipse . jdt . internal . compiler . ast . UnaryExpression expression ) { final PrefixExpression prefixExpression = new PrefixExpression ( this . ast ) ; if ( this . resolveBindings ) { this . recordNodes ( prefixExpression , expression ) ; } prefixExpression . setSourceRange ( expression . sourceStart , expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ) ; prefixExpression . setOperand ( convert ( expression . expression ) ) ; switch ( ( expression . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorMASK ) > > org . eclipse . jdt . internal . compiler . ast . ASTNode . OperatorSHIFT ) { case org . eclipse . jdt . internal . compiler . ast . OperatorIds . PLUS : prefixExpression . setOperator ( PrefixExpression . Operator . PLUS ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . MINUS : prefixExpression . setOperator ( PrefixExpression . Operator . MINUS ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . NOT : prefixExpression . setOperator ( PrefixExpression . Operator . NOT ) ; break ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . TWIDDLE : prefixExpression . setOperator ( PrefixExpression . Operator . COMPLEMENT ) ; } return prefixExpression ; } public WhileStatement convert ( org . eclipse . jdt . internal . compiler . ast . WhileStatement statement ) { final WhileStatement whileStatement = new WhileStatement ( this . ast ) ; whileStatement . setSourceRange ( statement . sourceStart , statement . sourceEnd - statement . sourceStart + <NUM_LIT:1> ) ; whileStatement . setExpression ( convert ( statement . condition ) ) ; final Statement action = convert ( statement . action ) ; if ( action == null ) return null ; whileStatement . setBody ( action ) ; return whileStatement ; } public ImportDeclaration convertImport ( org . eclipse . jdt . internal . compiler . ast . ImportReference importReference ) { final ImportDeclaration importDeclaration = new ImportDeclaration ( this . ast ) ; final boolean onDemand = ( importReference . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . OnDemand ) != <NUM_LIT:0> ; final char [ ] [ ] tokens = importReference . tokens ; int length = importReference . tokens . length ; final long [ ] positions = importReference . sourcePositions ; if ( length > <NUM_LIT:1> ) { importDeclaration . setName ( setQualifiedNameNameAndSourceRanges ( tokens , positions , importReference ) ) ; } else { final SimpleName name = new SimpleName ( this . ast ) ; name . internalSetIdentifier ( new String ( tokens [ <NUM_LIT:0> ] ) ) ; final int start = ( int ) ( positions [ <NUM_LIT:0> ] > > > <NUM_LIT:32> ) ; final int end = ( int ) ( positions [ <NUM_LIT:0> ] & <NUM_LIT> ) ; name . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; name . index = <NUM_LIT:1> ; importDeclaration . setName ( name ) ; if ( this . resolveBindings ) { recordNodes ( name , importReference ) ; } } importDeclaration . setSourceRange ( importReference . declarationSourceStart , importReference . declarationEnd - importReference . declarationSourceStart + <NUM_LIT:1> ) ; importDeclaration . setOnDemand ( onDemand ) ; int modifiers = importReference . modifiers ; if ( modifiers != ClassFileConstants . AccDefault ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : importDeclaration . setFlags ( importDeclaration . getFlags ( ) | ASTNode . MALFORMED ) ; break ; case AST . JLS3 : if ( modifiers == ClassFileConstants . AccStatic ) { importDeclaration . setStatic ( true ) ; } else { importDeclaration . setFlags ( importDeclaration . getFlags ( ) | ASTNode . MALFORMED ) ; } } } if ( this . resolveBindings ) { recordNodes ( importDeclaration , importReference ) ; } return importDeclaration ; } public PackageDeclaration convertPackage ( org . eclipse . jdt . internal . compiler . ast . CompilationUnitDeclaration compilationUnitDeclaration ) { org . eclipse . jdt . internal . compiler . ast . ImportReference importReference = compilationUnitDeclaration . currentPackage ; final PackageDeclaration packageDeclaration = new PackageDeclaration ( this . ast ) ; final char [ ] [ ] tokens = importReference . tokens ; final int length = importReference . tokens . length ; long [ ] positions = importReference . sourcePositions ; if ( length > <NUM_LIT:1> ) { packageDeclaration . setName ( setQualifiedNameNameAndSourceRanges ( tokens , positions , importReference ) ) ; } else { final SimpleName name = new SimpleName ( this . ast ) ; name . internalSetIdentifier ( new String ( tokens [ <NUM_LIT:0> ] ) ) ; int start = ( int ) ( positions [ <NUM_LIT:0> ] > > > <NUM_LIT:32> ) ; int end = ( int ) ( positions [ length - <NUM_LIT:1> ] & <NUM_LIT> ) ; name . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; name . index = <NUM_LIT:1> ; packageDeclaration . setName ( name ) ; if ( this . resolveBindings ) { recordNodes ( name , compilationUnitDeclaration ) ; } } packageDeclaration . setSourceRange ( importReference . declarationSourceStart , importReference . declarationEnd - importReference . declarationSourceStart + <NUM_LIT:1> ) ; org . eclipse . jdt . internal . compiler . ast . Annotation [ ] annotations = importReference . annotations ; if ( annotations != null ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : packageDeclaration . setFlags ( packageDeclaration . getFlags ( ) & ASTNode . MALFORMED ) ; break ; case AST . JLS3 : for ( int i = <NUM_LIT:0> , max = annotations . length ; i < max ; i ++ ) { packageDeclaration . annotations ( ) . add ( convert ( annotations [ i ] ) ) ; } } } if ( this . resolveBindings ) { recordNodes ( packageDeclaration , importReference ) ; } convert ( compilationUnitDeclaration . javadoc , packageDeclaration ) ; return packageDeclaration ; } private EnumDeclaration convertToEnumDeclaration ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration typeDeclaration ) { checkCanceled ( ) ; final EnumDeclaration enumDeclaration2 = new EnumDeclaration ( this . ast ) ; setModifiers ( enumDeclaration2 , typeDeclaration ) ; final SimpleName typeName = new SimpleName ( this . ast ) ; typeName . internalSetIdentifier ( new String ( typeDeclaration . name ) ) ; typeName . setSourceRange ( typeDeclaration . sourceStart , typeDeclaration . sourceEnd - typeDeclaration . sourceStart + <NUM_LIT:1> ) ; enumDeclaration2 . setName ( typeName ) ; enumDeclaration2 . setSourceRange ( typeDeclaration . declarationSourceStart , typeDeclaration . bodyEnd - typeDeclaration . declarationSourceStart + <NUM_LIT:1> ) ; org . eclipse . jdt . internal . compiler . ast . TypeReference [ ] superInterfaces = typeDeclaration . superInterfaces ; if ( superInterfaces != null ) { for ( int index = <NUM_LIT:0> , length = superInterfaces . length ; index < length ; index ++ ) { enumDeclaration2 . superInterfaceTypes ( ) . add ( convertType ( superInterfaces [ index ] ) ) ; } } buildBodyDeclarations ( typeDeclaration , enumDeclaration2 ) ; if ( this . resolveBindings ) { recordNodes ( enumDeclaration2 , typeDeclaration ) ; recordNodes ( typeName , typeDeclaration ) ; enumDeclaration2 . resolveBinding ( ) ; } return enumDeclaration2 ; } public Expression convertToExpression ( org . eclipse . jdt . internal . compiler . ast . Statement statement ) { if ( statement instanceof org . eclipse . jdt . internal . compiler . ast . Expression ) { return convert ( ( org . eclipse . jdt . internal . compiler . ast . Expression ) statement ) ; } else { return null ; } } protected FieldDeclaration convertToFieldDeclaration ( org . eclipse . jdt . internal . compiler . ast . FieldDeclaration fieldDecl ) { VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment ( fieldDecl ) ; final FieldDeclaration fieldDeclaration = new FieldDeclaration ( this . ast ) ; fieldDeclaration . fragments ( ) . add ( variableDeclarationFragment ) ; if ( this . resolveBindings ) { recordNodes ( variableDeclarationFragment , fieldDecl ) ; variableDeclarationFragment . resolveBinding ( ) ; } fieldDeclaration . setSourceRange ( fieldDecl . declarationSourceStart , fieldDecl . declarationEnd - fieldDecl . declarationSourceStart + <NUM_LIT:1> ) ; Type type = convertType ( fieldDecl . type ) ; setTypeForField ( fieldDeclaration , type , variableDeclarationFragment . getExtraDimensions ( ) ) ; setModifiers ( fieldDeclaration , fieldDecl ) ; convert ( fieldDecl . javadoc , fieldDeclaration ) ; return fieldDeclaration ; } public ParenthesizedExpression convertToParenthesizedExpression ( org . eclipse . jdt . internal . compiler . ast . Expression expression ) { final ParenthesizedExpression parenthesizedExpression = new ParenthesizedExpression ( this . ast ) ; if ( this . resolveBindings ) { recordNodes ( parenthesizedExpression , expression ) ; } parenthesizedExpression . setSourceRange ( expression . sourceStart , expression . sourceEnd - expression . sourceStart + <NUM_LIT:1> ) ; adjustSourcePositionsForParent ( expression ) ; trimWhiteSpacesAndComments ( expression ) ; int numberOfParenthesis = ( expression . bits & org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedMASK ) > > org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedSHIFT ; expression . bits &= ~ org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedMASK ; expression . bits |= ( numberOfParenthesis - <NUM_LIT:1> ) << org . eclipse . jdt . internal . compiler . ast . ASTNode . ParenthesizedSHIFT ; parenthesizedExpression . setExpression ( convert ( expression ) ) ; return parenthesizedExpression ; } public Type convertToType ( org . eclipse . jdt . internal . compiler . ast . NameReference reference ) { Name name = convert ( reference ) ; final SimpleType type = new SimpleType ( this . ast ) ; type . setName ( name ) ; type . setSourceRange ( name . getStartPosition ( ) , name . getLength ( ) ) ; if ( this . resolveBindings ) { this . recordNodes ( type , reference ) ; } return type ; } protected VariableDeclarationExpression convertToVariableDeclarationExpression ( org . eclipse . jdt . internal . compiler . ast . LocalDeclaration localDeclaration ) { final VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment ( localDeclaration ) ; final VariableDeclarationExpression variableDeclarationExpression = new VariableDeclarationExpression ( this . ast ) ; variableDeclarationExpression . fragments ( ) . add ( variableDeclarationFragment ) ; if ( this . resolveBindings ) { recordNodes ( variableDeclarationFragment , localDeclaration ) ; } variableDeclarationExpression . setSourceRange ( localDeclaration . declarationSourceStart , localDeclaration . declarationSourceEnd - localDeclaration . declarationSourceStart + <NUM_LIT:1> ) ; Type type = convertType ( localDeclaration . type ) ; setTypeForVariableDeclarationExpression ( variableDeclarationExpression , type , variableDeclarationFragment . getExtraDimensions ( ) ) ; if ( localDeclaration . modifiersSourceStart != - <NUM_LIT:1> ) { setModifiers ( variableDeclarationExpression , localDeclaration ) ; } return variableDeclarationExpression ; } protected SingleVariableDeclaration convertToSingleVariableDeclaration ( LocalDeclaration localDeclaration ) { final SingleVariableDeclaration variableDecl = new SingleVariableDeclaration ( this . ast ) ; setModifiers ( variableDecl , localDeclaration ) ; final SimpleName name = new SimpleName ( this . ast ) ; name . internalSetIdentifier ( new String ( localDeclaration . name ) ) ; int start = localDeclaration . sourceStart ; int nameEnd = localDeclaration . sourceEnd ; name . setSourceRange ( start , nameEnd - start + <NUM_LIT:1> ) ; variableDecl . setName ( name ) ; final int extraDimensions = retrieveExtraDimension ( nameEnd + <NUM_LIT:1> , localDeclaration . type . sourceEnd ) ; variableDecl . setExtraDimensions ( extraDimensions ) ; Type type = convertType ( localDeclaration . type ) ; int typeEnd = type . getStartPosition ( ) + type . getLength ( ) - <NUM_LIT:1> ; int rightEnd = Math . max ( typeEnd , localDeclaration . declarationSourceEnd ) ; setTypeForSingleVariableDeclaration ( variableDecl , type , extraDimensions ) ; variableDecl . setSourceRange ( localDeclaration . declarationSourceStart , rightEnd - localDeclaration . declarationSourceStart + <NUM_LIT:1> ) ; if ( this . resolveBindings ) { recordNodes ( name , localDeclaration ) ; recordNodes ( variableDecl , localDeclaration ) ; variableDecl . resolveBinding ( ) ; } return variableDecl ; } protected VariableDeclarationFragment convertToVariableDeclarationFragment ( org . eclipse . jdt . internal . compiler . ast . FieldDeclaration fieldDeclaration ) { final VariableDeclarationFragment variableDeclarationFragment = new VariableDeclarationFragment ( this . ast ) ; final SimpleName name = new SimpleName ( this . ast ) ; name . internalSetIdentifier ( new String ( fieldDeclaration . name ) ) ; name . setSourceRange ( fieldDeclaration . sourceStart , fieldDeclaration . sourceEnd - fieldDeclaration . sourceStart + <NUM_LIT:1> ) ; variableDeclarationFragment . setName ( name ) ; int start = fieldDeclaration . sourceEnd ; int end = start ; int extraDimensions = retrieveExtraDimension ( fieldDeclaration . sourceEnd + <NUM_LIT:1> , fieldDeclaration . declarationSourceEnd ) ; variableDeclarationFragment . setExtraDimensions ( extraDimensions ) ; if ( fieldDeclaration . initialization != null ) { final Expression expression = convert ( fieldDeclaration . initialization ) ; variableDeclarationFragment . setInitializer ( expression ) ; start = expression . getStartPosition ( ) + expression . getLength ( ) ; end = start - <NUM_LIT:1> ; } else { int possibleEnd = retrieveEndOfPotentialExtendedDimensions ( start + <NUM_LIT:1> , fieldDeclaration . sourceEnd , fieldDeclaration . declarationSourceEnd ) ; if ( possibleEnd == Integer . MIN_VALUE ) { end = fieldDeclaration . declarationSourceEnd ; variableDeclarationFragment . setFlags ( variableDeclarationFragment . getFlags ( ) | ASTNode . MALFORMED ) ; } if ( possibleEnd < <NUM_LIT:0> ) { end = - possibleEnd ; variableDeclarationFragment . setFlags ( variableDeclarationFragment . getFlags ( ) | ASTNode . MALFORMED ) ; } else { end = possibleEnd ; } } variableDeclarationFragment . setSourceRange ( fieldDeclaration . sourceStart , end - fieldDeclaration . sourceStart + <NUM_LIT:1> ) ; if ( this . resolveBindings ) { recordNodes ( name , fieldDeclaration ) ; recordNodes ( variableDeclarationFragment , fieldDeclaration ) ; variableDeclarationFragment . resolveBinding ( ) ; } return variableDeclarationFragment ; } protected VariableDeclarationFragment convertToVariableDeclarationFragment ( org . eclipse . jdt . internal . compiler . ast . LocalDeclaration localDeclaration ) { final VariableDeclarationFragment variableDeclarationFragment = new VariableDeclarationFragment ( this . ast ) ; final SimpleName name = new SimpleName ( this . ast ) ; name . internalSetIdentifier ( new String ( localDeclaration . name ) ) ; name . setSourceRange ( localDeclaration . sourceStart , localDeclaration . sourceEnd - localDeclaration . sourceStart + <NUM_LIT:1> ) ; variableDeclarationFragment . setName ( name ) ; int start = localDeclaration . sourceEnd ; org . eclipse . jdt . internal . compiler . ast . Expression initialization = localDeclaration . initialization ; int extraDimension = retrieveExtraDimension ( localDeclaration . sourceEnd + <NUM_LIT:1> , this . compilationUnitSourceLength ) ; variableDeclarationFragment . setExtraDimensions ( extraDimension ) ; boolean hasInitialization = initialization != null ; int end ; if ( hasInitialization ) { final Expression expression = convert ( initialization ) ; variableDeclarationFragment . setInitializer ( expression ) ; start = expression . getStartPosition ( ) + expression . getLength ( ) ; end = start - <NUM_LIT:1> ; } else { int possibleEnd = retrieveEndOfPotentialExtendedDimensions ( start + <NUM_LIT:1> , localDeclaration . sourceEnd , localDeclaration . declarationSourceEnd ) ; if ( possibleEnd == Integer . MIN_VALUE ) { end = start ; variableDeclarationFragment . setFlags ( variableDeclarationFragment . getFlags ( ) | ASTNode . MALFORMED ) ; } else if ( possibleEnd < <NUM_LIT:0> ) { end = - possibleEnd ; variableDeclarationFragment . setFlags ( variableDeclarationFragment . getFlags ( ) | ASTNode . MALFORMED ) ; } else { end = possibleEnd ; } } variableDeclarationFragment . setSourceRange ( localDeclaration . sourceStart , end - localDeclaration . sourceStart + <NUM_LIT:1> ) ; if ( this . resolveBindings ) { recordNodes ( variableDeclarationFragment , localDeclaration ) ; recordNodes ( name , localDeclaration ) ; variableDeclarationFragment . resolveBinding ( ) ; } return variableDeclarationFragment ; } protected VariableDeclarationStatement convertToVariableDeclarationStatement ( org . eclipse . jdt . internal . compiler . ast . LocalDeclaration localDeclaration ) { final VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment ( localDeclaration ) ; final VariableDeclarationStatement variableDeclarationStatement = new VariableDeclarationStatement ( this . ast ) ; variableDeclarationStatement . fragments ( ) . add ( variableDeclarationFragment ) ; if ( this . resolveBindings ) { recordNodes ( variableDeclarationFragment , localDeclaration ) ; } variableDeclarationStatement . setSourceRange ( localDeclaration . declarationSourceStart , localDeclaration . declarationSourceEnd - localDeclaration . declarationSourceStart + <NUM_LIT:1> ) ; Type type = convertType ( localDeclaration . type ) ; setTypeForVariableDeclarationStatement ( variableDeclarationStatement , type , variableDeclarationFragment . getExtraDimensions ( ) ) ; if ( localDeclaration . modifiersSourceStart != - <NUM_LIT:1> ) { setModifiers ( variableDeclarationStatement , localDeclaration ) ; } return variableDeclarationStatement ; } public Type convertType ( TypeReference typeReference ) { if ( typeReference instanceof Wildcard ) { final Wildcard wildcard = ( Wildcard ) typeReference ; final WildcardType wildcardType = new WildcardType ( this . ast ) ; if ( wildcard . bound != null ) { final Type bound = convertType ( wildcard . bound ) ; wildcardType . setBound ( bound , wildcard . kind == Wildcard . EXTENDS ) ; int start = wildcard . sourceStart ; wildcardType . setSourceRange ( start , bound . getStartPosition ( ) + bound . getLength ( ) - start ) ; } else { final int start = wildcard . sourceStart ; final int end = wildcard . sourceEnd ; wildcardType . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; } if ( this . resolveBindings ) { recordNodes ( wildcardType , typeReference ) ; } return wildcardType ; } Type type = null ; int sourceStart = - <NUM_LIT:1> ; int length = <NUM_LIT:0> ; int dimensions = typeReference . dimensions ( ) ; if ( typeReference instanceof org . eclipse . jdt . internal . compiler . ast . SingleTypeReference ) { char [ ] name = ( ( org . eclipse . jdt . internal . compiler . ast . SingleTypeReference ) typeReference ) . getTypeName ( ) [ <NUM_LIT:0> ] ; sourceStart = typeReference . sourceStart ; length = typeReference . sourceEnd - typeReference . sourceStart + <NUM_LIT:1> ; if ( isPrimitiveType ( name ) ) { int end = retrieveEndOfElementTypeNamePosition ( sourceStart , sourceStart + length ) ; if ( end == - <NUM_LIT:1> ) { end = sourceStart + length - <NUM_LIT:1> ; } final PrimitiveType primitiveType = new PrimitiveType ( this . ast ) ; primitiveType . setPrimitiveTypeCode ( getPrimitiveTypeCode ( name ) ) ; primitiveType . setSourceRange ( sourceStart , end - sourceStart + <NUM_LIT:1> ) ; type = primitiveType ; } else if ( typeReference instanceof ParameterizedSingleTypeReference ) { ParameterizedSingleTypeReference parameterizedSingleTypeReference = ( ParameterizedSingleTypeReference ) typeReference ; final SimpleName simpleName = new SimpleName ( this . ast ) ; simpleName . internalSetIdentifier ( new String ( name ) ) ; int end = retrieveEndOfElementTypeNamePosition ( sourceStart , sourceStart + length ) ; if ( end == - <NUM_LIT:1> ) { end = sourceStart + length - <NUM_LIT:1> ; } simpleName . setSourceRange ( sourceStart , end - sourceStart + <NUM_LIT:1> ) ; switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : SimpleType simpleType = new SimpleType ( this . ast ) ; simpleType . setName ( simpleName ) ; simpleType . setFlags ( simpleType . getFlags ( ) | ASTNode . MALFORMED ) ; simpleType . setSourceRange ( sourceStart , end - sourceStart + <NUM_LIT:1> ) ; type = simpleType ; if ( this . resolveBindings ) { this . recordNodes ( simpleName , typeReference ) ; } break ; case AST . JLS3 : simpleType = new SimpleType ( this . ast ) ; simpleType . setName ( simpleName ) ; simpleType . setSourceRange ( simpleName . getStartPosition ( ) , simpleName . getLength ( ) ) ; final ParameterizedType parameterizedType = new ParameterizedType ( this . ast ) ; parameterizedType . setType ( simpleType ) ; type = parameterizedType ; TypeReference [ ] typeArguments = parameterizedSingleTypeReference . typeArguments ; if ( typeArguments != null ) { Type type2 = null ; for ( int i = <NUM_LIT:0> , max = typeArguments . length ; i < max ; i ++ ) { type2 = convertType ( typeArguments [ i ] ) ; ( ( ParameterizedType ) type ) . typeArguments ( ) . add ( type2 ) ; end = type2 . getStartPosition ( ) + type2 . getLength ( ) - <NUM_LIT:1> ; } end = retrieveClosingAngleBracketPosition ( end + <NUM_LIT:1> ) ; type . setSourceRange ( sourceStart , end - sourceStart + <NUM_LIT:1> ) ; } else { type . setSourceRange ( sourceStart , end - sourceStart + <NUM_LIT:1> ) ; } if ( this . resolveBindings ) { this . recordNodes ( simpleName , typeReference ) ; this . recordNodes ( simpleType , typeReference ) ; } } } else { final SimpleName simpleName = new SimpleName ( this . ast ) ; simpleName . internalSetIdentifier ( new String ( name ) ) ; int end = retrieveEndOfElementTypeNamePosition ( sourceStart , sourceStart + length ) ; if ( end == - <NUM_LIT:1> ) { end = sourceStart + length - <NUM_LIT:1> ; } simpleName . setSourceRange ( sourceStart , end - sourceStart + <NUM_LIT:1> ) ; final SimpleType simpleType = new SimpleType ( this . ast ) ; simpleType . setName ( simpleName ) ; type = simpleType ; type . setSourceRange ( sourceStart , end - sourceStart + <NUM_LIT:1> ) ; type = simpleType ; if ( this . resolveBindings ) { this . recordNodes ( simpleName , typeReference ) ; } } if ( dimensions != <NUM_LIT:0> ) { type = this . ast . newArrayType ( type , dimensions ) ; type . setSourceRange ( sourceStart , length ) ; ArrayType subarrayType = ( ArrayType ) type ; int index = dimensions - <NUM_LIT:1> ; while ( index > <NUM_LIT:0> ) { subarrayType = ( ArrayType ) subarrayType . getComponentType ( ) ; int end = retrieveProperRightBracketPosition ( index , sourceStart ) ; subarrayType . setSourceRange ( sourceStart , end - sourceStart + <NUM_LIT:1> ) ; index -- ; } if ( this . resolveBindings ) { completeRecord ( ( ArrayType ) type , typeReference ) ; } } } else { if ( typeReference instanceof ParameterizedQualifiedTypeReference ) { ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference = ( ParameterizedQualifiedTypeReference ) typeReference ; char [ ] [ ] tokens = parameterizedQualifiedTypeReference . tokens ; TypeReference [ ] [ ] typeArguments = parameterizedQualifiedTypeReference . typeArguments ; long [ ] positions = parameterizedQualifiedTypeReference . sourcePositions ; sourceStart = ( int ) ( positions [ <NUM_LIT:0> ] > > > <NUM_LIT:32> ) ; switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : { char [ ] [ ] name = ( ( org . eclipse . jdt . internal . compiler . ast . QualifiedTypeReference ) typeReference ) . getTypeName ( ) ; int nameLength = name . length ; sourceStart = ( int ) ( positions [ <NUM_LIT:0> ] > > > <NUM_LIT:32> ) ; length = ( int ) ( positions [ nameLength - <NUM_LIT:1> ] & <NUM_LIT> ) - sourceStart + <NUM_LIT:1> ; Name qualifiedName = this . setQualifiedNameNameAndSourceRanges ( name , positions , typeReference ) ; final SimpleType simpleType = new SimpleType ( this . ast ) ; simpleType . setName ( qualifiedName ) ; simpleType . setSourceRange ( sourceStart , length ) ; type = simpleType ; } break ; case AST . JLS3 : if ( typeArguments != null ) { int numberOfEnclosingType = <NUM_LIT:0> ; int startingIndex = <NUM_LIT:0> ; int endingIndex = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> , max = typeArguments . length ; i < max ; i ++ ) { if ( typeArguments [ i ] != null ) { numberOfEnclosingType ++ ; } else if ( numberOfEnclosingType == <NUM_LIT:0> ) { endingIndex ++ ; } } Name name = null ; if ( endingIndex - startingIndex == <NUM_LIT:0> ) { final SimpleName simpleName = new SimpleName ( this . ast ) ; simpleName . internalSetIdentifier ( new String ( tokens [ startingIndex ] ) ) ; recordPendingNameScopeResolution ( simpleName ) ; int start = ( int ) ( positions [ startingIndex ] > > > <NUM_LIT:32> ) ; int end = ( int ) positions [ startingIndex ] ; simpleName . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; simpleName . index = <NUM_LIT:1> ; name = simpleName ; if ( this . resolveBindings ) { recordNodes ( simpleName , typeReference ) ; } } else { name = this . setQualifiedNameNameAndSourceRanges ( tokens , positions , endingIndex , typeReference ) ; } SimpleType simpleType = new SimpleType ( this . ast ) ; simpleType . setName ( name ) ; int start = ( int ) ( positions [ startingIndex ] > > > <NUM_LIT:32> ) ; int end = ( int ) positions [ endingIndex ] ; simpleType . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; ParameterizedType parameterizedType = new ParameterizedType ( this . ast ) ; parameterizedType . setType ( simpleType ) ; if ( this . resolveBindings ) { recordNodes ( simpleType , typeReference ) ; recordNodes ( parameterizedType , typeReference ) ; } start = simpleType . getStartPosition ( ) ; end = start + simpleType . getLength ( ) - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> , max = typeArguments [ endingIndex ] . length ; i < max ; i ++ ) { final Type type2 = convertType ( typeArguments [ endingIndex ] [ i ] ) ; parameterizedType . typeArguments ( ) . add ( type2 ) ; end = type2 . getStartPosition ( ) + type2 . getLength ( ) - <NUM_LIT:1> ; } int indexOfEnclosingType = <NUM_LIT:1> ; parameterizedType . index = indexOfEnclosingType ; end = retrieveClosingAngleBracketPosition ( end + <NUM_LIT:1> ) ; length = end + <NUM_LIT:1> ; parameterizedType . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; startingIndex = endingIndex + <NUM_LIT:1> ; Type currentType = parameterizedType ; while ( startingIndex < typeArguments . length ) { SimpleName simpleName = new SimpleName ( this . ast ) ; simpleName . internalSetIdentifier ( new String ( tokens [ startingIndex ] ) ) ; simpleName . index = startingIndex + <NUM_LIT:1> ; start = ( int ) ( positions [ startingIndex ] > > > <NUM_LIT:32> ) ; end = ( int ) positions [ startingIndex ] ; simpleName . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; recordPendingNameScopeResolution ( simpleName ) ; QualifiedType qualifiedType = new QualifiedType ( this . ast ) ; qualifiedType . setQualifier ( currentType ) ; qualifiedType . setName ( simpleName ) ; if ( this . resolveBindings ) { recordNodes ( simpleName , typeReference ) ; recordNodes ( qualifiedType , typeReference ) ; } start = currentType . getStartPosition ( ) ; end = simpleName . getStartPosition ( ) + simpleName . getLength ( ) - <NUM_LIT:1> ; qualifiedType . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; indexOfEnclosingType ++ ; if ( typeArguments [ startingIndex ] != null ) { qualifiedType . index = indexOfEnclosingType ; ParameterizedType parameterizedType2 = new ParameterizedType ( this . ast ) ; parameterizedType2 . setType ( qualifiedType ) ; parameterizedType2 . index = indexOfEnclosingType ; if ( this . resolveBindings ) { recordNodes ( parameterizedType2 , typeReference ) ; } for ( int i = <NUM_LIT:0> , max = typeArguments [ startingIndex ] . length ; i < max ; i ++ ) { final Type type2 = convertType ( typeArguments [ startingIndex ] [ i ] ) ; parameterizedType2 . typeArguments ( ) . add ( type2 ) ; end = type2 . getStartPosition ( ) + type2 . getLength ( ) - <NUM_LIT:1> ; } end = retrieveClosingAngleBracketPosition ( end + <NUM_LIT:1> ) ; length = end + <NUM_LIT:1> ; parameterizedType2 . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; currentType = parameterizedType2 ; } else { currentType = qualifiedType ; qualifiedType . index = indexOfEnclosingType ; } startingIndex ++ ; } if ( this . resolveBindings ) { this . recordNodes ( currentType , typeReference ) ; } type = currentType ; length -= sourceStart ; } } } else { char [ ] [ ] name = ( ( org . eclipse . jdt . internal . compiler . ast . QualifiedTypeReference ) typeReference ) . getTypeName ( ) ; int nameLength = name . length ; long [ ] positions = ( ( org . eclipse . jdt . internal . compiler . ast . QualifiedTypeReference ) typeReference ) . sourcePositions ; sourceStart = ( int ) ( positions [ <NUM_LIT:0> ] > > > <NUM_LIT:32> ) ; length = ( int ) ( positions [ nameLength - <NUM_LIT:1> ] & <NUM_LIT> ) - sourceStart + <NUM_LIT:1> ; final Name qualifiedName = this . setQualifiedNameNameAndSourceRanges ( name , positions , typeReference ) ; final SimpleType simpleType = new SimpleType ( this . ast ) ; simpleType . setName ( qualifiedName ) ; type = simpleType ; type . setSourceRange ( sourceStart , length ) ; } length = typeReference . sourceEnd - sourceStart + <NUM_LIT:1> ; if ( dimensions != <NUM_LIT:0> ) { type = this . ast . newArrayType ( type , dimensions ) ; if ( this . resolveBindings ) { completeRecord ( ( ArrayType ) type , typeReference ) ; } int end = retrieveEndOfDimensionsPosition ( sourceStart + length , this . compilationUnitSourceLength ) ; if ( end != - <NUM_LIT:1> ) { type . setSourceRange ( sourceStart , end - sourceStart + <NUM_LIT:1> ) ; } else { type . setSourceRange ( sourceStart , length ) ; } ArrayType subarrayType = ( ArrayType ) type ; int index = dimensions - <NUM_LIT:1> ; while ( index > <NUM_LIT:0> ) { subarrayType = ( ArrayType ) subarrayType . getComponentType ( ) ; end = retrieveProperRightBracketPosition ( index , sourceStart ) ; subarrayType . setSourceRange ( sourceStart , end - sourceStart + <NUM_LIT:1> ) ; index -- ; } } } if ( this . resolveBindings ) { this . recordNodes ( type , typeReference ) ; } return type ; } protected Comment createComment ( int [ ] positions ) { Comment comment = null ; int start = positions [ <NUM_LIT:0> ] ; int end = positions [ <NUM_LIT:1> ] ; if ( positions [ <NUM_LIT:1> ] > <NUM_LIT:0> ) { Javadoc docComment = this . docParser . parse ( positions ) ; if ( docComment == null ) return null ; comment = docComment ; } else { end = - end ; if ( positions [ <NUM_LIT:0> ] == <NUM_LIT:0> ) { if ( this . docParser . scanner . source [ <NUM_LIT:1> ] == '<CHAR_LIT:/>' ) { comment = new LineComment ( this . ast ) ; } else { comment = new BlockComment ( this . ast ) ; } } else if ( positions [ <NUM_LIT:0> ] > <NUM_LIT:0> ) { comment = new BlockComment ( this . ast ) ; } else { start = - start ; comment = new LineComment ( this . ast ) ; } comment . setSourceRange ( start , end - start ) ; } return comment ; } protected Statement createFakeEmptyStatement ( org . eclipse . jdt . internal . compiler . ast . Statement statement ) { if ( statement == null ) return null ; EmptyStatement emptyStatement = new EmptyStatement ( this . ast ) ; emptyStatement . setFlags ( emptyStatement . getFlags ( ) | ASTNode . MALFORMED ) ; int start = statement . sourceStart ; int end = statement . sourceEnd ; emptyStatement . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; return emptyStatement ; } private Modifier createModifier ( ModifierKeyword keyword ) { final Modifier modifier = new Modifier ( this . ast ) ; modifier . setKeyword ( keyword ) ; int start = this . scanner . getCurrentTokenStartPosition ( ) ; int end = this . scanner . getCurrentTokenEndPosition ( ) ; modifier . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; return modifier ; } protected InfixExpression . Operator getOperatorFor ( int operatorID ) { switch ( operatorID ) { case org . eclipse . jdt . internal . compiler . ast . OperatorIds . EQUAL_EQUAL : return InfixExpression . Operator . EQUALS ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . LESS_EQUAL : return InfixExpression . Operator . LESS_EQUALS ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . GREATER_EQUAL : return InfixExpression . Operator . GREATER_EQUALS ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . NOT_EQUAL : return InfixExpression . Operator . NOT_EQUALS ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . LEFT_SHIFT : return InfixExpression . Operator . LEFT_SHIFT ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . RIGHT_SHIFT : return InfixExpression . Operator . RIGHT_SHIFT_SIGNED ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . UNSIGNED_RIGHT_SHIFT : return InfixExpression . Operator . RIGHT_SHIFT_UNSIGNED ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . OR_OR : return InfixExpression . Operator . CONDITIONAL_OR ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . AND_AND : return InfixExpression . Operator . CONDITIONAL_AND ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . PLUS : return InfixExpression . Operator . PLUS ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . MINUS : return InfixExpression . Operator . MINUS ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . REMAINDER : return InfixExpression . Operator . REMAINDER ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . XOR : return InfixExpression . Operator . XOR ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . AND : return InfixExpression . Operator . AND ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . MULTIPLY : return InfixExpression . Operator . TIMES ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . OR : return InfixExpression . Operator . OR ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . DIVIDE : return InfixExpression . Operator . DIVIDE ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . GREATER : return InfixExpression . Operator . GREATER ; case org . eclipse . jdt . internal . compiler . ast . OperatorIds . LESS : return InfixExpression . Operator . LESS ; } return null ; } protected PrimitiveType . Code getPrimitiveTypeCode ( char [ ] name ) { switch ( name [ <NUM_LIT:0> ] ) { case '<CHAR_LIT>' : if ( name . length == <NUM_LIT:3> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT>' ) { return PrimitiveType . INT ; } break ; case '<CHAR_LIT>' : if ( name . length == <NUM_LIT:4> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT>' && name [ <NUM_LIT:3> ] == '<CHAR_LIT>' ) { return PrimitiveType . LONG ; } break ; case '<CHAR_LIT>' : if ( name . length == <NUM_LIT:6> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT>' && name [ <NUM_LIT:3> ] == '<CHAR_LIT:b>' && name [ <NUM_LIT:4> ] == '<CHAR_LIT>' && name [ <NUM_LIT:5> ] == '<CHAR_LIT:e>' ) { return PrimitiveType . DOUBLE ; } break ; case '<CHAR_LIT>' : if ( name . length == <NUM_LIT:5> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT>' && name [ <NUM_LIT:3> ] == '<CHAR_LIT:a>' && name [ <NUM_LIT:4> ] == '<CHAR_LIT>' ) { return PrimitiveType . FLOAT ; } break ; case '<CHAR_LIT:b>' : if ( name . length == <NUM_LIT:4> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT>' && name [ <NUM_LIT:3> ] == '<CHAR_LIT:e>' ) { return PrimitiveType . BYTE ; } else if ( name . length == <NUM_LIT:7> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT>' && name [ <NUM_LIT:3> ] == '<CHAR_LIT>' && name [ <NUM_LIT:4> ] == '<CHAR_LIT:e>' && name [ <NUM_LIT:5> ] == '<CHAR_LIT:a>' && name [ <NUM_LIT:6> ] == '<CHAR_LIT>' ) { return PrimitiveType . BOOLEAN ; } break ; case '<CHAR_LIT:c>' : if ( name . length == <NUM_LIT:4> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT:a>' && name [ <NUM_LIT:3> ] == '<CHAR_LIT>' ) { return PrimitiveType . CHAR ; } break ; case '<CHAR_LIT>' : if ( name . length == <NUM_LIT:5> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT>' && name [ <NUM_LIT:3> ] == '<CHAR_LIT>' && name [ <NUM_LIT:4> ] == '<CHAR_LIT>' ) { return PrimitiveType . SHORT ; } break ; case '<CHAR_LIT>' : if ( name . length == <NUM_LIT:4> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT>' && name [ <NUM_LIT:3> ] == '<CHAR_LIT>' ) { return PrimitiveType . VOID ; } } return null ; } protected boolean isPrimitiveType ( char [ ] name ) { switch ( name [ <NUM_LIT:0> ] ) { case '<CHAR_LIT>' : if ( name . length == <NUM_LIT:3> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT>' ) { return true ; } return false ; case '<CHAR_LIT>' : if ( name . length == <NUM_LIT:4> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT>' && name [ <NUM_LIT:3> ] == '<CHAR_LIT>' ) { return true ; } return false ; case '<CHAR_LIT>' : if ( name . length == <NUM_LIT:6> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT>' && name [ <NUM_LIT:3> ] == '<CHAR_LIT:b>' && name [ <NUM_LIT:4> ] == '<CHAR_LIT>' && name [ <NUM_LIT:5> ] == '<CHAR_LIT:e>' ) { return true ; } return false ; case '<CHAR_LIT>' : if ( name . length == <NUM_LIT:5> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT>' && name [ <NUM_LIT:3> ] == '<CHAR_LIT:a>' && name [ <NUM_LIT:4> ] == '<CHAR_LIT>' ) { return true ; } return false ; case '<CHAR_LIT:b>' : if ( name . length == <NUM_LIT:4> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT>' && name [ <NUM_LIT:3> ] == '<CHAR_LIT:e>' ) { return true ; } else if ( name . length == <NUM_LIT:7> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT>' && name [ <NUM_LIT:3> ] == '<CHAR_LIT>' && name [ <NUM_LIT:4> ] == '<CHAR_LIT:e>' && name [ <NUM_LIT:5> ] == '<CHAR_LIT:a>' && name [ <NUM_LIT:6> ] == '<CHAR_LIT>' ) { return true ; } return false ; case '<CHAR_LIT:c>' : if ( name . length == <NUM_LIT:4> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT:a>' && name [ <NUM_LIT:3> ] == '<CHAR_LIT>' ) { return true ; } return false ; case '<CHAR_LIT>' : if ( name . length == <NUM_LIT:5> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT>' && name [ <NUM_LIT:3> ] == '<CHAR_LIT>' && name [ <NUM_LIT:4> ] == '<CHAR_LIT>' ) { return true ; } return false ; case '<CHAR_LIT>' : if ( name . length == <NUM_LIT:4> && name [ <NUM_LIT:1> ] == '<CHAR_LIT>' && name [ <NUM_LIT:2> ] == '<CHAR_LIT>' && name [ <NUM_LIT:3> ] == '<CHAR_LIT>' ) { return true ; } return false ; } return false ; } private void lookupForScopes ( ) { if ( this . pendingNameScopeResolution != null ) { for ( Iterator iterator = this . pendingNameScopeResolution . iterator ( ) ; iterator . hasNext ( ) ; ) { Name name = ( Name ) iterator . next ( ) ; this . ast . getBindingResolver ( ) . recordScope ( name , lookupScope ( name ) ) ; } } if ( this . pendingThisExpressionScopeResolution != null ) { for ( Iterator iterator = this . pendingThisExpressionScopeResolution . iterator ( ) ; iterator . hasNext ( ) ; ) { ThisExpression thisExpression = ( ThisExpression ) iterator . next ( ) ; this . ast . getBindingResolver ( ) . recordScope ( thisExpression , lookupScope ( thisExpression ) ) ; } } } private BlockScope lookupScope ( ASTNode node ) { ASTNode currentNode = node ; while ( currentNode != null && ! ( currentNode instanceof MethodDeclaration ) && ! ( currentNode instanceof Initializer ) && ! ( currentNode instanceof FieldDeclaration ) && ! ( currentNode instanceof AbstractTypeDeclaration ) ) { currentNode = currentNode . getParent ( ) ; } if ( currentNode == null ) { return null ; } if ( currentNode instanceof Initializer ) { Initializer initializer = ( Initializer ) currentNode ; while ( ! ( currentNode instanceof AbstractTypeDeclaration ) ) { currentNode = currentNode . getParent ( ) ; } if ( currentNode instanceof TypeDeclaration || currentNode instanceof EnumDeclaration || currentNode instanceof AnnotationTypeDeclaration ) { org . eclipse . jdt . internal . compiler . ast . TypeDeclaration typeDecl = ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) this . ast . getBindingResolver ( ) . getCorrespondingNode ( currentNode ) ; if ( ( initializer . getModifiers ( ) & Modifier . STATIC ) != <NUM_LIT:0> ) { return typeDecl . staticInitializerScope ; } else { return typeDecl . initializerScope ; } } } else if ( currentNode instanceof FieldDeclaration ) { FieldDeclaration fieldDeclaration = ( FieldDeclaration ) currentNode ; while ( ! ( currentNode instanceof AbstractTypeDeclaration ) ) { currentNode = currentNode . getParent ( ) ; } org . eclipse . jdt . internal . compiler . ast . TypeDeclaration typeDecl = ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) this . ast . getBindingResolver ( ) . getCorrespondingNode ( currentNode ) ; if ( ( fieldDeclaration . getModifiers ( ) & Modifier . STATIC ) != <NUM_LIT:0> ) { return typeDecl . staticInitializerScope ; } else { return typeDecl . initializerScope ; } } else if ( currentNode instanceof AbstractTypeDeclaration ) { org . eclipse . jdt . internal . compiler . ast . TypeDeclaration typeDecl = ( org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ) this . ast . getBindingResolver ( ) . getCorrespondingNode ( currentNode ) ; return typeDecl . initializerScope ; } AbstractMethodDeclaration abstractMethodDeclaration = ( AbstractMethodDeclaration ) this . ast . getBindingResolver ( ) . getCorrespondingNode ( currentNode ) ; return abstractMethodDeclaration . scope ; } protected void recordName ( Name name , org . eclipse . jdt . internal . compiler . ast . ASTNode compilerNode ) { if ( compilerNode != null ) { recordNodes ( name , compilerNode ) ; if ( compilerNode instanceof org . eclipse . jdt . internal . compiler . ast . TypeReference ) { org . eclipse . jdt . internal . compiler . ast . TypeReference typeRef = ( org . eclipse . jdt . internal . compiler . ast . TypeReference ) compilerNode ; if ( name . isQualifiedName ( ) ) { SimpleName simpleName = null ; while ( name . isQualifiedName ( ) ) { simpleName = ( ( QualifiedName ) name ) . getName ( ) ; recordNodes ( simpleName , typeRef ) ; name = ( ( QualifiedName ) name ) . getQualifier ( ) ; recordNodes ( name , typeRef ) ; } } } } } protected void recordNodes ( ASTNode node , org . eclipse . jdt . internal . compiler . ast . ASTNode oldASTNode ) { this . ast . getBindingResolver ( ) . store ( node , oldASTNode ) ; } protected void recordNodes ( org . eclipse . jdt . internal . compiler . ast . Javadoc javadoc , TagElement tagElement ) { Iterator fragments = tagElement . fragments ( ) . listIterator ( ) ; while ( fragments . hasNext ( ) ) { ASTNode node = ( ASTNode ) fragments . next ( ) ; if ( node . getNodeType ( ) == ASTNode . MEMBER_REF ) { MemberRef memberRef = ( MemberRef ) node ; Name name = memberRef . getName ( ) ; int start = name . getStartPosition ( ) ; org . eclipse . jdt . internal . compiler . ast . ASTNode compilerNode = javadoc . getNodeStartingAt ( start ) ; if ( compilerNode != null ) { recordNodes ( name , compilerNode ) ; recordNodes ( node , compilerNode ) ; } if ( memberRef . getQualifier ( ) != null ) { org . eclipse . jdt . internal . compiler . ast . TypeReference typeRef = null ; if ( compilerNode instanceof JavadocFieldReference ) { org . eclipse . jdt . internal . compiler . ast . Expression expression = ( ( JavadocFieldReference ) compilerNode ) . receiver ; if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . TypeReference ) { typeRef = ( org . eclipse . jdt . internal . compiler . ast . TypeReference ) expression ; } } else if ( compilerNode instanceof JavadocMessageSend ) { org . eclipse . jdt . internal . compiler . ast . Expression expression = ( ( JavadocMessageSend ) compilerNode ) . receiver ; if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . TypeReference ) { typeRef = ( org . eclipse . jdt . internal . compiler . ast . TypeReference ) expression ; } } if ( typeRef != null ) { recordName ( memberRef . getQualifier ( ) , typeRef ) ; } } } else if ( node . getNodeType ( ) == ASTNode . METHOD_REF ) { MethodRef methodRef = ( MethodRef ) node ; Name name = methodRef . getName ( ) ; int start = methodRef . getStartPosition ( ) ; this . scanner . resetTo ( start , start + name . getStartPosition ( ) + name . getLength ( ) ) ; int token ; try { nextToken : while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF && token != TerminalTokens . TokenNameLPAREN ) { if ( token == TerminalTokens . TokenNameERROR && this . scanner . currentCharacter == '<CHAR_LIT>' ) { start = this . scanner . getCurrentTokenEndPosition ( ) + <NUM_LIT:1> ; break nextToken ; } } } catch ( InvalidInputException e ) { } org . eclipse . jdt . internal . compiler . ast . ASTNode compilerNode = javadoc . getNodeStartingAt ( start ) ; if ( compilerNode != null ) { recordNodes ( methodRef , compilerNode ) ; org . eclipse . jdt . internal . compiler . ast . TypeReference typeRef = null ; if ( compilerNode instanceof org . eclipse . jdt . internal . compiler . ast . JavadocAllocationExpression ) { typeRef = ( ( org . eclipse . jdt . internal . compiler . ast . JavadocAllocationExpression ) compilerNode ) . type ; if ( typeRef != null ) recordNodes ( name , compilerNode ) ; } else if ( compilerNode instanceof org . eclipse . jdt . internal . compiler . ast . JavadocMessageSend ) { org . eclipse . jdt . internal . compiler . ast . Expression expression = ( ( org . eclipse . jdt . internal . compiler . ast . JavadocMessageSend ) compilerNode ) . receiver ; if ( expression instanceof org . eclipse . jdt . internal . compiler . ast . TypeReference ) { typeRef = ( org . eclipse . jdt . internal . compiler . ast . TypeReference ) expression ; } recordNodes ( name , compilerNode ) ; } if ( typeRef != null && methodRef . getQualifier ( ) != null ) { recordName ( methodRef . getQualifier ( ) , typeRef ) ; } } Iterator parameters = methodRef . parameters ( ) . listIterator ( ) ; while ( parameters . hasNext ( ) ) { MethodRefParameter param = ( MethodRefParameter ) parameters . next ( ) ; org . eclipse . jdt . internal . compiler . ast . Expression expression = ( org . eclipse . jdt . internal . compiler . ast . Expression ) javadoc . getNodeStartingAt ( param . getStartPosition ( ) ) ; if ( expression != null ) { recordNodes ( param , expression ) ; if ( expression instanceof JavadocArgumentExpression ) { JavadocArgumentExpression argExpr = ( JavadocArgumentExpression ) expression ; org . eclipse . jdt . internal . compiler . ast . TypeReference typeRef = argExpr . argument . type ; if ( this . ast . apiLevel >= AST . JLS3 ) param . setVarargs ( argExpr . argument . isVarArgs ( ) ) ; recordNodes ( param . getType ( ) , typeRef ) ; if ( param . getType ( ) . isSimpleType ( ) ) { recordName ( ( ( SimpleType ) param . getType ( ) ) . getName ( ) , typeRef ) ; } else if ( param . getType ( ) . isArrayType ( ) ) { Type type = ( ( ArrayType ) param . getType ( ) ) . getElementType ( ) ; recordNodes ( type , typeRef ) ; if ( type . isSimpleType ( ) ) { recordName ( ( ( SimpleType ) type ) . getName ( ) , typeRef ) ; } } } } } } else if ( node . getNodeType ( ) == ASTNode . SIMPLE_NAME || node . getNodeType ( ) == ASTNode . QUALIFIED_NAME ) { org . eclipse . jdt . internal . compiler . ast . ASTNode compilerNode = javadoc . getNodeStartingAt ( node . getStartPosition ( ) ) ; recordName ( ( Name ) node , compilerNode ) ; } else if ( node . getNodeType ( ) == ASTNode . TAG_ELEMENT ) { recordNodes ( javadoc , ( TagElement ) node ) ; } } } protected void recordPendingNameScopeResolution ( Name name ) { if ( this . pendingNameScopeResolution == null ) { this . pendingNameScopeResolution = new HashSet ( ) ; } this . pendingNameScopeResolution . add ( name ) ; } protected void recordPendingThisExpressionScopeResolution ( ThisExpression thisExpression ) { if ( this . pendingThisExpressionScopeResolution == null ) { this . pendingThisExpressionScopeResolution = new HashSet ( ) ; } this . pendingThisExpressionScopeResolution . add ( thisExpression ) ; } private void trimWhiteSpacesAndComments ( org . eclipse . jdt . internal . compiler . ast . Expression expression ) { int start = expression . sourceStart ; int end = expression . sourceEnd ; int token ; int trimLeftPosition = expression . sourceStart ; int trimRightPosition = expression . sourceEnd ; boolean first = true ; Scanner removeBlankScanner = this . ast . scanner ; try { removeBlankScanner . setSource ( this . compilationUnitSource ) ; removeBlankScanner . resetTo ( start , end ) ; while ( true ) { token = removeBlankScanner . getNextToken ( ) ; switch ( token ) { case TerminalTokens . TokenNameCOMMENT_JAVADOC : case TerminalTokens . TokenNameCOMMENT_LINE : case TerminalTokens . TokenNameCOMMENT_BLOCK : if ( first ) { trimLeftPosition = removeBlankScanner . currentPosition ; } break ; case TerminalTokens . TokenNameWHITESPACE : if ( first ) { trimLeftPosition = removeBlankScanner . currentPosition ; } break ; case TerminalTokens . TokenNameEOF : expression . sourceStart = trimLeftPosition ; expression . sourceEnd = trimRightPosition ; return ; default : trimRightPosition = removeBlankScanner . currentPosition - <NUM_LIT:1> ; first = false ; } } } catch ( InvalidInputException e ) { } } protected void removeLeadingAndTrailingCommentsFromLiteral ( ASTNode node ) { int start = node . getStartPosition ( ) ; this . scanner . resetTo ( start , start + node . getLength ( ) ) ; int token ; int startPosition = - <NUM_LIT:1> ; try { while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameIntegerLiteral : case TerminalTokens . TokenNameFloatingPointLiteral : case TerminalTokens . TokenNameLongLiteral : case TerminalTokens . TokenNameDoubleLiteral : case TerminalTokens . TokenNameCharacterLiteral : if ( startPosition == - <NUM_LIT:1> ) { startPosition = this . scanner . startPosition ; } int end = this . scanner . currentPosition ; node . setSourceRange ( startPosition , end - startPosition ) ; return ; case TerminalTokens . TokenNameMINUS : startPosition = this . scanner . startPosition ; break ; } } } catch ( InvalidInputException e ) { } } protected void removeTrailingCommentFromExpressionEndingWithAParen ( ASTNode node ) { int start = node . getStartPosition ( ) ; this . scanner . resetTo ( start , start + node . getLength ( ) ) ; int token ; int parenCounter = <NUM_LIT:0> ; try { while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameLPAREN : parenCounter ++ ; break ; case TerminalTokens . TokenNameRPAREN : parenCounter -- ; if ( parenCounter == <NUM_LIT:0> ) { int end = this . scanner . currentPosition - <NUM_LIT:1> ; node . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; } } } } catch ( InvalidInputException e ) { } } protected int retrieveClosingAngleBracketPosition ( int start ) { this . scanner . resetTo ( start , this . compilationUnitSourceLength ) ; this . scanner . returnOnlyGreater = true ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameGREATER : return this . scanner . currentPosition - <NUM_LIT:1> ; default : return start ; } } } catch ( InvalidInputException e ) { } this . scanner . returnOnlyGreater = false ; return start ; } protected void retrieveColonPosition ( ASTNode node ) { int start = node . getStartPosition ( ) ; int length = node . getLength ( ) ; int end = start + length ; this . scanner . resetTo ( end , this . compilationUnitSourceLength ) ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameCOLON : node . setSourceRange ( start , this . scanner . currentPosition - start ) ; return ; } } } catch ( InvalidInputException e ) { } } protected int retrieveEllipsisStartPosition ( int start , int end ) { this . scanner . resetTo ( start , end ) ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameELLIPSIS : return this . scanner . startPosition - <NUM_LIT:1> ; } } } catch ( InvalidInputException e ) { } return - <NUM_LIT:1> ; } protected int retrieveEndBlockPosition ( int start , int end ) { this . scanner . resetTo ( start , end ) ; int count = <NUM_LIT:0> ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameLBRACE : count ++ ; break ; case TerminalTokens . TokenNameRBRACE : count -- ; if ( count == <NUM_LIT:0> ) { return this . scanner . currentPosition - <NUM_LIT:1> ; } } } } catch ( InvalidInputException e ) { } return - <NUM_LIT:1> ; } protected int retrieveSemiColonPosition ( Expression node ) { int start = node . getStartPosition ( ) ; int length = node . getLength ( ) ; int end = start + length ; this . scanner . resetTo ( end , this . compilationUnitSourceLength ) ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameSEMICOLON : return this . scanner . currentPosition - <NUM_LIT:1> ; } } } catch ( InvalidInputException e ) { } return - <NUM_LIT:1> ; } protected int retrieveEndOfDimensionsPosition ( int start , int end ) { this . scanner . resetTo ( start , end ) ; int foundPosition = - <NUM_LIT:1> ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameLBRACKET : case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_JAVADOC : case TerminalTokens . TokenNameCOMMENT_LINE : break ; case TerminalTokens . TokenNameRBRACKET : foundPosition = this . scanner . currentPosition - <NUM_LIT:1> ; break ; default : return foundPosition ; } } } catch ( InvalidInputException e ) { } return foundPosition ; } protected int retrieveEndOfElementTypeNamePosition ( int start , int end ) { this . scanner . resetTo ( start , end ) ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameIdentifier : case TerminalTokens . TokenNamebyte : case TerminalTokens . TokenNamechar : case TerminalTokens . TokenNamedouble : case TerminalTokens . TokenNamefloat : case TerminalTokens . TokenNameint : case TerminalTokens . TokenNamelong : case TerminalTokens . TokenNameshort : case TerminalTokens . TokenNameboolean : return this . scanner . currentPosition - <NUM_LIT:1> ; } } } catch ( InvalidInputException e ) { } return - <NUM_LIT:1> ; } protected int retrieveEndOfRightParenthesisPosition ( int start , int end ) { this . scanner . resetTo ( start , end ) ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameRPAREN : return this . scanner . currentPosition ; } } } catch ( InvalidInputException e ) { } return - <NUM_LIT:1> ; } protected int retrieveExtraDimension ( int start , int end ) { this . scanner . resetTo ( start , end ) ; int dimensions = <NUM_LIT:0> ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameLBRACKET : case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_JAVADOC : case TerminalTokens . TokenNameCOMMENT_LINE : break ; case TerminalTokens . TokenNameRBRACKET : dimensions ++ ; break ; default : return dimensions ; } } } catch ( InvalidInputException e ) { } return dimensions ; } protected void retrieveIdentifierAndSetPositions ( int start , int end , Name name ) { this . scanner . resetTo ( start , end ) ; int token ; try { while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { if ( token == TerminalTokens . TokenNameIdentifier ) { int startName = this . scanner . startPosition ; int endName = this . scanner . currentPosition - <NUM_LIT:1> ; name . setSourceRange ( startName , endName - startName + <NUM_LIT:1> ) ; return ; } } } catch ( InvalidInputException e ) { } } protected int retrieveIdentifierEndPosition ( int start , int end ) { this . scanner . resetTo ( start , end ) ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameIdentifier : return this . scanner . getCurrentTokenEndPosition ( ) ; } } } catch ( InvalidInputException e ) { } return - <NUM_LIT:1> ; } protected int retrieveEndOfPotentialExtendedDimensions ( int initializerEnd , int nameEnd , int end ) { this . scanner . resetTo ( initializerEnd , end ) ; boolean hasTokens = false ; int balance = <NUM_LIT:0> ; int pos = initializerEnd > nameEnd ? initializerEnd - <NUM_LIT:1> : nameEnd ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { hasTokens = true ; switch ( token ) { case TerminalTokens . TokenNameLBRACE : case TerminalTokens . TokenNameLBRACKET : balance ++ ; break ; case TerminalTokens . TokenNameRBRACKET : case TerminalTokens . TokenNameRBRACE : balance -- ; pos = this . scanner . currentPosition - <NUM_LIT:1> ; break ; case TerminalTokens . TokenNameCOMMA : if ( balance == <NUM_LIT:0> ) return pos ; pos = this . scanner . currentPosition - <NUM_LIT:1> ; break ; case TerminalTokens . TokenNameSEMICOLON : if ( balance == <NUM_LIT:0> ) return pos ; return - pos ; } } } catch ( InvalidInputException e ) { } return hasTokens ? Integer . MIN_VALUE : pos ; } protected int retrieveProperRightBracketPosition ( int bracketNumber , int start ) { this . scanner . resetTo ( start , this . compilationUnitSourceLength ) ; try { int token , count = <NUM_LIT:0> ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameRBRACKET : count ++ ; if ( count == bracketNumber ) { return this . scanner . currentPosition - <NUM_LIT:1> ; } } } } catch ( InvalidInputException e ) { } return - <NUM_LIT:1> ; } protected int retrieveRightBraceOrSemiColonPosition ( int start , int end ) { this . scanner . resetTo ( start , end ) ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameRBRACE : return this . scanner . currentPosition - <NUM_LIT:1> ; case TerminalTokens . TokenNameSEMICOLON : return this . scanner . currentPosition - <NUM_LIT:1> ; } } } catch ( InvalidInputException e ) { } return - <NUM_LIT:1> ; } protected int retrieveRightBrace ( int start , int end ) { this . scanner . resetTo ( start , end ) ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameRBRACE : return this . scanner . currentPosition - <NUM_LIT:1> ; } } } catch ( InvalidInputException e ) { } return - <NUM_LIT:1> ; } protected int retrieveRightBracketPosition ( int start , int end ) { this . scanner . resetTo ( start , end ) ; try { int token ; int balance = <NUM_LIT:0> ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameLBRACKET : balance ++ ; break ; case TerminalTokens . TokenNameRBRACKET : balance -- ; if ( balance == <NUM_LIT:0> ) return this . scanner . currentPosition - <NUM_LIT:1> ; break ; } } } catch ( InvalidInputException e ) { } return - <NUM_LIT:1> ; } protected int retrieveStartBlockPosition ( int start , int end ) { this . scanner . resetTo ( start , end ) ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNameLBRACE : return this . scanner . startPosition ; } } } catch ( InvalidInputException e ) { } return - <NUM_LIT:1> ; } protected int retrieveStartingCatchPosition ( int start , int end ) { this . scanner . resetTo ( start , end ) ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { switch ( token ) { case TerminalTokens . TokenNamecatch : return this . scanner . startPosition ; } } } catch ( InvalidInputException e ) { } return - <NUM_LIT:1> ; } public void setAST ( AST ast ) { this . ast = ast ; this . docParser = new DocCommentParser ( this . ast , this . scanner , this . insideComments ) ; } protected void setModifiers ( AnnotationTypeDeclaration typeDecl , org . eclipse . jdt . internal . compiler . ast . TypeDeclaration typeDeclaration ) { this . scanner . resetTo ( typeDeclaration . declarationSourceStart , typeDeclaration . sourceStart ) ; this . setModifiers ( typeDecl , typeDeclaration . annotations , typeDeclaration . sourceStart ) ; } protected void setModifiers ( AnnotationTypeMemberDeclaration annotationTypeMemberDecl , org . eclipse . jdt . internal . compiler . ast . AnnotationMethodDeclaration annotationTypeMemberDeclaration ) { this . scanner . resetTo ( annotationTypeMemberDeclaration . declarationSourceStart , annotationTypeMemberDeclaration . sourceStart ) ; this . setModifiers ( annotationTypeMemberDecl , annotationTypeMemberDeclaration . annotations , annotationTypeMemberDeclaration . sourceStart ) ; } protected void setModifiers ( BodyDeclaration bodyDeclaration , org . eclipse . jdt . internal . compiler . ast . Annotation [ ] annotations , int modifiersEnd ) { this . scanner . tokenizeWhiteSpace = false ; try { int token ; int indexInAnnotations = <NUM_LIT:0> ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { IExtendedModifier modifier = null ; switch ( token ) { case TerminalTokens . TokenNameabstract : modifier = createModifier ( Modifier . ModifierKeyword . ABSTRACT_KEYWORD ) ; break ; case TerminalTokens . TokenNamepublic : modifier = createModifier ( Modifier . ModifierKeyword . PUBLIC_KEYWORD ) ; break ; case TerminalTokens . TokenNamestatic : modifier = createModifier ( Modifier . ModifierKeyword . STATIC_KEYWORD ) ; break ; case TerminalTokens . TokenNameprotected : modifier = createModifier ( Modifier . ModifierKeyword . PROTECTED_KEYWORD ) ; break ; case TerminalTokens . TokenNameprivate : modifier = createModifier ( Modifier . ModifierKeyword . PRIVATE_KEYWORD ) ; break ; case TerminalTokens . TokenNamefinal : modifier = createModifier ( Modifier . ModifierKeyword . FINAL_KEYWORD ) ; break ; case TerminalTokens . TokenNamenative : modifier = createModifier ( Modifier . ModifierKeyword . NATIVE_KEYWORD ) ; break ; case TerminalTokens . TokenNamesynchronized : modifier = createModifier ( Modifier . ModifierKeyword . SYNCHRONIZED_KEYWORD ) ; break ; case TerminalTokens . TokenNametransient : modifier = createModifier ( Modifier . ModifierKeyword . TRANSIENT_KEYWORD ) ; break ; case TerminalTokens . TokenNamevolatile : modifier = createModifier ( Modifier . ModifierKeyword . VOLATILE_KEYWORD ) ; break ; case TerminalTokens . TokenNamestrictfp : modifier = createModifier ( Modifier . ModifierKeyword . STRICTFP_KEYWORD ) ; break ; case TerminalTokens . TokenNameAT : if ( annotations != null && indexInAnnotations < annotations . length ) { org . eclipse . jdt . internal . compiler . ast . Annotation annotation = annotations [ indexInAnnotations ++ ] ; modifier = convert ( annotation ) ; this . scanner . resetTo ( annotation . declarationSourceEnd + <NUM_LIT:1> , modifiersEnd ) ; } break ; case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_LINE : case TerminalTokens . TokenNameCOMMENT_JAVADOC : break ; default : break ; } if ( modifier != null ) { bodyDeclaration . modifiers ( ) . add ( modifier ) ; } } } catch ( InvalidInputException e ) { } } protected void setModifiers ( EnumDeclaration enumDeclaration , org . eclipse . jdt . internal . compiler . ast . TypeDeclaration enumDeclaration2 ) { this . scanner . resetTo ( enumDeclaration2 . declarationSourceStart , enumDeclaration2 . sourceStart ) ; this . setModifiers ( enumDeclaration , enumDeclaration2 . annotations , enumDeclaration2 . sourceStart ) ; } protected void setModifiers ( EnumConstantDeclaration enumConstantDeclaration , org . eclipse . jdt . internal . compiler . ast . FieldDeclaration fieldDeclaration ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : enumConstantDeclaration . internalSetModifiers ( fieldDeclaration . modifiers & ExtraCompilerModifiers . AccJustFlag ) ; if ( fieldDeclaration . annotations != null ) { enumConstantDeclaration . setFlags ( enumConstantDeclaration . getFlags ( ) | ASTNode . MALFORMED ) ; } break ; case AST . JLS3 : this . scanner . resetTo ( fieldDeclaration . declarationSourceStart , fieldDeclaration . sourceStart ) ; this . setModifiers ( enumConstantDeclaration , fieldDeclaration . annotations , fieldDeclaration . sourceStart ) ; } } protected void setModifiers ( FieldDeclaration fieldDeclaration , org . eclipse . jdt . internal . compiler . ast . FieldDeclaration fieldDecl ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : fieldDeclaration . internalSetModifiers ( fieldDecl . modifiers & ExtraCompilerModifiers . AccJustFlag ) ; if ( fieldDecl . annotations != null ) { fieldDeclaration . setFlags ( fieldDeclaration . getFlags ( ) | ASTNode . MALFORMED ) ; } break ; case AST . JLS3 : this . scanner . resetTo ( fieldDecl . declarationSourceStart , fieldDecl . sourceStart ) ; this . setModifiers ( fieldDeclaration , fieldDecl . annotations , fieldDecl . sourceStart ) ; } } protected void setModifiers ( Initializer initializer , org . eclipse . jdt . internal . compiler . ast . Initializer oldInitializer ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : initializer . internalSetModifiers ( oldInitializer . modifiers & ExtraCompilerModifiers . AccJustFlag ) ; if ( oldInitializer . annotations != null ) { initializer . setFlags ( initializer . getFlags ( ) | ASTNode . MALFORMED ) ; } break ; case AST . JLS3 : this . scanner . resetTo ( oldInitializer . declarationSourceStart , oldInitializer . bodyStart ) ; this . setModifiers ( initializer , oldInitializer . annotations , oldInitializer . bodyStart ) ; } } protected void setModifiers ( MethodDeclaration methodDecl , AbstractMethodDeclaration methodDeclaration ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : methodDecl . internalSetModifiers ( methodDeclaration . modifiers & ExtraCompilerModifiers . AccJustFlag ) ; if ( methodDeclaration . annotations != null ) { methodDecl . setFlags ( methodDecl . getFlags ( ) | ASTNode . MALFORMED ) ; } break ; case AST . JLS3 : this . scanner . resetTo ( methodDeclaration . declarationSourceStart , methodDeclaration . sourceStart ) ; this . setModifiers ( methodDecl , methodDeclaration . annotations , methodDeclaration . sourceStart ) ; } } protected void setModifiers ( SingleVariableDeclaration variableDecl , Argument argument ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : variableDecl . internalSetModifiers ( argument . modifiers & ExtraCompilerModifiers . AccJustFlag ) ; if ( argument . annotations != null ) { variableDecl . setFlags ( variableDecl . getFlags ( ) | ASTNode . MALFORMED ) ; } break ; case AST . JLS3 : this . scanner . resetTo ( argument . declarationSourceStart , argument . sourceStart ) ; org . eclipse . jdt . internal . compiler . ast . Annotation [ ] annotations = argument . annotations ; int indexInAnnotations = <NUM_LIT:0> ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { IExtendedModifier modifier = null ; switch ( token ) { case TerminalTokens . TokenNameabstract : modifier = createModifier ( Modifier . ModifierKeyword . ABSTRACT_KEYWORD ) ; break ; case TerminalTokens . TokenNamepublic : modifier = createModifier ( Modifier . ModifierKeyword . PUBLIC_KEYWORD ) ; break ; case TerminalTokens . TokenNamestatic : modifier = createModifier ( Modifier . ModifierKeyword . STATIC_KEYWORD ) ; break ; case TerminalTokens . TokenNameprotected : modifier = createModifier ( Modifier . ModifierKeyword . PROTECTED_KEYWORD ) ; break ; case TerminalTokens . TokenNameprivate : modifier = createModifier ( Modifier . ModifierKeyword . PRIVATE_KEYWORD ) ; break ; case TerminalTokens . TokenNamefinal : modifier = createModifier ( Modifier . ModifierKeyword . FINAL_KEYWORD ) ; break ; case TerminalTokens . TokenNamenative : modifier = createModifier ( Modifier . ModifierKeyword . NATIVE_KEYWORD ) ; break ; case TerminalTokens . TokenNamesynchronized : modifier = createModifier ( Modifier . ModifierKeyword . SYNCHRONIZED_KEYWORD ) ; break ; case TerminalTokens . TokenNametransient : modifier = createModifier ( Modifier . ModifierKeyword . TRANSIENT_KEYWORD ) ; break ; case TerminalTokens . TokenNamevolatile : modifier = createModifier ( Modifier . ModifierKeyword . VOLATILE_KEYWORD ) ; break ; case TerminalTokens . TokenNamestrictfp : modifier = createModifier ( Modifier . ModifierKeyword . STRICTFP_KEYWORD ) ; break ; case TerminalTokens . TokenNameAT : if ( annotations != null && indexInAnnotations < annotations . length ) { org . eclipse . jdt . internal . compiler . ast . Annotation annotation = annotations [ indexInAnnotations ++ ] ; modifier = convert ( annotation ) ; this . scanner . resetTo ( annotation . declarationSourceEnd + <NUM_LIT:1> , this . compilationUnitSourceLength ) ; } break ; case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_LINE : case TerminalTokens . TokenNameCOMMENT_JAVADOC : break ; default : return ; } if ( modifier != null ) { variableDecl . modifiers ( ) . add ( modifier ) ; } } } catch ( InvalidInputException e ) { } } } protected void setModifiers ( SingleVariableDeclaration variableDecl , LocalDeclaration localDeclaration ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : variableDecl . internalSetModifiers ( localDeclaration . modifiers & ExtraCompilerModifiers . AccJustFlag ) ; if ( localDeclaration . annotations != null ) { variableDecl . setFlags ( variableDecl . getFlags ( ) | ASTNode . MALFORMED ) ; } break ; case AST . JLS3 : this . scanner . resetTo ( localDeclaration . declarationSourceStart , localDeclaration . sourceStart ) ; org . eclipse . jdt . internal . compiler . ast . Annotation [ ] annotations = localDeclaration . annotations ; int indexInAnnotations = <NUM_LIT:0> ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { IExtendedModifier modifier = null ; switch ( token ) { case TerminalTokens . TokenNameabstract : modifier = createModifier ( Modifier . ModifierKeyword . ABSTRACT_KEYWORD ) ; break ; case TerminalTokens . TokenNamepublic : modifier = createModifier ( Modifier . ModifierKeyword . PUBLIC_KEYWORD ) ; break ; case TerminalTokens . TokenNamestatic : modifier = createModifier ( Modifier . ModifierKeyword . STATIC_KEYWORD ) ; break ; case TerminalTokens . TokenNameprotected : modifier = createModifier ( Modifier . ModifierKeyword . PROTECTED_KEYWORD ) ; break ; case TerminalTokens . TokenNameprivate : modifier = createModifier ( Modifier . ModifierKeyword . PRIVATE_KEYWORD ) ; break ; case TerminalTokens . TokenNamefinal : modifier = createModifier ( Modifier . ModifierKeyword . FINAL_KEYWORD ) ; break ; case TerminalTokens . TokenNamenative : modifier = createModifier ( Modifier . ModifierKeyword . NATIVE_KEYWORD ) ; break ; case TerminalTokens . TokenNamesynchronized : modifier = createModifier ( Modifier . ModifierKeyword . SYNCHRONIZED_KEYWORD ) ; break ; case TerminalTokens . TokenNametransient : modifier = createModifier ( Modifier . ModifierKeyword . TRANSIENT_KEYWORD ) ; break ; case TerminalTokens . TokenNamevolatile : modifier = createModifier ( Modifier . ModifierKeyword . VOLATILE_KEYWORD ) ; break ; case TerminalTokens . TokenNamestrictfp : modifier = createModifier ( Modifier . ModifierKeyword . STRICTFP_KEYWORD ) ; break ; case TerminalTokens . TokenNameAT : if ( annotations != null && indexInAnnotations < annotations . length ) { org . eclipse . jdt . internal . compiler . ast . Annotation annotation = annotations [ indexInAnnotations ++ ] ; modifier = convert ( annotation ) ; this . scanner . resetTo ( annotation . declarationSourceEnd + <NUM_LIT:1> , this . compilationUnitSourceLength ) ; } break ; case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_LINE : case TerminalTokens . TokenNameCOMMENT_JAVADOC : break ; default : return ; } if ( modifier != null ) { variableDecl . modifiers ( ) . add ( modifier ) ; } } } catch ( InvalidInputException e ) { } } } protected void setModifiers ( TypeDeclaration typeDecl , org . eclipse . jdt . internal . compiler . ast . TypeDeclaration typeDeclaration ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : int modifiers = typeDeclaration . modifiers ; modifiers &= ~ ClassFileConstants . AccInterface ; modifiers &= ExtraCompilerModifiers . AccJustFlag ; typeDecl . internalSetModifiers ( modifiers ) ; if ( typeDeclaration . annotations != null ) { typeDecl . setFlags ( typeDecl . getFlags ( ) | ASTNode . MALFORMED ) ; } break ; case AST . JLS3 : this . scanner . resetTo ( typeDeclaration . declarationSourceStart , typeDeclaration . sourceStart ) ; this . setModifiers ( typeDecl , typeDeclaration . annotations , typeDeclaration . sourceStart ) ; } } protected void setModifiers ( VariableDeclarationExpression variableDeclarationExpression , LocalDeclaration localDeclaration ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : int modifiers = localDeclaration . modifiers & ExtraCompilerModifiers . AccJustFlag ; modifiers &= ~ ExtraCompilerModifiers . AccBlankFinal ; variableDeclarationExpression . internalSetModifiers ( modifiers ) ; if ( localDeclaration . annotations != null ) { variableDeclarationExpression . setFlags ( variableDeclarationExpression . getFlags ( ) | ASTNode . MALFORMED ) ; } break ; case AST . JLS3 : this . scanner . resetTo ( localDeclaration . declarationSourceStart , localDeclaration . sourceStart ) ; org . eclipse . jdt . internal . compiler . ast . Annotation [ ] annotations = localDeclaration . annotations ; int indexInAnnotations = <NUM_LIT:0> ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { IExtendedModifier modifier = null ; switch ( token ) { case TerminalTokens . TokenNameabstract : modifier = createModifier ( Modifier . ModifierKeyword . ABSTRACT_KEYWORD ) ; break ; case TerminalTokens . TokenNamepublic : modifier = createModifier ( Modifier . ModifierKeyword . PUBLIC_KEYWORD ) ; break ; case TerminalTokens . TokenNamestatic : modifier = createModifier ( Modifier . ModifierKeyword . STATIC_KEYWORD ) ; break ; case TerminalTokens . TokenNameprotected : modifier = createModifier ( Modifier . ModifierKeyword . PROTECTED_KEYWORD ) ; break ; case TerminalTokens . TokenNameprivate : modifier = createModifier ( Modifier . ModifierKeyword . PRIVATE_KEYWORD ) ; break ; case TerminalTokens . TokenNamefinal : modifier = createModifier ( Modifier . ModifierKeyword . FINAL_KEYWORD ) ; break ; case TerminalTokens . TokenNamenative : modifier = createModifier ( Modifier . ModifierKeyword . NATIVE_KEYWORD ) ; break ; case TerminalTokens . TokenNamesynchronized : modifier = createModifier ( Modifier . ModifierKeyword . SYNCHRONIZED_KEYWORD ) ; break ; case TerminalTokens . TokenNametransient : modifier = createModifier ( Modifier . ModifierKeyword . TRANSIENT_KEYWORD ) ; break ; case TerminalTokens . TokenNamevolatile : modifier = createModifier ( Modifier . ModifierKeyword . VOLATILE_KEYWORD ) ; break ; case TerminalTokens . TokenNamestrictfp : modifier = createModifier ( Modifier . ModifierKeyword . STRICTFP_KEYWORD ) ; break ; case TerminalTokens . TokenNameAT : if ( annotations != null && indexInAnnotations < annotations . length ) { org . eclipse . jdt . internal . compiler . ast . Annotation annotation = annotations [ indexInAnnotations ++ ] ; modifier = convert ( annotation ) ; this . scanner . resetTo ( annotation . declarationSourceEnd + <NUM_LIT:1> , this . compilationUnitSourceLength ) ; } break ; case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_LINE : case TerminalTokens . TokenNameCOMMENT_JAVADOC : break ; default : return ; } if ( modifier != null ) { variableDeclarationExpression . modifiers ( ) . add ( modifier ) ; } } } catch ( InvalidInputException e ) { } } } protected void setModifiers ( VariableDeclarationStatement variableDeclarationStatement , LocalDeclaration localDeclaration ) { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : int modifiers = localDeclaration . modifiers & ExtraCompilerModifiers . AccJustFlag ; modifiers &= ~ ExtraCompilerModifiers . AccBlankFinal ; variableDeclarationStatement . internalSetModifiers ( modifiers ) ; if ( localDeclaration . annotations != null ) { variableDeclarationStatement . setFlags ( variableDeclarationStatement . getFlags ( ) | ASTNode . MALFORMED ) ; } break ; case AST . JLS3 : this . scanner . resetTo ( localDeclaration . declarationSourceStart , localDeclaration . sourceStart ) ; org . eclipse . jdt . internal . compiler . ast . Annotation [ ] annotations = localDeclaration . annotations ; int indexInAnnotations = <NUM_LIT:0> ; try { int token ; while ( ( token = this . scanner . getNextToken ( ) ) != TerminalTokens . TokenNameEOF ) { IExtendedModifier modifier = null ; switch ( token ) { case TerminalTokens . TokenNameabstract : modifier = createModifier ( Modifier . ModifierKeyword . ABSTRACT_KEYWORD ) ; break ; case TerminalTokens . TokenNamepublic : modifier = createModifier ( Modifier . ModifierKeyword . PUBLIC_KEYWORD ) ; break ; case TerminalTokens . TokenNamestatic : modifier = createModifier ( Modifier . ModifierKeyword . STATIC_KEYWORD ) ; break ; case TerminalTokens . TokenNameprotected : modifier = createModifier ( Modifier . ModifierKeyword . PROTECTED_KEYWORD ) ; break ; case TerminalTokens . TokenNameprivate : modifier = createModifier ( Modifier . ModifierKeyword . PRIVATE_KEYWORD ) ; break ; case TerminalTokens . TokenNamefinal : modifier = createModifier ( Modifier . ModifierKeyword . FINAL_KEYWORD ) ; break ; case TerminalTokens . TokenNamenative : modifier = createModifier ( Modifier . ModifierKeyword . NATIVE_KEYWORD ) ; break ; case TerminalTokens . TokenNamesynchronized : modifier = createModifier ( Modifier . ModifierKeyword . SYNCHRONIZED_KEYWORD ) ; break ; case TerminalTokens . TokenNametransient : modifier = createModifier ( Modifier . ModifierKeyword . TRANSIENT_KEYWORD ) ; break ; case TerminalTokens . TokenNamevolatile : modifier = createModifier ( Modifier . ModifierKeyword . VOLATILE_KEYWORD ) ; break ; case TerminalTokens . TokenNamestrictfp : modifier = createModifier ( Modifier . ModifierKeyword . STRICTFP_KEYWORD ) ; break ; case TerminalTokens . TokenNameAT : if ( annotations != null && indexInAnnotations < annotations . length ) { org . eclipse . jdt . internal . compiler . ast . Annotation annotation = annotations [ indexInAnnotations ++ ] ; modifier = convert ( annotation ) ; this . scanner . resetTo ( annotation . declarationSourceEnd + <NUM_LIT:1> , this . compilationUnitSourceLength ) ; } break ; case TerminalTokens . TokenNameCOMMENT_BLOCK : case TerminalTokens . TokenNameCOMMENT_LINE : case TerminalTokens . TokenNameCOMMENT_JAVADOC : break ; default : return ; } if ( modifier != null ) { variableDeclarationStatement . modifiers ( ) . add ( modifier ) ; } } } catch ( InvalidInputException e ) { } } } protected QualifiedName setQualifiedNameNameAndSourceRanges ( char [ ] [ ] typeName , long [ ] positions , org . eclipse . jdt . internal . compiler . ast . ASTNode node ) { int length = typeName . length ; final SimpleName firstToken = new SimpleName ( this . ast ) ; firstToken . internalSetIdentifier ( new String ( typeName [ <NUM_LIT:0> ] ) ) ; firstToken . index = <NUM_LIT:1> ; int start0 = ( int ) ( positions [ <NUM_LIT:0> ] > > > <NUM_LIT:32> ) ; int start = start0 ; int end = ( int ) ( positions [ <NUM_LIT:0> ] & <NUM_LIT> ) ; firstToken . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; final SimpleName secondToken = new SimpleName ( this . ast ) ; secondToken . internalSetIdentifier ( new String ( typeName [ <NUM_LIT:1> ] ) ) ; secondToken . index = <NUM_LIT:2> ; start = ( int ) ( positions [ <NUM_LIT:1> ] > > > <NUM_LIT:32> ) ; end = ( int ) ( positions [ <NUM_LIT:1> ] & <NUM_LIT> ) ; secondToken . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; QualifiedName qualifiedName = new QualifiedName ( this . ast ) ; qualifiedName . setQualifier ( firstToken ) ; qualifiedName . setName ( secondToken ) ; if ( this . resolveBindings ) { recordNodes ( qualifiedName , node ) ; recordPendingNameScopeResolution ( qualifiedName ) ; recordNodes ( firstToken , node ) ; recordNodes ( secondToken , node ) ; recordPendingNameScopeResolution ( firstToken ) ; recordPendingNameScopeResolution ( secondToken ) ; } qualifiedName . index = <NUM_LIT:2> ; qualifiedName . setSourceRange ( start0 , end - start0 + <NUM_LIT:1> ) ; SimpleName newPart = null ; for ( int i = <NUM_LIT:2> ; i < length ; i ++ ) { newPart = new SimpleName ( this . ast ) ; newPart . internalSetIdentifier ( new String ( typeName [ i ] ) ) ; newPart . index = i + <NUM_LIT:1> ; start = ( int ) ( positions [ i ] > > > <NUM_LIT:32> ) ; end = ( int ) ( positions [ i ] & <NUM_LIT> ) ; newPart . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; QualifiedName qualifiedName2 = new QualifiedName ( this . ast ) ; qualifiedName2 . setQualifier ( qualifiedName ) ; qualifiedName2 . setName ( newPart ) ; qualifiedName = qualifiedName2 ; qualifiedName . index = newPart . index ; qualifiedName . setSourceRange ( start0 , end - start0 + <NUM_LIT:1> ) ; if ( this . resolveBindings ) { recordNodes ( qualifiedName , node ) ; recordNodes ( newPart , node ) ; recordPendingNameScopeResolution ( qualifiedName ) ; recordPendingNameScopeResolution ( newPart ) ; } } QualifiedName name = qualifiedName ; if ( this . resolveBindings ) { recordNodes ( name , node ) ; recordPendingNameScopeResolution ( name ) ; } return name ; } protected QualifiedName setQualifiedNameNameAndSourceRanges ( char [ ] [ ] typeName , long [ ] positions , int endingIndex , org . eclipse . jdt . internal . compiler . ast . ASTNode node ) { int length = endingIndex + <NUM_LIT:1> ; final SimpleName firstToken = new SimpleName ( this . ast ) ; firstToken . internalSetIdentifier ( new String ( typeName [ <NUM_LIT:0> ] ) ) ; firstToken . index = <NUM_LIT:1> ; int start0 = ( int ) ( positions [ <NUM_LIT:0> ] > > > <NUM_LIT:32> ) ; int start = start0 ; int end = ( int ) positions [ <NUM_LIT:0> ] ; firstToken . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; final SimpleName secondToken = new SimpleName ( this . ast ) ; secondToken . internalSetIdentifier ( new String ( typeName [ <NUM_LIT:1> ] ) ) ; secondToken . index = <NUM_LIT:2> ; start = ( int ) ( positions [ <NUM_LIT:1> ] > > > <NUM_LIT:32> ) ; end = ( int ) positions [ <NUM_LIT:1> ] ; secondToken . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; QualifiedName qualifiedName = new QualifiedName ( this . ast ) ; qualifiedName . setQualifier ( firstToken ) ; qualifiedName . setName ( secondToken ) ; if ( this . resolveBindings ) { recordNodes ( qualifiedName , node ) ; recordPendingNameScopeResolution ( qualifiedName ) ; recordNodes ( firstToken , node ) ; recordNodes ( secondToken , node ) ; recordPendingNameScopeResolution ( firstToken ) ; recordPendingNameScopeResolution ( secondToken ) ; } qualifiedName . index = <NUM_LIT:2> ; qualifiedName . setSourceRange ( start0 , end - start0 + <NUM_LIT:1> ) ; SimpleName newPart = null ; for ( int i = <NUM_LIT:2> ; i < length ; i ++ ) { newPart = new SimpleName ( this . ast ) ; newPart . internalSetIdentifier ( new String ( typeName [ i ] ) ) ; newPart . index = i + <NUM_LIT:1> ; start = ( int ) ( positions [ i ] > > > <NUM_LIT:32> ) ; end = ( int ) positions [ i ] ; newPart . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; QualifiedName qualifiedName2 = new QualifiedName ( this . ast ) ; qualifiedName2 . setQualifier ( qualifiedName ) ; qualifiedName2 . setName ( newPart ) ; qualifiedName = qualifiedName2 ; qualifiedName . index = newPart . index ; qualifiedName . setSourceRange ( start0 , end - start0 + <NUM_LIT:1> ) ; if ( this . resolveBindings ) { recordNodes ( qualifiedName , node ) ; recordNodes ( newPart , node ) ; recordPendingNameScopeResolution ( qualifiedName ) ; recordPendingNameScopeResolution ( newPart ) ; } } if ( newPart == null && this . resolveBindings ) { recordNodes ( qualifiedName , node ) ; recordPendingNameScopeResolution ( qualifiedName ) ; } return qualifiedName ; } protected void setTypeNameForAnnotation ( org . eclipse . jdt . internal . compiler . ast . Annotation compilerAnnotation , Annotation annotation ) { TypeReference typeReference = compilerAnnotation . type ; if ( typeReference instanceof QualifiedTypeReference ) { QualifiedTypeReference qualifiedTypeReference = ( QualifiedTypeReference ) typeReference ; char [ ] [ ] tokens = qualifiedTypeReference . tokens ; long [ ] positions = qualifiedTypeReference . sourcePositions ; annotation . setTypeName ( setQualifiedNameNameAndSourceRanges ( tokens , positions , typeReference ) ) ; } else { SingleTypeReference singleTypeReference = ( SingleTypeReference ) typeReference ; final SimpleName name = new SimpleName ( this . ast ) ; name . internalSetIdentifier ( new String ( singleTypeReference . token ) ) ; int start = singleTypeReference . sourceStart ; int end = singleTypeReference . sourceEnd ; name . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; name . index = <NUM_LIT:1> ; annotation . setTypeName ( name ) ; if ( this . resolveBindings ) { recordNodes ( name , typeReference ) ; } } } protected void setTypeForField ( FieldDeclaration fieldDeclaration , Type type , int extraDimension ) { if ( extraDimension != <NUM_LIT:0> ) { if ( type . isArrayType ( ) ) { ArrayType arrayType = ( ArrayType ) type ; int remainingDimensions = arrayType . getDimensions ( ) - extraDimension ; if ( remainingDimensions == <NUM_LIT:0> ) { Type elementType = arrayType . getElementType ( ) ; elementType . setParent ( null , null ) ; this . ast . getBindingResolver ( ) . updateKey ( type , elementType ) ; fieldDeclaration . setType ( elementType ) ; } else { int start = type . getStartPosition ( ) ; ArrayType subarrayType = arrayType ; int index = extraDimension ; while ( index > <NUM_LIT:0> ) { subarrayType = ( ArrayType ) subarrayType . getComponentType ( ) ; index -- ; } int end = retrieveProperRightBracketPosition ( remainingDimensions , start ) ; subarrayType . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; subarrayType . setParent ( null , null ) ; fieldDeclaration . setType ( subarrayType ) ; updateInnerPositions ( subarrayType , remainingDimensions ) ; this . ast . getBindingResolver ( ) . updateKey ( type , subarrayType ) ; } } else { fieldDeclaration . setType ( type ) ; } } else { if ( type . isArrayType ( ) ) { int dimensions = ( ( ArrayType ) type ) . getDimensions ( ) ; updateInnerPositions ( type , dimensions ) ; } fieldDeclaration . setType ( type ) ; } } protected void setTypeForMethodDeclaration ( MethodDeclaration methodDeclaration , Type type , int extraDimension ) { if ( extraDimension != <NUM_LIT:0> ) { if ( type . isArrayType ( ) ) { ArrayType arrayType = ( ArrayType ) type ; int remainingDimensions = arrayType . getDimensions ( ) - extraDimension ; if ( remainingDimensions == <NUM_LIT:0> ) { Type elementType = arrayType . getElementType ( ) ; elementType . setParent ( null , null ) ; this . ast . getBindingResolver ( ) . updateKey ( type , elementType ) ; switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : methodDeclaration . internalSetReturnType ( elementType ) ; break ; case AST . JLS3 : methodDeclaration . setReturnType2 ( elementType ) ; break ; } } else { int start = type . getStartPosition ( ) ; ArrayType subarrayType = arrayType ; int index = extraDimension ; while ( index > <NUM_LIT:0> ) { subarrayType = ( ArrayType ) subarrayType . getComponentType ( ) ; index -- ; } int end = retrieveProperRightBracketPosition ( remainingDimensions , start ) ; subarrayType . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; subarrayType . setParent ( null , null ) ; updateInnerPositions ( subarrayType , remainingDimensions ) ; switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : methodDeclaration . internalSetReturnType ( subarrayType ) ; break ; case AST . JLS3 : methodDeclaration . setReturnType2 ( subarrayType ) ; break ; } this . ast . getBindingResolver ( ) . updateKey ( type , subarrayType ) ; } } else { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : methodDeclaration . internalSetReturnType ( type ) ; break ; case AST . JLS3 : methodDeclaration . setReturnType2 ( type ) ; break ; } } } else { switch ( this . ast . apiLevel ) { case AST . JLS2_INTERNAL : methodDeclaration . internalSetReturnType ( type ) ; break ; case AST . JLS3 : methodDeclaration . setReturnType2 ( type ) ; break ; } } } protected void setTypeForMethodDeclaration ( AnnotationTypeMemberDeclaration annotationTypeMemberDeclaration , Type type , int extraDimension ) { annotationTypeMemberDeclaration . setType ( type ) ; } protected void setTypeForSingleVariableDeclaration ( SingleVariableDeclaration singleVariableDeclaration , Type type , int extraDimension ) { if ( extraDimension != <NUM_LIT:0> ) { if ( type . isArrayType ( ) ) { ArrayType arrayType = ( ArrayType ) type ; int remainingDimensions = arrayType . getDimensions ( ) - extraDimension ; if ( remainingDimensions == <NUM_LIT:0> ) { Type elementType = arrayType . getElementType ( ) ; elementType . setParent ( null , null ) ; this . ast . getBindingResolver ( ) . updateKey ( type , elementType ) ; singleVariableDeclaration . setType ( elementType ) ; } else { int start = type . getStartPosition ( ) ; ArrayType subarrayType = arrayType ; int index = extraDimension ; while ( index > <NUM_LIT:0> ) { subarrayType = ( ArrayType ) subarrayType . getComponentType ( ) ; index -- ; } int end = retrieveProperRightBracketPosition ( remainingDimensions , start ) ; subarrayType . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; subarrayType . setParent ( null , null ) ; updateInnerPositions ( subarrayType , remainingDimensions ) ; singleVariableDeclaration . setType ( subarrayType ) ; this . ast . getBindingResolver ( ) . updateKey ( type , subarrayType ) ; } } else { singleVariableDeclaration . setType ( type ) ; } } else { singleVariableDeclaration . setType ( type ) ; } } protected void setTypeForVariableDeclarationExpression ( VariableDeclarationExpression variableDeclarationExpression , Type type , int extraDimension ) { if ( extraDimension != <NUM_LIT:0> ) { if ( type . isArrayType ( ) ) { ArrayType arrayType = ( ArrayType ) type ; int remainingDimensions = arrayType . getDimensions ( ) - extraDimension ; if ( remainingDimensions == <NUM_LIT:0> ) { Type elementType = arrayType . getElementType ( ) ; elementType . setParent ( null , null ) ; this . ast . getBindingResolver ( ) . updateKey ( type , elementType ) ; variableDeclarationExpression . setType ( elementType ) ; } else { int start = type . getStartPosition ( ) ; ArrayType subarrayType = arrayType ; int index = extraDimension ; while ( index > <NUM_LIT:0> ) { subarrayType = ( ArrayType ) subarrayType . getComponentType ( ) ; index -- ; } int end = retrieveProperRightBracketPosition ( remainingDimensions , start ) ; subarrayType . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; subarrayType . setParent ( null , null ) ; updateInnerPositions ( subarrayType , remainingDimensions ) ; variableDeclarationExpression . setType ( subarrayType ) ; this . ast . getBindingResolver ( ) . updateKey ( type , subarrayType ) ; } } else { variableDeclarationExpression . setType ( type ) ; } } else { variableDeclarationExpression . setType ( type ) ; } } protected void setTypeForVariableDeclarationStatement ( VariableDeclarationStatement variableDeclarationStatement , Type type , int extraDimension ) { if ( extraDimension != <NUM_LIT:0> ) { if ( type . isArrayType ( ) ) { ArrayType arrayType = ( ArrayType ) type ; int remainingDimensions = arrayType . getDimensions ( ) - extraDimension ; if ( remainingDimensions == <NUM_LIT:0> ) { Type elementType = arrayType . getElementType ( ) ; elementType . setParent ( null , null ) ; this . ast . getBindingResolver ( ) . updateKey ( type , elementType ) ; variableDeclarationStatement . setType ( elementType ) ; } else { int start = type . getStartPosition ( ) ; ArrayType subarrayType = arrayType ; int index = extraDimension ; while ( index > <NUM_LIT:0> ) { subarrayType = ( ArrayType ) subarrayType . getComponentType ( ) ; index -- ; } int end = retrieveProperRightBracketPosition ( remainingDimensions , start ) ; subarrayType . setSourceRange ( start , end - start + <NUM_LIT:1> ) ; subarrayType . setParent ( null , null ) ; updateInnerPositions ( subarrayType , remainingDimensions ) ; variableDeclarationStatement . setType ( subarrayType ) ; this . ast . getBindingResolver ( ) . updateKey ( type , subarrayType ) ; } } else { variableDeclarationStatement . setType ( type ) ; } } else { variableDeclarationStatement . setType ( type ) ; } } protected void updateInnerPositions ( Type type , int dimensions ) { if ( dimensions > <NUM_LIT:1> ) { int start = type . getStartPosition ( ) ; Type currentComponentType = ( ( ArrayType ) type ) . getComponentType ( ) ; int searchedDimension = dimensions - <NUM_LIT:1> ; int rightBracketEndPosition = start ; while ( currentComponentType . isArrayType ( ) ) { rightBracketEndPosition = retrieveProperRightBracketPosition ( searchedDimension , start ) ; currentComponentType . setSourceRange ( start , rightBracketEndPosition - start + <NUM_LIT:1> ) ; currentComponentType = ( ( ArrayType ) currentComponentType ) . getComponentType ( ) ; searchedDimension -- ; } } } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class MethodInvocation extends Expression { public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( MethodInvocation . class , "<STR_LIT>" , Expression . class , OPTIONAL , CYCLE_RISK ) ; public static final ChildListPropertyDescriptor TYPE_ARGUMENTS_PROPERTY = new ChildListPropertyDescriptor ( MethodInvocation . class , "<STR_LIT>" , Type . class , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = new ChildPropertyDescriptor ( MethodInvocation . class , "<STR_LIT:name>" , SimpleName . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor ARGUMENTS_PROPERTY = new ChildListPropertyDescriptor ( MethodInvocation . class , "<STR_LIT>" , Expression . class , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List properyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( MethodInvocation . class , properyList ) ; addProperty ( EXPRESSION_PROPERTY , properyList ) ; addProperty ( NAME_PROPERTY , properyList ) ; addProperty ( ARGUMENTS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( properyList ) ; properyList = new ArrayList ( <NUM_LIT:5> ) ; createPropertyList ( MethodInvocation . class , properyList ) ; addProperty ( EXPRESSION_PROPERTY , properyList ) ; addProperty ( TYPE_ARGUMENTS_PROPERTY , properyList ) ; addProperty ( NAME_PROPERTY , properyList ) ; addProperty ( ARGUMENTS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private Expression optionalExpression = null ; private ASTNode . NodeList typeArguments = null ; private SimpleName methodName = null ; private ASTNode . NodeList arguments = new ASTNode . NodeList ( ARGUMENTS_PROPERTY ) ; MethodInvocation ( AST ast ) { super ( ast ) ; if ( ast . apiLevel >= AST . JLS3 ) { this . typeArguments = new ASTNode . NodeList ( TYPE_ARGUMENTS_PROPERTY ) ; } } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == ARGUMENTS_PROPERTY ) { return arguments ( ) ; } if ( property == TYPE_ARGUMENTS_PROPERTY ) { return typeArguments ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return METHOD_INVOCATION ; } ASTNode clone0 ( AST target ) { MethodInvocation result = new MethodInvocation ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setName ( ( SimpleName ) getName ( ) . clone ( target ) ) ; result . setExpression ( ( Expression ) ASTNode . copySubtree ( target , getExpression ( ) ) ) ; if ( this . ast . apiLevel >= AST . JLS3 ) { result . typeArguments ( ) . addAll ( ASTNode . copySubtrees ( target , typeArguments ( ) ) ) ; } result . arguments ( ) . addAll ( ASTNode . copySubtrees ( target , arguments ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getExpression ( ) ) ; if ( this . ast . apiLevel >= AST . JLS3 ) { acceptChildren ( visitor , this . typeArguments ) ; } acceptChild ( visitor , getName ( ) ) ; acceptChildren ( visitor , this . arguments ) ; } visitor . endVisit ( this ) ; } public Expression getExpression ( ) { return this . optionalExpression ; } public boolean isResolvedTypeInferredFromExpectedType ( ) { return this . ast . getBindingResolver ( ) . isResolvedTypeInferredFromExpectedType ( this ) ; } public void setExpression ( Expression expression ) { ASTNode oldChild = this . optionalExpression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . optionalExpression = expression ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } public List typeArguments ( ) { if ( this . typeArguments == null ) { unsupportedIn2 ( ) ; } return this . typeArguments ; } public SimpleName getName ( ) { if ( this . methodName == null ) { synchronized ( this ) { if ( this . methodName == null ) { preLazyInit ( ) ; this . methodName = new SimpleName ( this . ast ) ; postLazyInit ( this . methodName , NAME_PROPERTY ) ; } } } return this . methodName ; } public void setName ( SimpleName name ) { if ( name == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . methodName ; preReplaceChild ( oldChild , name , NAME_PROPERTY ) ; this . methodName = name ; postReplaceChild ( oldChild , name , NAME_PROPERTY ) ; } public List arguments ( ) { return this . arguments ; } public IMethodBinding resolveMethodBinding ( ) { return this . ast . getBindingResolver ( ) . resolveMethod ( this ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:4> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . optionalExpression == null ? <NUM_LIT:0> : getExpression ( ) . treeSize ( ) ) + ( this . typeArguments == null ? <NUM_LIT:0> : this . typeArguments . listSize ( ) ) + ( this . methodName == null ? <NUM_LIT:0> : getName ( ) . treeSize ( ) ) + ( this . arguments == null ? <NUM_LIT:0> : this . arguments . listSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class ConstructorInvocation extends Statement { public static final ChildListPropertyDescriptor TYPE_ARGUMENTS_PROPERTY = new ChildListPropertyDescriptor ( ConstructorInvocation . class , "<STR_LIT>" , Type . class , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor ARGUMENTS_PROPERTY = new ChildListPropertyDescriptor ( ConstructorInvocation . class , "<STR_LIT>" , Expression . class , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List properyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( ConstructorInvocation . class , properyList ) ; addProperty ( ARGUMENTS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( properyList ) ; properyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( ConstructorInvocation . class , properyList ) ; addProperty ( TYPE_ARGUMENTS_PROPERTY , properyList ) ; addProperty ( ARGUMENTS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private ASTNode . NodeList typeArguments = null ; private ASTNode . NodeList arguments = new ASTNode . NodeList ( ARGUMENTS_PROPERTY ) ; ConstructorInvocation ( AST ast ) { super ( ast ) ; if ( ast . apiLevel >= AST . JLS3 ) { this . typeArguments = new ASTNode . NodeList ( TYPE_ARGUMENTS_PROPERTY ) ; } } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == ARGUMENTS_PROPERTY ) { return arguments ( ) ; } if ( property == TYPE_ARGUMENTS_PROPERTY ) { return typeArguments ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return CONSTRUCTOR_INVOCATION ; } ASTNode clone0 ( AST target ) { ConstructorInvocation result = new ConstructorInvocation ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; if ( this . ast . apiLevel >= AST . JLS3 ) { result . typeArguments ( ) . addAll ( ASTNode . copySubtrees ( target , typeArguments ( ) ) ) ; } result . arguments ( ) . addAll ( ASTNode . copySubtrees ( target , arguments ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { if ( this . ast . apiLevel >= AST . JLS3 ) { acceptChildren ( visitor , this . typeArguments ) ; } acceptChildren ( visitor , this . arguments ) ; } visitor . endVisit ( this ) ; } public List typeArguments ( ) { if ( this . typeArguments == null ) { unsupportedIn2 ( ) ; } return this . typeArguments ; } public List arguments ( ) { return this . arguments ; } public IMethodBinding resolveConstructorBinding ( ) { return this . ast . getBindingResolver ( ) . resolveConstructor ( this ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . typeArguments == null ? <NUM_LIT:0> : this . typeArguments . listSize ( ) ) + ( this . arguments == null ? <NUM_LIT:0> : this . arguments . listSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class EnhancedForStatement extends Statement { public static final ChildPropertyDescriptor PARAMETER_PROPERTY = new ChildPropertyDescriptor ( EnhancedForStatement . class , "<STR_LIT>" , SingleVariableDeclaration . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( EnhancedForStatement . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; public static final ChildPropertyDescriptor BODY_PROPERTY = new ChildPropertyDescriptor ( EnhancedForStatement . class , "<STR_LIT:body>" , Statement . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( EnhancedForStatement . class , properyList ) ; addProperty ( PARAMETER_PROPERTY , properyList ) ; addProperty ( EXPRESSION_PROPERTY , properyList ) ; addProperty ( BODY_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private SingleVariableDeclaration parameter = null ; private Expression expression = null ; private Statement body = null ; EnhancedForStatement ( AST ast ) { super ( ast ) ; unsupportedIn2 ( ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == PARAMETER_PROPERTY ) { if ( get ) { return getParameter ( ) ; } else { setParameter ( ( SingleVariableDeclaration ) child ) ; return null ; } } if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } if ( property == BODY_PROPERTY ) { if ( get ) { return getBody ( ) ; } else { setBody ( ( Statement ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return ENHANCED_FOR_STATEMENT ; } ASTNode clone0 ( AST target ) { EnhancedForStatement result = new EnhancedForStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; result . setParameter ( ( SingleVariableDeclaration ) getParameter ( ) . clone ( target ) ) ; result . setExpression ( ( Expression ) getExpression ( ) . clone ( target ) ) ; result . setBody ( ( Statement ) ASTNode . copySubtree ( target , getBody ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getParameter ( ) ) ; acceptChild ( visitor , getExpression ( ) ) ; acceptChild ( visitor , getBody ( ) ) ; } visitor . endVisit ( this ) ; } public SingleVariableDeclaration getParameter ( ) { if ( this . parameter == null ) { synchronized ( this ) { if ( this . parameter == null ) { preLazyInit ( ) ; this . parameter = this . ast . newSingleVariableDeclaration ( ) ; postLazyInit ( this . parameter , PARAMETER_PROPERTY ) ; } } } return this . parameter ; } public void setParameter ( SingleVariableDeclaration parameter ) { if ( parameter == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . parameter ; preReplaceChild ( oldChild , parameter , PARAMETER_PROPERTY ) ; this . parameter = parameter ; postReplaceChild ( oldChild , parameter , PARAMETER_PROPERTY ) ; } public Expression getExpression ( ) { if ( this . expression == null ) { synchronized ( this ) { if ( this . expression == null ) { preLazyInit ( ) ; this . expression = new SimpleName ( this . ast ) ; postLazyInit ( this . expression , EXPRESSION_PROPERTY ) ; } } } return this . expression ; } public void setExpression ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . expression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . expression = expression ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } public Statement getBody ( ) { if ( this . body == null ) { synchronized ( this ) { if ( this . body == null ) { preLazyInit ( ) ; this . body = new Block ( this . ast ) ; postLazyInit ( this . body , BODY_PROPERTY ) ; } } } return this . body ; } public void setBody ( Statement statement ) { if ( statement == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . body ; preReplaceChild ( oldChild , statement , BODY_PROPERTY ) ; this . body = statement ; postReplaceChild ( oldChild , statement , BODY_PROPERTY ) ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:3> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . parameter == null ? <NUM_LIT:0> : getParameter ( ) . treeSize ( ) ) + ( this . expression == null ? <NUM_LIT:0> : getExpression ( ) . treeSize ( ) ) + ( this . body == null ? <NUM_LIT:0> : getBody ( ) . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class ArrayInitializer extends Expression { public static final ChildListPropertyDescriptor EXPRESSIONS_PROPERTY = new ChildListPropertyDescriptor ( ArrayInitializer . class , "<STR_LIT>" , Expression . class , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:2> ) ; createPropertyList ( ArrayInitializer . class , properyList ) ; addProperty ( EXPRESSIONS_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private ASTNode . NodeList expressions = new ASTNode . NodeList ( EXPRESSIONS_PROPERTY ) ; ArrayInitializer ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == EXPRESSIONS_PROPERTY ) { return expressions ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return ARRAY_INITIALIZER ; } ASTNode clone0 ( AST target ) { ArrayInitializer result = new ArrayInitializer ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . expressions ( ) . addAll ( ASTNode . copySubtrees ( target , expressions ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChildren ( visitor , this . expressions ) ; } visitor . endVisit ( this ) ; } public List expressions ( ) { return this . expressions ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:1> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + this . expressions . listSize ( ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import org . eclipse . jdt . core . IJavaElement ; class RecoveredVariableBinding implements IVariableBinding { private VariableDeclaration variableDeclaration ; private BindingResolver resolver ; RecoveredVariableBinding ( BindingResolver resolver , VariableDeclaration variableDeclaration ) { this . resolver = resolver ; this . variableDeclaration = variableDeclaration ; } public Object getConstantValue ( ) { return null ; } public ITypeBinding getDeclaringClass ( ) { ASTNode parent = this . variableDeclaration . getParent ( ) ; while ( parent != null && parent . getNodeType ( ) != ASTNode . TYPE_DECLARATION ) { parent = parent . getParent ( ) ; } if ( parent != null ) { return ( ( TypeDeclaration ) parent ) . resolveBinding ( ) ; } return null ; } public IMethodBinding getDeclaringMethod ( ) { ASTNode parent = this . variableDeclaration . getParent ( ) ; while ( parent != null && parent . getNodeType ( ) != ASTNode . METHOD_DECLARATION ) { parent = parent . getParent ( ) ; } if ( parent != null ) { return ( ( MethodDeclaration ) parent ) . resolveBinding ( ) ; } return null ; } public String getName ( ) { return this . variableDeclaration . getName ( ) . getIdentifier ( ) ; } public ITypeBinding getType ( ) { return this . resolver . getTypeBinding ( this . variableDeclaration ) ; } public IVariableBinding getVariableDeclaration ( ) { return this ; } public int getVariableId ( ) { return <NUM_LIT:0> ; } public boolean isEnumConstant ( ) { return false ; } public boolean isField ( ) { return this . variableDeclaration . getParent ( ) instanceof FieldDeclaration ; } public boolean isParameter ( ) { return this . variableDeclaration instanceof SingleVariableDeclaration ; } public IAnnotationBinding [ ] getAnnotations ( ) { return AnnotationBinding . NoAnnotations ; } public IJavaElement getJavaElement ( ) { return null ; } public String getKey ( ) { StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( "<STR_LIT>" ) ; if ( this . variableDeclaration != null ) { buffer . append ( "<STR_LIT>" ) . append ( this . variableDeclaration . getClass ( ) ) . append ( this . variableDeclaration . getName ( ) . getIdentifier ( ) ) . append ( this . variableDeclaration . getExtraDimensions ( ) ) ; } return String . valueOf ( buffer ) ; } public int getKind ( ) { return IBinding . VARIABLE ; } public int getModifiers ( ) { return <NUM_LIT:0> ; } public boolean isDeprecated ( ) { return false ; } public boolean isEqualTo ( IBinding binding ) { if ( binding . isRecovered ( ) && binding . getKind ( ) == IBinding . VARIABLE ) { return getKey ( ) . equals ( binding . getKey ( ) ) ; } return false ; } public boolean isRecovered ( ) { return true ; } public boolean isSynthetic ( ) { return false ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; public class CastExpression extends Expression { public static final ChildPropertyDescriptor TYPE_PROPERTY = new ChildPropertyDescriptor ( CastExpression . class , "<STR_LIT:type>" , Type . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor ( CastExpression . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List properyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( CastExpression . class , properyList ) ; addProperty ( TYPE_PROPERTY , properyList ) ; addProperty ( EXPRESSION_PROPERTY , properyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( properyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private Type type = null ; private Expression expression = null ; CastExpression ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == EXPRESSION_PROPERTY ) { if ( get ) { return getExpression ( ) ; } else { setExpression ( ( Expression ) child ) ; return null ; } } if ( property == TYPE_PROPERTY ) { if ( get ) { return getType ( ) ; } else { setType ( ( Type ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return CAST_EXPRESSION ; } ASTNode clone0 ( AST target ) { CastExpression result = new CastExpression ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setType ( ( Type ) getType ( ) . clone ( target ) ) ; result . setExpression ( ( Expression ) getExpression ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getType ( ) ) ; acceptChild ( visitor , getExpression ( ) ) ; } visitor . endVisit ( this ) ; } public Type getType ( ) { if ( this . type == null ) { synchronized ( this ) { if ( this . type == null ) { preLazyInit ( ) ; this . type = this . ast . newPrimitiveType ( PrimitiveType . INT ) ; postLazyInit ( this . type , TYPE_PROPERTY ) ; } } } return this . type ; } public void setType ( Type type ) { if ( type == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . type ; preReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; this . type = type ; postReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; } public Expression getExpression ( ) { if ( this . expression == null ) { synchronized ( this ) { if ( this . expression == null ) { preLazyInit ( ) ; this . expression = new SimpleName ( this . ast ) ; postLazyInit ( this . expression , EXPRESSION_PROPERTY ) ; } } } return this . expression ; } public void setExpression ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . expression ; preReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; this . expression = expression ; postReplaceChild ( oldChild , expression , EXPRESSION_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . expression == null ? <NUM_LIT:0> : getExpression ( ) . treeSize ( ) ) + ( this . type == null ? <NUM_LIT:0> : getType ( ) . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import org . eclipse . jdt . core . compiler . CategorizedProblem ; import org . eclipse . jdt . core . compiler . IProblem ; class ASTSyntaxErrorPropagator extends ASTVisitor { private CategorizedProblem [ ] problems ; ASTSyntaxErrorPropagator ( CategorizedProblem [ ] problems ) { super ( true ) ; this . problems = problems ; } private boolean checkAndTagAsMalformed ( ASTNode node ) { boolean tagWithErrors = false ; search : for ( int i = <NUM_LIT:0> , max = this . problems . length ; i < max ; i ++ ) { CategorizedProblem problem = this . problems [ i ] ; switch ( problem . getID ( ) ) { case IProblem . ParsingErrorOnKeywordNoSuggestion : case IProblem . ParsingErrorOnKeyword : case IProblem . ParsingError : case IProblem . ParsingErrorNoSuggestion : case IProblem . ParsingErrorInsertTokenBefore : case IProblem . ParsingErrorInsertTokenAfter : case IProblem . ParsingErrorDeleteToken : case IProblem . ParsingErrorDeleteTokens : case IProblem . ParsingErrorMergeTokens : case IProblem . ParsingErrorInvalidToken : case IProblem . ParsingErrorMisplacedConstruct : case IProblem . ParsingErrorReplaceTokens : case IProblem . ParsingErrorNoSuggestionForTokens : case IProblem . ParsingErrorUnexpectedEOF : case IProblem . ParsingErrorInsertToComplete : case IProblem . ParsingErrorInsertToCompleteScope : case IProblem . ParsingErrorInsertToCompletePhrase : case IProblem . EndOfSource : case IProblem . InvalidHexa : case IProblem . InvalidOctal : case IProblem . InvalidCharacterConstant : case IProblem . InvalidEscape : case IProblem . InvalidInput : case IProblem . InvalidUnicodeEscape : case IProblem . InvalidFloat : case IProblem . NullSourceString : case IProblem . UnterminatedString : case IProblem . UnterminatedComment : case IProblem . InvalidDigit : break ; default : continue search ; } int position = problem . getSourceStart ( ) ; int start = node . getStartPosition ( ) ; int end = start + node . getLength ( ) ; if ( ( start <= position ) && ( position <= end ) ) { node . setFlags ( node . getFlags ( ) | ASTNode . MALFORMED ) ; ASTNode currentNode = node . getParent ( ) ; while ( currentNode != null ) { currentNode . setFlags ( currentNode . getFlags ( ) & ~ ASTNode . MALFORMED ) ; currentNode = currentNode . getParent ( ) ; } tagWithErrors = true ; } } return tagWithErrors ; } public boolean visit ( FieldDeclaration node ) { return checkAndTagAsMalformed ( node ) ; } public boolean visit ( MethodDeclaration node ) { return checkAndTagAsMalformed ( node ) ; } public boolean visit ( PackageDeclaration node ) { return checkAndTagAsMalformed ( node ) ; } public boolean visit ( ImportDeclaration node ) { return checkAndTagAsMalformed ( node ) ; } public boolean visit ( CompilationUnit node ) { return checkAndTagAsMalformed ( node ) ; } public boolean visit ( AnnotationTypeDeclaration node ) { return checkAndTagAsMalformed ( node ) ; } public boolean visit ( EnumDeclaration node ) { return checkAndTagAsMalformed ( node ) ; } public boolean visit ( TypeDeclaration node ) { return checkAndTagAsMalformed ( node ) ; } public boolean visit ( Initializer node ) { return checkAndTagAsMalformed ( node ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . Iterator ; import java . util . List ; public class VariableDeclarationStatement extends Statement { public static final SimplePropertyDescriptor MODIFIERS_PROPERTY = new SimplePropertyDescriptor ( VariableDeclarationStatement . class , "<STR_LIT>" , int . class , MANDATORY ) ; public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY = new ChildListPropertyDescriptor ( VariableDeclarationStatement . class , "<STR_LIT>" , IExtendedModifier . class , CYCLE_RISK ) ; public static final ChildPropertyDescriptor TYPE_PROPERTY = new ChildPropertyDescriptor ( VariableDeclarationStatement . class , "<STR_LIT:type>" , Type . class , MANDATORY , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor FRAGMENTS_PROPERTY = new ChildListPropertyDescriptor ( VariableDeclarationStatement . class , "<STR_LIT>" , VariableDeclarationFragment . class , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List propertyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( VariableDeclarationStatement . class , propertyList ) ; addProperty ( MODIFIERS_PROPERTY , propertyList ) ; addProperty ( TYPE_PROPERTY , propertyList ) ; addProperty ( FRAGMENTS_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( propertyList ) ; propertyList = new ArrayList ( <NUM_LIT:4> ) ; createPropertyList ( VariableDeclarationStatement . class , propertyList ) ; addProperty ( MODIFIERS2_PROPERTY , propertyList ) ; addProperty ( TYPE_PROPERTY , propertyList ) ; addProperty ( FRAGMENTS_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private ASTNode . NodeList modifiers = null ; private int modifierFlags = Modifier . NONE ; private Type baseType = null ; private ASTNode . NodeList variableDeclarationFragments = new ASTNode . NodeList ( FRAGMENTS_PROPERTY ) ; VariableDeclarationStatement ( AST ast ) { super ( ast ) ; if ( ast . apiLevel >= AST . JLS3 ) { this . modifiers = new ASTNode . NodeList ( MODIFIERS2_PROPERTY ) ; } } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final int internalGetSetIntProperty ( SimplePropertyDescriptor property , boolean get , int value ) { if ( property == MODIFIERS_PROPERTY ) { if ( get ) { return getModifiers ( ) ; } else { setModifiers ( value ) ; return <NUM_LIT:0> ; } } return super . internalGetSetIntProperty ( property , get , value ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == TYPE_PROPERTY ) { if ( get ) { return getType ( ) ; } else { setType ( ( Type ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == MODIFIERS2_PROPERTY ) { return modifiers ( ) ; } if ( property == FRAGMENTS_PROPERTY ) { return fragments ( ) ; } return super . internalGetChildListProperty ( property ) ; } final int getNodeType0 ( ) { return VARIABLE_DECLARATION_STATEMENT ; } ASTNode clone0 ( AST target ) { VariableDeclarationStatement result = new VariableDeclarationStatement ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . copyLeadingComment ( this ) ; if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { result . setModifiers ( getModifiers ( ) ) ; } if ( this . ast . apiLevel >= AST . JLS3 ) { result . modifiers ( ) . addAll ( ASTNode . copySubtrees ( target , modifiers ( ) ) ) ; } result . setType ( ( Type ) getType ( ) . clone ( target ) ) ; result . fragments ( ) . addAll ( ASTNode . copySubtrees ( target , fragments ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { if ( this . ast . apiLevel >= AST . JLS3 ) { acceptChildren ( visitor , this . modifiers ) ; } acceptChild ( visitor , getType ( ) ) ; acceptChildren ( visitor , this . variableDeclarationFragments ) ; } visitor . endVisit ( this ) ; } public List modifiers ( ) { if ( this . modifiers == null ) { unsupportedIn2 ( ) ; } return this . modifiers ; } public int getModifiers ( ) { if ( this . modifiers == null ) { return this . modifierFlags ; } else { int computedModifierFlags = Modifier . NONE ; for ( Iterator it = modifiers ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Object x = it . next ( ) ; if ( x instanceof Modifier ) { computedModifierFlags |= ( ( Modifier ) x ) . getKeyword ( ) . toFlagValue ( ) ; } } return computedModifierFlags ; } } public void setModifiers ( int modifiers ) { internalSetModifiers ( modifiers ) ; } final void internalSetModifiers ( int pmodifiers ) { supportedOnlyIn2 ( ) ; preValueChange ( MODIFIERS_PROPERTY ) ; this . modifierFlags = pmodifiers ; postValueChange ( MODIFIERS_PROPERTY ) ; } public Type getType ( ) { if ( this . baseType == null ) { synchronized ( this ) { if ( this . baseType == null ) { preLazyInit ( ) ; this . baseType = this . ast . newPrimitiveType ( PrimitiveType . INT ) ; postLazyInit ( this . baseType , TYPE_PROPERTY ) ; } } } return this . baseType ; } public void setType ( Type type ) { if ( type == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . baseType ; preReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; this . baseType = type ; postReplaceChild ( oldChild , type , TYPE_PROPERTY ) ; } public List fragments ( ) { return this . variableDeclarationFragments ; } int memSize ( ) { return super . memSize ( ) + <NUM_LIT:4> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . modifiers == null ? <NUM_LIT:0> : this . modifiers . listSize ( ) ) + ( this . baseType == null ? <NUM_LIT:0> : getType ( ) . treeSize ( ) ) + this . variableDeclarationFragments . listSize ( ) ; } } </s>
<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; public class PostfixExpression extends Expression { public static class Operator { private String token ; private Operator ( String token ) { this . token = token ; } public String toString ( ) { return this . token ; } public static final Operator INCREMENT = new Operator ( "<STR_LIT>" ) ; public static final Operator DECREMENT = new Operator ( "<STR_LIT:-->" ) ; private static final Map CODES ; static { CODES = new HashMap ( <NUM_LIT:20> ) ; Operator [ ] ops = { INCREMENT , DECREMENT , } ; for ( int i = <NUM_LIT:0> ; i < ops . length ; i ++ ) { CODES . put ( ops [ i ] . toString ( ) , ops [ i ] ) ; } } public static Operator toOperator ( String token ) { return ( Operator ) CODES . get ( token ) ; } } public static final SimplePropertyDescriptor OPERATOR_PROPERTY = new SimplePropertyDescriptor ( PostfixExpression . class , "<STR_LIT>" , PostfixExpression . Operator . class , MANDATORY ) ; public static final ChildPropertyDescriptor OPERAND_PROPERTY = new ChildPropertyDescriptor ( PostfixExpression . class , "<STR_LIT>" , Expression . class , MANDATORY , CYCLE_RISK ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( <NUM_LIT:3> ) ; createPropertyList ( PostfixExpression . class , propertyList ) ; addProperty ( OPERAND_PROPERTY , propertyList ) ; addProperty ( OPERATOR_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private PostfixExpression . Operator operator = PostfixExpression . Operator . INCREMENT ; private Expression operand = null ; PostfixExpression ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final Object internalGetSetObjectProperty ( SimplePropertyDescriptor property , boolean get , Object value ) { if ( property == OPERATOR_PROPERTY ) { if ( get ) { return getOperator ( ) ; } else { setOperator ( ( Operator ) value ) ; return null ; } } return super . internalGetSetObjectProperty ( property , get , value ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == OPERAND_PROPERTY ) { if ( get ) { return getOperand ( ) ; } else { setOperand ( ( Expression ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final int getNodeType0 ( ) { return POSTFIX_EXPRESSION ; } ASTNode clone0 ( AST target ) { PostfixExpression result = new PostfixExpression ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setOperator ( getOperator ( ) ) ; result . setOperand ( ( Expression ) getOperand ( ) . clone ( target ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { acceptChild ( visitor , getOperand ( ) ) ; } visitor . endVisit ( this ) ; } public PostfixExpression . Operator getOperator ( ) { return this . operator ; } public void setOperator ( PostfixExpression . Operator operator ) { if ( operator == null ) { throw new IllegalArgumentException ( ) ; } preValueChange ( OPERATOR_PROPERTY ) ; this . operator = operator ; postValueChange ( OPERATOR_PROPERTY ) ; } public Expression getOperand ( ) { if ( this . operand == null ) { synchronized ( this ) { if ( this . operand == null ) { preLazyInit ( ) ; this . operand = new SimpleName ( this . ast ) ; postLazyInit ( this . operand , OPERAND_PROPERTY ) ; } } } return this . operand ; } public void setOperand ( Expression expression ) { if ( expression == null ) { throw new IllegalArgumentException ( ) ; } ASTNode oldChild = this . operand ; preReplaceChild ( oldChild , expression , OPERAND_PROPERTY ) ; this . operand = expression ; postReplaceChild ( oldChild , expression , OPERAND_PROPERTY ) ; } int memSize ( ) { return BASE_NODE_SIZE + <NUM_LIT:2> * <NUM_LIT:4> ; } int treeSize ( ) { return memSize ( ) + ( this . operand == null ? <NUM_LIT:0> : getOperand ( ) . treeSize ( ) ) ; } } </s>
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . HashSet ; import java . util . IdentityHashMap ; import java . util . Map ; import java . util . Set ; import org . eclipse . jdt . core . dom . AST ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . Block ; import org . eclipse . jdt . core . dom . FieldDeclaration ; import org . eclipse . jdt . core . dom . Modifier ; import org . eclipse . jdt . core . dom . ParameterizedType ; import org . eclipse . jdt . core . dom . TryStatement ; import org . eclipse . jdt . core . dom . VariableDeclarationExpression ; import org . eclipse . jdt . core . dom . VariableDeclarationStatement ; import org . eclipse . jdt . internal . core . dom . rewrite . RewriteEventStore . CopySourceInfo ; public final class NodeInfoStore { private AST ast ; private Map placeholderNodes ; private Set collapsedNodes ; public NodeInfoStore ( AST ast ) { super ( ) ; this . ast = ast ; this . placeholderNodes = null ; this . collapsedNodes = null ; } public final void markAsStringPlaceholder ( ASTNode placeholder , String code ) { StringPlaceholderData data = new StringPlaceholderData ( ) ; data . code = code ; setPlaceholderData ( placeholder , data ) ; } public final void markAsCopyTarget ( ASTNode target , CopySourceInfo copySource ) { CopyPlaceholderData data = new CopyPlaceholderData ( ) ; data . copySource = copySource ; setPlaceholderData ( target , data ) ; } public final ASTNode newPlaceholderNode ( int nodeType ) { try { ASTNode node = this . ast . createInstance ( nodeType ) ; switch ( node . getNodeType ( ) ) { case ASTNode . FIELD_DECLARATION : ( ( FieldDeclaration ) node ) . fragments ( ) . add ( this . ast . newVariableDeclarationFragment ( ) ) ; break ; case ASTNode . MODIFIER : ( ( Modifier ) node ) . setKeyword ( Modifier . ModifierKeyword . ABSTRACT_KEYWORD ) ; break ; case ASTNode . TRY_STATEMENT : ( ( TryStatement ) node ) . setFinally ( this . ast . newBlock ( ) ) ; break ; case ASTNode . VARIABLE_DECLARATION_EXPRESSION : ( ( VariableDeclarationExpression ) node ) . fragments ( ) . add ( this . ast . newVariableDeclarationFragment ( ) ) ; break ; case ASTNode . VARIABLE_DECLARATION_STATEMENT : ( ( VariableDeclarationStatement ) node ) . fragments ( ) . add ( this . ast . newVariableDeclarationFragment ( ) ) ; break ; case ASTNode . PARAMETERIZED_TYPE : ( ( ParameterizedType ) node ) . typeArguments ( ) . add ( this . ast . newWildcardType ( ) ) ; break ; } return node ; } catch ( IllegalArgumentException e ) { return null ; } } public Block createCollapsePlaceholder ( ) { Block placeHolder = this . ast . newBlock ( ) ; if ( this . collapsedNodes == null ) { this . collapsedNodes = new HashSet ( ) ; } this . collapsedNodes . add ( placeHolder ) ; return placeHolder ; } public boolean isCollapsed ( ASTNode node ) { if ( this . collapsedNodes != null ) { return this . collapsedNodes . contains ( node ) ; } return false ; } public Object getPlaceholderData ( ASTNode node ) { if ( this . placeholderNodes != null ) { return this . placeholderNodes . get ( node ) ; } return null ; } private void setPlaceholderData ( ASTNode node , PlaceholderData data ) { if ( this . placeholderNodes == null ) { this . placeholderNodes = new IdentityHashMap ( ) ; } this . placeholderNodes . put ( node , data ) ; } static class PlaceholderData { } protected static final class CopyPlaceholderData extends PlaceholderData { public CopySourceInfo copySource ; public String toString ( ) { return "<STR_LIT>" + this . copySource + "<STR_LIT:]>" ; } } protected static final class StringPlaceholderData extends PlaceholderData { public String code ; public String toString ( ) { return "<STR_LIT>" + this . code + "<STR_LIT:]>" ; } } public void clear ( ) { this . placeholderNodes = null ; this . collapsedNodes = null ; } } </s>
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import org . eclipse . text . edits . TextEdit ; import org . eclipse . text . edits . TextEditGroup ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . rewrite . ITrackedNodePosition ; import org . eclipse . jface . text . IRegion ; public class TrackedNodePosition implements ITrackedNodePosition { private final TextEditGroup group ; private final ASTNode node ; public TrackedNodePosition ( TextEditGroup group , ASTNode node ) { this . group = group ; this . node = node ; } public int getStartPosition ( ) { if ( this . group . isEmpty ( ) ) { return this . node . getStartPosition ( ) ; } IRegion coverage = TextEdit . getCoverage ( this . group . getTextEdits ( ) ) ; if ( coverage == null ) { return this . node . getStartPosition ( ) ; } return coverage . getOffset ( ) ; } public int getLength ( ) { if ( this . group . isEmpty ( ) ) { return this . node . getLength ( ) ; } IRegion coverage = TextEdit . getCoverage ( this . group . getTextEdits ( ) ) ; if ( coverage == null ) { return this . node . getLength ( ) ; } return coverage . getLength ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . ArrayList ; import java . util . List ; import org . eclipse . jdt . core . formatter . IndentManipulation ; import org . eclipse . text . edits . ISourceModifier ; import org . eclipse . text . edits . ReplaceEdit ; public class SourceModifier implements ISourceModifier { private final String destinationIndent ; private final int sourceIndentLevel ; private final int tabWidth ; private final int indentWidth ; public SourceModifier ( int sourceIndentLevel , String destinationIndent , int tabWidth , int indentWidth ) { this . destinationIndent = destinationIndent ; this . sourceIndentLevel = sourceIndentLevel ; this . tabWidth = tabWidth ; this . indentWidth = indentWidth ; } public ISourceModifier copy ( ) { return this ; } public ReplaceEdit [ ] getModifications ( String source ) { List result = new ArrayList ( ) ; int destIndentLevel = IndentManipulation . measureIndentUnits ( this . destinationIndent , this . tabWidth , this . indentWidth ) ; if ( destIndentLevel == this . sourceIndentLevel ) { return ( ReplaceEdit [ ] ) result . toArray ( new ReplaceEdit [ result . size ( ) ] ) ; } return IndentManipulation . getChangeIndentEdits ( source , this . sourceIndentLevel , this . tabWidth , this . indentWidth , this . destinationIndent ) ; } } </s>
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; public abstract class RewriteEvent { public static final int INSERTED = <NUM_LIT:1> ; public static final int REMOVED = <NUM_LIT:2> ; public static final int REPLACED = <NUM_LIT:4> ; public static final int CHILDREN_CHANGED = <NUM_LIT:8> ; public static final int UNCHANGED = <NUM_LIT:0> ; public abstract int getChangeKind ( ) ; public abstract boolean isListRewrite ( ) ; public abstract Object getOriginalValue ( ) ; public abstract Object getNewValue ( ) ; public abstract RewriteEvent [ ] getChildren ( ) ; } </s>
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . List ; import org . eclipse . jdt . core . dom . * ; import org . eclipse . jdt . internal . compiler . util . Util ; public class ASTRewriteFlattener extends ASTVisitor { static final int JLS2_INTERNAL = AST . JLS2 ; public static String asString ( ASTNode node , RewriteEventStore store ) { ASTRewriteFlattener flattener = new ASTRewriteFlattener ( store ) ; node . accept ( flattener ) ; return flattener . getResult ( ) ; } protected StringBuffer result ; private RewriteEventStore store ; public ASTRewriteFlattener ( RewriteEventStore store ) { this . store = store ; this . result = new StringBuffer ( ) ; } public String getResult ( ) { return new String ( this . result . toString ( ) ) ; } public void reset ( ) { this . result . setLength ( <NUM_LIT:0> ) ; } public static void printModifiers ( int modifiers , StringBuffer buf ) { if ( Modifier . isPublic ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isProtected ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isPrivate ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isStatic ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isAbstract ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isFinal ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isSynchronized ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isVolatile ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isNative ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isStrictfp ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } if ( Modifier . isTransient ( modifiers ) ) { buf . append ( "<STR_LIT>" ) ; } } protected List getChildList ( ASTNode parent , StructuralPropertyDescriptor childProperty ) { return ( List ) getAttribute ( parent , childProperty ) ; } protected ASTNode getChildNode ( ASTNode parent , StructuralPropertyDescriptor childProperty ) { return ( ASTNode ) getAttribute ( parent , childProperty ) ; } protected int getIntAttribute ( ASTNode parent , StructuralPropertyDescriptor childProperty ) { return ( ( Integer ) getAttribute ( parent , childProperty ) ) . intValue ( ) ; } protected boolean getBooleanAttribute ( ASTNode parent , StructuralPropertyDescriptor childProperty ) { return ( ( Boolean ) getAttribute ( parent , childProperty ) ) . booleanValue ( ) ; } protected Object getAttribute ( ASTNode parent , StructuralPropertyDescriptor childProperty ) { return this . store . getNewValue ( parent , childProperty ) ; } protected void visitList ( ASTNode parent , StructuralPropertyDescriptor childProperty , String separator ) { List list = getChildList ( parent , childProperty ) ; for ( int i = <NUM_LIT:0> ; i < list . size ( ) ; i ++ ) { if ( separator != null && i > <NUM_LIT:0> ) { this . result . append ( separator ) ; } ( ( ASTNode ) list . get ( i ) ) . accept ( this ) ; } } protected void visitList ( ASTNode parent , StructuralPropertyDescriptor childProperty , String separator , String lead , String post ) { List list = getChildList ( parent , childProperty ) ; if ( ! list . isEmpty ( ) ) { this . result . append ( lead ) ; for ( int i = <NUM_LIT:0> ; i < list . size ( ) ; i ++ ) { if ( separator != null && i > <NUM_LIT:0> ) { this . result . append ( separator ) ; } ( ( ASTNode ) list . get ( i ) ) . accept ( this ) ; } this . result . append ( post ) ; } } public boolean visit ( AnonymousClassDeclaration node ) { this . result . append ( '<CHAR_LIT>' ) ; visitList ( node , AnonymousClassDeclaration . BODY_DECLARATIONS_PROPERTY , null ) ; this . result . append ( '<CHAR_LIT:}>' ) ; return false ; } public boolean visit ( ArrayAccess node ) { getChildNode ( node , ArrayAccess . ARRAY_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:[>' ) ; getChildNode ( node , ArrayAccess . INDEX_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:]>' ) ; return false ; } public boolean visit ( ArrayCreation node ) { this . result . append ( "<STR_LIT>" ) ; ArrayType arrayType = ( ArrayType ) getChildNode ( node , ArrayCreation . TYPE_PROPERTY ) ; Type elementType = ( Type ) getChildNode ( arrayType , ArrayType . COMPONENT_TYPE_PROPERTY ) ; int dimensions = <NUM_LIT:1> ; while ( elementType . isArrayType ( ) ) { dimensions ++ ; elementType = ( Type ) getChildNode ( elementType , ArrayType . COMPONENT_TYPE_PROPERTY ) ; } elementType . accept ( this ) ; List list = getChildList ( node , ArrayCreation . DIMENSIONS_PROPERTY ) ; for ( int i = <NUM_LIT:0> ; i < list . size ( ) ; i ++ ) { this . result . append ( '<CHAR_LIT:[>' ) ; ( ( ASTNode ) list . get ( i ) ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:]>' ) ; dimensions -- ; } for ( int i = <NUM_LIT:0> ; i < dimensions ; i ++ ) { this . result . append ( "<STR_LIT:[]>" ) ; } ASTNode initializer = getChildNode ( node , ArrayCreation . INITIALIZER_PROPERTY ) ; if ( initializer != null ) { getChildNode ( node , ArrayCreation . INITIALIZER_PROPERTY ) . accept ( this ) ; } return false ; } public boolean visit ( ArrayInitializer node ) { this . result . append ( '<CHAR_LIT>' ) ; visitList ( node , ArrayInitializer . EXPRESSIONS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:}>' ) ; return false ; } public boolean visit ( ArrayType node ) { getChildNode ( node , ArrayType . COMPONENT_TYPE_PROPERTY ) . accept ( this ) ; this . result . append ( "<STR_LIT:[]>" ) ; return false ; } public boolean visit ( AssertStatement node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , AssertStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; ASTNode message = getChildNode ( node , AssertStatement . MESSAGE_PROPERTY ) ; if ( message != null ) { this . result . append ( '<CHAR_LIT::>' ) ; message . accept ( this ) ; } this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( Assignment node ) { getChildNode ( node , Assignment . LEFT_HAND_SIDE_PROPERTY ) . accept ( this ) ; this . result . append ( getAttribute ( node , Assignment . OPERATOR_PROPERTY ) . toString ( ) ) ; getChildNode ( node , Assignment . RIGHT_HAND_SIDE_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( Block node ) { this . result . append ( '<CHAR_LIT>' ) ; visitList ( node , Block . STATEMENTS_PROPERTY , null ) ; this . result . append ( '<CHAR_LIT:}>' ) ; return false ; } public boolean visit ( BooleanLiteral node ) { if ( node . booleanValue ( ) == true ) { this . result . append ( "<STR_LIT:true>" ) ; } else { this . result . append ( "<STR_LIT:false>" ) ; } return false ; } public boolean visit ( BreakStatement node ) { this . result . append ( "<STR_LIT>" ) ; ASTNode label = getChildNode ( node , BreakStatement . LABEL_PROPERTY ) ; if ( label != null ) { this . result . append ( '<CHAR_LIT:U+0020>' ) ; label . accept ( this ) ; } this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( CastExpression node ) { this . result . append ( '<CHAR_LIT:(>' ) ; getChildNode ( node , CastExpression . TYPE_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; getChildNode ( node , CastExpression . EXPRESSION_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( CatchClause node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , CatchClause . EXCEPTION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; getChildNode ( node , CatchClause . BODY_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( CharacterLiteral node ) { this . result . append ( getAttribute ( node , CharacterLiteral . ESCAPED_VALUE_PROPERTY ) ) ; return false ; } public boolean visit ( ClassInstanceCreation node ) { ASTNode expression = getChildNode ( node , ClassInstanceCreation . EXPRESSION_PROPERTY ) ; if ( expression != null ) { expression . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; } this . result . append ( "<STR_LIT>" ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { getChildNode ( node , ClassInstanceCreation . NAME_PROPERTY ) . accept ( this ) ; } else { visitList ( node , ClassInstanceCreation . TYPE_ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , String . valueOf ( '<CHAR_LIT>' ) , String . valueOf ( '<CHAR_LIT:>>' ) ) ; getChildNode ( node , ClassInstanceCreation . TYPE_PROPERTY ) . accept ( this ) ; } this . result . append ( '<CHAR_LIT:(>' ) ; visitList ( node , ClassInstanceCreation . ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:)>' ) ; ASTNode decl = getChildNode ( node , ClassInstanceCreation . ANONYMOUS_CLASS_DECLARATION_PROPERTY ) ; if ( decl != null ) { decl . accept ( this ) ; } return false ; } public boolean visit ( CompilationUnit node ) { ASTNode pack = getChildNode ( node , CompilationUnit . PACKAGE_PROPERTY ) ; if ( pack != null ) { pack . accept ( this ) ; } visitList ( node , CompilationUnit . IMPORTS_PROPERTY , null ) ; visitList ( node , CompilationUnit . TYPES_PROPERTY , null ) ; return false ; } public boolean visit ( ConditionalExpression node ) { getChildNode ( node , ConditionalExpression . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT>' ) ; getChildNode ( node , ConditionalExpression . THEN_EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT::>' ) ; getChildNode ( node , ConditionalExpression . ELSE_EXPRESSION_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( ConstructorInvocation node ) { if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { visitList ( node , ConstructorInvocation . TYPE_ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , String . valueOf ( '<CHAR_LIT>' ) , String . valueOf ( '<CHAR_LIT:>>' ) ) ; } this . result . append ( "<STR_LIT>" ) ; visitList ( node , ConstructorInvocation . ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( ContinueStatement node ) { this . result . append ( "<STR_LIT>" ) ; ASTNode label = getChildNode ( node , ContinueStatement . LABEL_PROPERTY ) ; if ( label != null ) { this . result . append ( '<CHAR_LIT:U+0020>' ) ; label . accept ( this ) ; } this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( DoStatement node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , DoStatement . BODY_PROPERTY ) . accept ( this ) ; this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , DoStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( EmptyStatement node ) { this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( ExpressionStatement node ) { getChildNode ( node , ExpressionStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( FieldAccess node ) { getChildNode ( node , FieldAccess . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; getChildNode ( node , FieldAccess . NAME_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( FieldDeclaration node ) { ASTNode javadoc = getChildNode ( node , FieldDeclaration . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { printModifiers ( getIntAttribute ( node , FieldDeclaration . MODIFIERS_PROPERTY ) , this . result ) ; } else { visitList ( node , FieldDeclaration . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; } getChildNode ( node , FieldDeclaration . TYPE_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; visitList ( node , FieldDeclaration . FRAGMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( ForStatement node ) { this . result . append ( "<STR_LIT>" ) ; visitList ( node , ForStatement . INITIALIZERS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:;>' ) ; ASTNode expression = getChildNode ( node , ForStatement . EXPRESSION_PROPERTY ) ; if ( expression != null ) { expression . accept ( this ) ; } this . result . append ( '<CHAR_LIT:;>' ) ; visitList ( node , ForStatement . UPDATERS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:)>' ) ; getChildNode ( node , ForStatement . BODY_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( IfStatement node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , IfStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; getChildNode ( node , IfStatement . THEN_STATEMENT_PROPERTY ) . accept ( this ) ; ASTNode elseStatement = getChildNode ( node , IfStatement . ELSE_STATEMENT_PROPERTY ) ; if ( elseStatement != null ) { this . result . append ( "<STR_LIT>" ) ; elseStatement . accept ( this ) ; } return false ; } public boolean visit ( ImportDeclaration node ) { this . result . append ( "<STR_LIT>" ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { if ( getBooleanAttribute ( node , ImportDeclaration . STATIC_PROPERTY ) ) { this . result . append ( "<STR_LIT>" ) ; } } getChildNode ( node , ImportDeclaration . NAME_PROPERTY ) . accept ( this ) ; if ( getBooleanAttribute ( node , ImportDeclaration . ON_DEMAND_PROPERTY ) ) { this . result . append ( "<STR_LIT>" ) ; } this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( InfixExpression node ) { getChildNode ( node , InfixExpression . LEFT_OPERAND_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; String operator = getAttribute ( node , InfixExpression . OPERATOR_PROPERTY ) . toString ( ) ; this . result . append ( operator ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; getChildNode ( node , InfixExpression . RIGHT_OPERAND_PROPERTY ) . accept ( this ) ; List list = getChildList ( node , InfixExpression . EXTENDED_OPERANDS_PROPERTY ) ; for ( int i = <NUM_LIT:0> ; i < list . size ( ) ; i ++ ) { this . result . append ( operator ) ; ( ( ASTNode ) list . get ( i ) ) . accept ( this ) ; } return false ; } public boolean visit ( InstanceofExpression node ) { getChildNode ( node , InstanceofExpression . LEFT_OPERAND_PROPERTY ) . accept ( this ) ; this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , InstanceofExpression . RIGHT_OPERAND_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( Initializer node ) { ASTNode javadoc = getChildNode ( node , Initializer . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { printModifiers ( getIntAttribute ( node , Initializer . MODIFIERS_PROPERTY ) , this . result ) ; } else { visitList ( node , Initializer . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; } getChildNode ( node , Initializer . BODY_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( Javadoc node ) { this . result . append ( "<STR_LIT>" ) ; List list = getChildList ( node , Javadoc . TAGS_PROPERTY ) ; for ( int i = <NUM_LIT:0> ; i < list . size ( ) ; i ++ ) { this . result . append ( "<STR_LIT>" ) ; ( ( ASTNode ) list . get ( i ) ) . accept ( this ) ; } this . result . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( LabeledStatement node ) { getChildNode ( node , LabeledStatement . LABEL_PROPERTY ) . accept ( this ) ; this . result . append ( "<STR_LIT::U+0020>" ) ; getChildNode ( node , LabeledStatement . BODY_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( MethodDeclaration node ) { ASTNode javadoc = getChildNode ( node , MethodDeclaration . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { printModifiers ( getIntAttribute ( node , MethodDeclaration . MODIFIERS_PROPERTY ) , this . result ) ; } else { visitList ( node , MethodDeclaration . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; visitList ( node , MethodDeclaration . TYPE_PARAMETERS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , String . valueOf ( '<CHAR_LIT>' ) , String . valueOf ( '<CHAR_LIT:>>' ) ) ; } if ( ! getBooleanAttribute ( node , MethodDeclaration . CONSTRUCTOR_PROPERTY ) ) { if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { getChildNode ( node , MethodDeclaration . RETURN_TYPE_PROPERTY ) . accept ( this ) ; } else { ASTNode returnType = getChildNode ( node , MethodDeclaration . RETURN_TYPE2_PROPERTY ) ; if ( returnType != null ) { returnType . accept ( this ) ; } else { this . result . append ( "<STR_LIT>" ) ; } } this . result . append ( '<CHAR_LIT:U+0020>' ) ; } getChildNode ( node , MethodDeclaration . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:(>' ) ; visitList ( node , MethodDeclaration . PARAMETERS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:)>' ) ; int extraDims = getIntAttribute ( node , MethodDeclaration . EXTRA_DIMENSIONS_PROPERTY ) ; for ( int i = <NUM_LIT:0> ; i < extraDims ; i ++ ) { this . result . append ( "<STR_LIT:[]>" ) ; } visitList ( node , MethodDeclaration . THROWN_EXCEPTIONS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , "<STR_LIT>" , Util . EMPTY_STRING ) ; ASTNode body = getChildNode ( node , MethodDeclaration . BODY_PROPERTY ) ; if ( body == null ) { this . result . append ( '<CHAR_LIT:;>' ) ; } else { body . accept ( this ) ; } return false ; } public boolean visit ( MethodInvocation node ) { ASTNode expression = getChildNode ( node , MethodInvocation . EXPRESSION_PROPERTY ) ; if ( expression != null ) { expression . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; } if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { visitList ( node , MethodInvocation . TYPE_ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , String . valueOf ( '<CHAR_LIT>' ) , String . valueOf ( '<CHAR_LIT:>>' ) ) ; } getChildNode ( node , MethodInvocation . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:(>' ) ; visitList ( node , MethodInvocation . ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:)>' ) ; return false ; } public boolean visit ( NullLiteral node ) { this . result . append ( "<STR_LIT:null>" ) ; return false ; } public boolean visit ( NumberLiteral node ) { this . result . append ( getAttribute ( node , NumberLiteral . TOKEN_PROPERTY ) . toString ( ) ) ; return false ; } public boolean visit ( PackageDeclaration node ) { if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { ASTNode javadoc = getChildNode ( node , PackageDeclaration . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } visitList ( node , PackageDeclaration . ANNOTATIONS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; } this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , PackageDeclaration . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( ParenthesizedExpression node ) { this . result . append ( '<CHAR_LIT:(>' ) ; getChildNode ( node , ParenthesizedExpression . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; return false ; } public boolean visit ( PostfixExpression node ) { getChildNode ( node , PostfixExpression . OPERAND_PROPERTY ) . accept ( this ) ; this . result . append ( getAttribute ( node , PostfixExpression . OPERATOR_PROPERTY ) . toString ( ) ) ; return false ; } public boolean visit ( PrefixExpression node ) { this . result . append ( getAttribute ( node , PrefixExpression . OPERATOR_PROPERTY ) . toString ( ) ) ; getChildNode ( node , PrefixExpression . OPERAND_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( PrimitiveType node ) { this . result . append ( getAttribute ( node , PrimitiveType . PRIMITIVE_TYPE_CODE_PROPERTY ) . toString ( ) ) ; return false ; } public boolean visit ( QualifiedName node ) { getChildNode ( node , QualifiedName . QUALIFIER_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; getChildNode ( node , QualifiedName . NAME_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( ReturnStatement node ) { this . result . append ( "<STR_LIT>" ) ; ASTNode expression = getChildNode ( node , ReturnStatement . EXPRESSION_PROPERTY ) ; if ( expression != null ) { this . result . append ( '<CHAR_LIT:U+0020>' ) ; expression . accept ( this ) ; } this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( SimpleName node ) { this . result . append ( getAttribute ( node , SimpleName . IDENTIFIER_PROPERTY ) ) ; return false ; } public boolean visit ( SimpleType node ) { return true ; } public boolean visit ( SingleVariableDeclaration node ) { if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { printModifiers ( getIntAttribute ( node , SingleVariableDeclaration . MODIFIERS_PROPERTY ) , this . result ) ; } else { visitList ( node , SingleVariableDeclaration . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; } getChildNode ( node , SingleVariableDeclaration . TYPE_PROPERTY ) . accept ( this ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { if ( getBooleanAttribute ( node , SingleVariableDeclaration . VARARGS_PROPERTY ) ) { this . result . append ( "<STR_LIT:...>" ) ; } } this . result . append ( '<CHAR_LIT:U+0020>' ) ; getChildNode ( node , SingleVariableDeclaration . NAME_PROPERTY ) . accept ( this ) ; int extraDimensions = getIntAttribute ( node , SingleVariableDeclaration . EXTRA_DIMENSIONS_PROPERTY ) ; for ( int i = <NUM_LIT:0> ; i < extraDimensions ; i ++ ) { this . result . append ( "<STR_LIT:[]>" ) ; } ASTNode initializer = getChildNode ( node , SingleVariableDeclaration . INITIALIZER_PROPERTY ) ; if ( initializer != null ) { this . result . append ( '<CHAR_LIT:=>' ) ; initializer . accept ( this ) ; } return false ; } public boolean visit ( StringLiteral node ) { this . result . append ( getAttribute ( node , StringLiteral . ESCAPED_VALUE_PROPERTY ) ) ; return false ; } public boolean visit ( SuperConstructorInvocation node ) { ASTNode expression = getChildNode ( node , SuperConstructorInvocation . EXPRESSION_PROPERTY ) ; if ( expression != null ) { expression . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; } if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { visitList ( node , SuperConstructorInvocation . TYPE_ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , String . valueOf ( '<CHAR_LIT>' ) , String . valueOf ( '<CHAR_LIT:>>' ) ) ; } this . result . append ( "<STR_LIT>" ) ; visitList ( node , SuperConstructorInvocation . ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( SuperFieldAccess node ) { ASTNode qualifier = getChildNode ( node , SuperFieldAccess . QUALIFIER_PROPERTY ) ; if ( qualifier != null ) { qualifier . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; } this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , SuperFieldAccess . NAME_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( SuperMethodInvocation node ) { ASTNode qualifier = getChildNode ( node , SuperMethodInvocation . QUALIFIER_PROPERTY ) ; if ( qualifier != null ) { qualifier . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; } this . result . append ( "<STR_LIT>" ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { visitList ( node , SuperMethodInvocation . TYPE_ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , String . valueOf ( '<CHAR_LIT>' ) , String . valueOf ( '<CHAR_LIT:>>' ) ) ; } getChildNode ( node , SuperMethodInvocation . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:(>' ) ; visitList ( node , SuperMethodInvocation . ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:)>' ) ; return false ; } public boolean visit ( SwitchCase node ) { ASTNode expression = getChildNode ( node , SwitchCase . EXPRESSION_PROPERTY ) ; if ( expression == null ) { this . result . append ( "<STR_LIT:default>" ) ; } else { this . result . append ( "<STR_LIT>" ) ; expression . accept ( this ) ; } this . result . append ( '<CHAR_LIT::>' ) ; return false ; } public boolean visit ( SwitchStatement node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , SwitchStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; this . result . append ( '<CHAR_LIT>' ) ; visitList ( node , SwitchStatement . STATEMENTS_PROPERTY , null ) ; this . result . append ( '<CHAR_LIT:}>' ) ; return false ; } public boolean visit ( SynchronizedStatement node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , SynchronizedStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; getChildNode ( node , SynchronizedStatement . BODY_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( ThisExpression node ) { ASTNode qualifier = getChildNode ( node , ThisExpression . QUALIFIER_PROPERTY ) ; if ( qualifier != null ) { qualifier . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; } this . result . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( ThrowStatement node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , ThrowStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( TryStatement node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , TryStatement . BODY_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; visitList ( node , TryStatement . CATCH_CLAUSES_PROPERTY , null ) ; ASTNode finallyClause = getChildNode ( node , TryStatement . FINALLY_PROPERTY ) ; if ( finallyClause != null ) { this . result . append ( "<STR_LIT>" ) ; finallyClause . accept ( this ) ; } return false ; } public boolean visit ( TypeDeclaration node ) { int apiLevel = node . getAST ( ) . apiLevel ( ) ; ASTNode javadoc = getChildNode ( node , TypeDeclaration . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } if ( apiLevel == JLS2_INTERNAL ) { printModifiers ( getIntAttribute ( node , TypeDeclaration . MODIFIERS_PROPERTY ) , this . result ) ; } else { visitList ( node , TypeDeclaration . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; } boolean isInterface = getBooleanAttribute ( node , TypeDeclaration . INTERFACE_PROPERTY ) ; this . result . append ( isInterface ? "<STR_LIT>" : "<STR_LIT>" ) ; getChildNode ( node , TypeDeclaration . NAME_PROPERTY ) . accept ( this ) ; if ( apiLevel >= AST . JLS3 ) { visitList ( node , TypeDeclaration . TYPE_PARAMETERS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , String . valueOf ( '<CHAR_LIT>' ) , String . valueOf ( '<CHAR_LIT:>>' ) ) ; } this . result . append ( '<CHAR_LIT:U+0020>' ) ; ChildPropertyDescriptor superClassProperty = ( apiLevel == JLS2_INTERNAL ) ? TypeDeclaration . SUPERCLASS_PROPERTY : TypeDeclaration . SUPERCLASS_TYPE_PROPERTY ; ASTNode superclass = getChildNode ( node , superClassProperty ) ; if ( superclass != null ) { this . result . append ( "<STR_LIT>" ) ; superclass . accept ( this ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; } ChildListPropertyDescriptor superInterfaceProperty = ( apiLevel == JLS2_INTERNAL ) ? TypeDeclaration . SUPER_INTERFACES_PROPERTY : TypeDeclaration . SUPER_INTERFACE_TYPES_PROPERTY ; String lead = isInterface ? "<STR_LIT>" : "<STR_LIT>" ; visitList ( node , superInterfaceProperty , String . valueOf ( '<CHAR_LIT:U+002C>' ) , lead , Util . EMPTY_STRING ) ; this . result . append ( '<CHAR_LIT>' ) ; visitList ( node , TypeDeclaration . BODY_DECLARATIONS_PROPERTY , null ) ; this . result . append ( '<CHAR_LIT:}>' ) ; return false ; } public boolean visit ( TypeDeclarationStatement node ) { if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { getChildNode ( node , TypeDeclarationStatement . TYPE_DECLARATION_PROPERTY ) . accept ( this ) ; } else { getChildNode ( node , TypeDeclarationStatement . DECLARATION_PROPERTY ) . accept ( this ) ; } return false ; } public boolean visit ( TypeLiteral node ) { getChildNode ( node , TypeLiteral . TYPE_PROPERTY ) . accept ( this ) ; this . result . append ( "<STR_LIT:.class>" ) ; return false ; } public boolean visit ( VariableDeclarationExpression node ) { if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { printModifiers ( getIntAttribute ( node , VariableDeclarationExpression . MODIFIERS_PROPERTY ) , this . result ) ; } else { visitList ( node , VariableDeclarationExpression . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; } getChildNode ( node , VariableDeclarationExpression . TYPE_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; visitList ( node , VariableDeclarationExpression . FRAGMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; return false ; } public boolean visit ( VariableDeclarationFragment node ) { getChildNode ( node , VariableDeclarationFragment . NAME_PROPERTY ) . accept ( this ) ; int extraDimensions = getIntAttribute ( node , VariableDeclarationFragment . EXTRA_DIMENSIONS_PROPERTY ) ; for ( int i = <NUM_LIT:0> ; i < extraDimensions ; i ++ ) { this . result . append ( "<STR_LIT:[]>" ) ; } ASTNode initializer = getChildNode ( node , VariableDeclarationFragment . INITIALIZER_PROPERTY ) ; if ( initializer != null ) { this . result . append ( '<CHAR_LIT:=>' ) ; initializer . accept ( this ) ; } return false ; } public boolean visit ( VariableDeclarationStatement node ) { if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { printModifiers ( getIntAttribute ( node , VariableDeclarationStatement . MODIFIERS_PROPERTY ) , this . result ) ; } else { visitList ( node , VariableDeclarationStatement . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; } getChildNode ( node , VariableDeclarationStatement . TYPE_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; visitList ( node , VariableDeclarationStatement . FRAGMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) ) ; this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( WhileStatement node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , WhileStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; getChildNode ( node , WhileStatement . BODY_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( BlockComment node ) { return false ; } public boolean visit ( LineComment node ) { return false ; } public boolean visit ( MemberRef node ) { ASTNode qualifier = getChildNode ( node , MemberRef . QUALIFIER_PROPERTY ) ; if ( qualifier != null ) { qualifier . accept ( this ) ; } this . result . append ( '<CHAR_LIT>' ) ; getChildNode ( node , MemberRef . NAME_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( MethodRef node ) { ASTNode qualifier = getChildNode ( node , MethodRef . QUALIFIER_PROPERTY ) ; if ( qualifier != null ) { qualifier . accept ( this ) ; } this . result . append ( '<CHAR_LIT>' ) ; getChildNode ( node , MethodRef . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:(>' ) ; visitList ( node , MethodRef . PARAMETERS_PROPERTY , "<STR_LIT:U+002C>" ) ; this . result . append ( '<CHAR_LIT:)>' ) ; return false ; } public boolean visit ( MethodRefParameter node ) { getChildNode ( node , MethodRefParameter . TYPE_PROPERTY ) . accept ( this ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { if ( getBooleanAttribute ( node , MethodRefParameter . VARARGS_PROPERTY ) ) { this . result . append ( "<STR_LIT:...>" ) ; } } ASTNode name = getChildNode ( node , MethodRefParameter . NAME_PROPERTY ) ; if ( name != null ) { this . result . append ( '<CHAR_LIT:U+0020>' ) ; name . accept ( this ) ; } return false ; } public boolean visit ( TagElement node ) { Object tagName = getAttribute ( node , TagElement . TAG_NAME_PROPERTY ) ; if ( tagName != null ) { this . result . append ( ( String ) tagName ) ; } List list = getChildList ( node , TagElement . FRAGMENTS_PROPERTY ) ; for ( int i = <NUM_LIT:0> ; i < list . size ( ) ; i ++ ) { if ( i > <NUM_LIT:0> || tagName != null ) { this . result . append ( '<CHAR_LIT:U+0020>' ) ; } ASTNode curr = ( ASTNode ) list . get ( i ) ; if ( curr instanceof TagElement ) { this . result . append ( '<CHAR_LIT>' ) ; curr . accept ( this ) ; this . result . append ( '<CHAR_LIT:}>' ) ; } else { curr . accept ( this ) ; } } return false ; } public boolean visit ( TextElement node ) { this . result . append ( getAttribute ( node , TextElement . TEXT_PROPERTY ) ) ; return false ; } public boolean visit ( AnnotationTypeDeclaration node ) { ASTNode javadoc = getChildNode ( node , AnnotationTypeDeclaration . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } visitList ( node , AnnotationTypeDeclaration . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , AnnotationTypeDeclaration . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT>' ) ; visitList ( node , AnnotationTypeDeclaration . BODY_DECLARATIONS_PROPERTY , Util . EMPTY_STRING ) ; this . result . append ( '<CHAR_LIT:}>' ) ; return false ; } public boolean visit ( AnnotationTypeMemberDeclaration node ) { ASTNode javadoc = getChildNode ( node , AnnotationTypeMemberDeclaration . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } visitList ( node , AnnotationTypeMemberDeclaration . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; getChildNode ( node , AnnotationTypeMemberDeclaration . TYPE_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; getChildNode ( node , AnnotationTypeMemberDeclaration . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( "<STR_LIT>" ) ; ASTNode def = getChildNode ( node , AnnotationTypeMemberDeclaration . DEFAULT_PROPERTY ) ; if ( def != null ) { this . result . append ( "<STR_LIT>" ) ; def . accept ( this ) ; } this . result . append ( '<CHAR_LIT:;>' ) ; return false ; } public boolean visit ( EnhancedForStatement node ) { this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , EnhancedForStatement . PARAMETER_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT::>' ) ; getChildNode ( node , EnhancedForStatement . EXPRESSION_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; getChildNode ( node , EnhancedForStatement . BODY_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( EnumConstantDeclaration node ) { ASTNode javadoc = getChildNode ( node , EnumConstantDeclaration . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } visitList ( node , EnumConstantDeclaration . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; getChildNode ( node , EnumConstantDeclaration . NAME_PROPERTY ) . accept ( this ) ; visitList ( node , EnumConstantDeclaration . ARGUMENTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , String . valueOf ( '<CHAR_LIT:(>' ) , String . valueOf ( '<CHAR_LIT:)>' ) ) ; ASTNode classDecl = getChildNode ( node , EnumConstantDeclaration . ANONYMOUS_CLASS_DECLARATION_PROPERTY ) ; if ( classDecl != null ) { classDecl . accept ( this ) ; } return false ; } public boolean visit ( EnumDeclaration node ) { ASTNode javadoc = getChildNode ( node , EnumDeclaration . JAVADOC_PROPERTY ) ; if ( javadoc != null ) { javadoc . accept ( this ) ; } visitList ( node , EnumDeclaration . MODIFIERS2_PROPERTY , String . valueOf ( '<CHAR_LIT:U+0020>' ) , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:U+0020>' ) ) ; this . result . append ( "<STR_LIT>" ) ; getChildNode ( node , EnumDeclaration . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:U+0020>' ) ; visitList ( node , EnumDeclaration . SUPER_INTERFACE_TYPES_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , "<STR_LIT>" , Util . EMPTY_STRING ) ; this . result . append ( '<CHAR_LIT>' ) ; visitList ( node , EnumDeclaration . ENUM_CONSTANTS_PROPERTY , String . valueOf ( '<CHAR_LIT:U+002C>' ) , Util . EMPTY_STRING , Util . EMPTY_STRING ) ; visitList ( node , EnumDeclaration . BODY_DECLARATIONS_PROPERTY , Util . EMPTY_STRING , String . valueOf ( '<CHAR_LIT:;>' ) , Util . EMPTY_STRING ) ; this . result . append ( '<CHAR_LIT:}>' ) ; return false ; } public boolean visit ( MarkerAnnotation node ) { this . result . append ( '<CHAR_LIT>' ) ; getChildNode ( node , MarkerAnnotation . TYPE_NAME_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( MemberValuePair node ) { getChildNode ( node , MemberValuePair . NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:=>' ) ; getChildNode ( node , MemberValuePair . VALUE_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( Modifier node ) { this . result . append ( getAttribute ( node , Modifier . KEYWORD_PROPERTY ) . toString ( ) ) ; return false ; } public boolean visit ( NormalAnnotation node ) { this . result . append ( '<CHAR_LIT>' ) ; getChildNode ( node , NormalAnnotation . TYPE_NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:(>' ) ; visitList ( node , NormalAnnotation . VALUES_PROPERTY , "<STR_LIT:U+002CU+0020>" ) ; this . result . append ( '<CHAR_LIT:)>' ) ; return false ; } public boolean visit ( ParameterizedType node ) { getChildNode ( node , ParameterizedType . TYPE_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT>' ) ; visitList ( node , ParameterizedType . TYPE_ARGUMENTS_PROPERTY , "<STR_LIT:U+002CU+0020>" ) ; this . result . append ( '<CHAR_LIT:>>' ) ; return false ; } public boolean visit ( QualifiedType node ) { getChildNode ( node , QualifiedType . QUALIFIER_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:.>' ) ; getChildNode ( node , QualifiedType . NAME_PROPERTY ) . accept ( this ) ; return false ; } public boolean visit ( SingleMemberAnnotation node ) { this . result . append ( '<CHAR_LIT>' ) ; getChildNode ( node , SingleMemberAnnotation . TYPE_NAME_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:(>' ) ; getChildNode ( node , SingleMemberAnnotation . VALUE_PROPERTY ) . accept ( this ) ; this . result . append ( '<CHAR_LIT:)>' ) ; return false ; } public boolean visit ( TypeParameter node ) { getChildNode ( node , TypeParameter . NAME_PROPERTY ) . accept ( this ) ; visitList ( node , TypeParameter . TYPE_BOUNDS_PROPERTY , "<STR_LIT>" , "<STR_LIT>" , Util . EMPTY_STRING ) ; return false ; } public boolean visit ( WildcardType node ) { this . result . append ( '<CHAR_LIT>' ) ; ASTNode bound = getChildNode ( node , WildcardType . BOUND_PROPERTY ) ; if ( bound != null ) { if ( getBooleanAttribute ( node , WildcardType . UPPER_BOUND_PROPERTY ) ) { this . result . append ( "<STR_LIT>" ) ; } else { this . result . append ( "<STR_LIT>" ) ; } bound . accept ( this ) ; } return false ; } } </s>
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . Arrays ; import java . util . List ; import org . eclipse . jdt . core . dom . LineComment ; import org . eclipse . jdt . core . formatter . IndentManipulation ; import org . eclipse . jdt . internal . compiler . util . Util ; public class LineCommentEndOffsets { private int [ ] offsets ; private final List commentList ; public LineCommentEndOffsets ( List commentList ) { this . commentList = commentList ; this . offsets = null ; } private int [ ] getOffsets ( ) { if ( this . offsets == null ) { if ( this . commentList != null ) { int nComments = this . commentList . size ( ) ; int count = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < nComments ; i ++ ) { Object curr = this . commentList . get ( i ) ; if ( curr instanceof LineComment ) { count ++ ; } } this . offsets = new int [ count ] ; for ( int i = <NUM_LIT:0> , k = <NUM_LIT:0> ; i < nComments ; i ++ ) { Object curr = this . commentList . get ( i ) ; if ( curr instanceof LineComment ) { LineComment comment = ( LineComment ) curr ; this . offsets [ k ++ ] = comment . getStartPosition ( ) + comment . getLength ( ) ; } } } else { this . offsets = Util . EMPTY_INT_ARRAY ; } } return this . offsets ; } public boolean isEndOfLineComment ( int offset ) { return offset >= <NUM_LIT:0> && Arrays . binarySearch ( getOffsets ( ) , offset ) >= <NUM_LIT:0> ; } public boolean isEndOfLineComment ( int offset , char [ ] content ) { if ( offset < <NUM_LIT:0> || ( offset < content . length && ! IndentManipulation . isLineDelimiterChar ( content [ offset ] ) ) ) { return false ; } return Arrays . binarySearch ( getOffsets ( ) , offset ) >= <NUM_LIT:0> ; } public boolean remove ( int offset ) { int [ ] offsetArray = getOffsets ( ) ; int index = Arrays . binarySearch ( offsetArray , offset ) ; if ( index >= <NUM_LIT:0> ) { if ( index > <NUM_LIT:0> ) { System . arraycopy ( offsetArray , <NUM_LIT:0> , offsetArray , <NUM_LIT:1> , index ) ; } offsetArray [ <NUM_LIT:0> ] = - <NUM_LIT:1> ; return true ; } return false ; } } </s>
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . HashSet ; import java . util . List ; import java . util . Set ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . NullProgressMonitor ; import org . eclipse . jdt . core . IBuffer ; import org . eclipse . jdt . core . ICompilationUnit ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . CompilationUnit ; import org . eclipse . jdt . core . dom . ImportDeclaration ; import org . eclipse . jdt . core . dom . PackageDeclaration ; import org . eclipse . jdt . core . formatter . DefaultCodeFormatterConstants ; import org . eclipse . jdt . core . search . IJavaSearchConstants ; import org . eclipse . jdt . core . search . IJavaSearchScope ; import org . eclipse . jdt . core . search . SearchEngine ; import org . eclipse . jdt . core . search . TypeNameRequestor ; import org . eclipse . jdt . internal . core . JavaProject ; import org . eclipse . jface . text . IRegion ; import org . eclipse . jface . text . Region ; import org . eclipse . text . edits . DeleteEdit ; import org . eclipse . text . edits . InsertEdit ; import org . eclipse . text . edits . MultiTextEdit ; public final class ImportRewriteAnalyzer { private final ICompilationUnit compilationUnit ; private final ArrayList packageEntries ; private final List importsCreated ; private final List staticImportsCreated ; private final IRegion replaceRange ; private final int importOnDemandThreshold ; private final int staticImportOnDemandThreshold ; private boolean filterImplicitImports ; private boolean useContextToFilterImplicitImports ; private boolean findAmbiguousImports ; private int flags = <NUM_LIT:0> ; private static final int F_NEEDS_LEADING_DELIM = <NUM_LIT:2> ; private static final int F_NEEDS_TRAILING_DELIM = <NUM_LIT:4> ; private static final String JAVA_LANG = "<STR_LIT>" ; public ImportRewriteAnalyzer ( ICompilationUnit cu , CompilationUnit root , String [ ] importOrder , int threshold , int staticThreshold , boolean restoreExistingImports , boolean useContextToFilterImplicitImports ) { this . compilationUnit = cu ; this . importOnDemandThreshold = threshold ; this . staticImportOnDemandThreshold = staticThreshold ; this . useContextToFilterImplicitImports = useContextToFilterImplicitImports ; this . filterImplicitImports = true ; this . findAmbiguousImports = true ; this . packageEntries = new ArrayList ( <NUM_LIT:20> ) ; this . importsCreated = new ArrayList ( ) ; this . staticImportsCreated = new ArrayList ( ) ; this . flags = <NUM_LIT:0> ; this . replaceRange = evaluateReplaceRange ( root ) ; if ( restoreExistingImports ) { addExistingImports ( root ) ; } PackageEntry [ ] order = new PackageEntry [ importOrder . length ] ; for ( int i = <NUM_LIT:0> ; i < order . length ; i ++ ) { String curr = importOrder [ i ] ; if ( curr . length ( ) > <NUM_LIT:0> && curr . charAt ( <NUM_LIT:0> ) == '<CHAR_LIT>' ) { curr = curr . substring ( <NUM_LIT:1> ) ; order [ i ] = new PackageEntry ( curr , curr , true ) ; } else { order [ i ] = new PackageEntry ( curr , curr , false ) ; } } addPreferenceOrderHolders ( order ) ; } private int getSpacesBetweenImportGroups ( ) { try { int num = Integer . parseInt ( this . compilationUnit . getJavaProject ( ) . getOption ( DefaultCodeFormatterConstants . FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS , true ) ) ; if ( num >= <NUM_LIT:0> ) return num ; } catch ( NumberFormatException e ) { } return <NUM_LIT:1> ; } private boolean insertSpaceBeforeSemicolon ( ) { return JavaCore . INSERT . equals ( this . compilationUnit . getJavaProject ( ) . getOption ( DefaultCodeFormatterConstants . FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON , true ) ) ; } private void addPreferenceOrderHolders ( PackageEntry [ ] preferenceOrder ) { if ( this . packageEntries . isEmpty ( ) ) { for ( int i = <NUM_LIT:0> ; i < preferenceOrder . length ; i ++ ) { this . packageEntries . add ( preferenceOrder [ i ] ) ; } } else { PackageEntry [ ] lastAssigned = new PackageEntry [ preferenceOrder . length ] ; for ( int k = <NUM_LIT:0> ; k < this . packageEntries . size ( ) ; k ++ ) { PackageEntry entry = ( PackageEntry ) this . packageEntries . get ( k ) ; if ( ! entry . isComment ( ) ) { String currName = entry . getName ( ) ; int currNameLen = currName . length ( ) ; int bestGroupIndex = - <NUM_LIT:1> ; int bestGroupLen = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < preferenceOrder . length ; i ++ ) { boolean currPrevStatic = preferenceOrder [ i ] . isStatic ( ) ; if ( currPrevStatic == entry . isStatic ( ) ) { String currPrefEntry = preferenceOrder [ i ] . getName ( ) ; int currPrefLen = currPrefEntry . length ( ) ; if ( currName . startsWith ( currPrefEntry ) && currPrefLen >= bestGroupLen ) { if ( currPrefLen == currNameLen || currName . charAt ( currPrefLen ) == '<CHAR_LIT:.>' ) { if ( bestGroupIndex == - <NUM_LIT:1> || currPrefLen > bestGroupLen ) { bestGroupLen = currPrefLen ; bestGroupIndex = i ; } } } } } if ( bestGroupIndex != - <NUM_LIT:1> ) { entry . setGroupID ( preferenceOrder [ bestGroupIndex ] . getName ( ) ) ; lastAssigned [ bestGroupIndex ] = entry ; } } } int currAppendIndex = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < lastAssigned . length ; i ++ ) { PackageEntry entry = lastAssigned [ i ] ; if ( entry == null ) { PackageEntry newEntry = preferenceOrder [ i ] ; if ( currAppendIndex == <NUM_LIT:0> && ! newEntry . isStatic ( ) ) { currAppendIndex = getIndexAfterStatics ( ) ; } this . packageEntries . add ( currAppendIndex , newEntry ) ; currAppendIndex ++ ; } else { currAppendIndex = this . packageEntries . indexOf ( entry ) + <NUM_LIT:1> ; } } } } private String getQualifier ( ImportDeclaration decl ) { String name = decl . getName ( ) . getFullyQualifiedName ( ) ; if ( decl . isOnDemand ( ) ) { return name ; } return getQualifier ( name , decl . isStatic ( ) ) ; } private String getQualifier ( String name , boolean isStatic ) { if ( isStatic || ! this . useContextToFilterImplicitImports ) { return Signature . getQualifier ( name ) ; } char [ ] searchedName = name . toCharArray ( ) ; int index = name . length ( ) ; JavaProject project = ( JavaProject ) this . compilationUnit . getJavaProject ( ) ; do { String testedName = new String ( searchedName , <NUM_LIT:0> , index ) ; IJavaElement fragment = null ; try { fragment = project . findPackageFragment ( testedName ) ; } catch ( JavaModelException e ) { return name ; } if ( fragment != null ) { return testedName ; } try { fragment = project . findType ( testedName ) ; } catch ( JavaModelException e ) { return name ; } if ( fragment != null ) { index = CharOperation . lastIndexOf ( Signature . C_DOT , searchedName , <NUM_LIT:0> , index - <NUM_LIT:1> ) ; } else { index = CharOperation . lastIndexOf ( Signature . C_DOT , searchedName , <NUM_LIT:0> , index - <NUM_LIT:1> ) ; if ( Character . isLowerCase ( searchedName [ index + <NUM_LIT:1> ] ) ) { return testedName ; } } } while ( index >= <NUM_LIT:0> ) ; return name ; } private static String getFullName ( ImportDeclaration decl ) { String name = decl . getName ( ) . getFullyQualifiedName ( ) ; return decl . isOnDemand ( ) ? name + "<STR_LIT>" : name ; } private void addExistingImports ( CompilationUnit root ) { List decls = root . imports ( ) ; if ( decls . isEmpty ( ) ) { return ; } PackageEntry currPackage = null ; ImportDeclaration curr = ( ImportDeclaration ) decls . get ( <NUM_LIT:0> ) ; int currOffset = curr . getStartPosition ( ) ; int currLength = curr . getLength ( ) ; int currEndLine = root . getLineNumber ( currOffset + currLength ) ; for ( int i = <NUM_LIT:1> ; i < decls . size ( ) ; i ++ ) { boolean isStatic = curr . isStatic ( ) ; String name = getFullName ( curr ) ; String packName = getQualifier ( curr ) ; if ( currPackage == null || currPackage . compareTo ( packName , isStatic ) != <NUM_LIT:0> ) { currPackage = new PackageEntry ( packName , null , isStatic ) ; this . packageEntries . add ( currPackage ) ; } ImportDeclaration next = ( ImportDeclaration ) decls . get ( i ) ; int nextOffset = next . getStartPosition ( ) ; int nextLength = next . getLength ( ) ; int nextOffsetLine = root . getLineNumber ( nextOffset ) ; if ( currEndLine < nextOffsetLine ) { currEndLine ++ ; nextOffset = root . getPosition ( currEndLine , <NUM_LIT:0> ) ; } currPackage . add ( new ImportDeclEntry ( packName . length ( ) , name , isStatic , new Region ( currOffset , nextOffset - currOffset ) ) ) ; currOffset = nextOffset ; curr = next ; if ( currEndLine < nextOffsetLine ) { nextOffset = root . getPosition ( nextOffsetLine , <NUM_LIT:0> ) ; currPackage = new PackageEntry ( ) ; this . packageEntries . add ( currPackage ) ; currPackage . add ( new ImportDeclEntry ( packName . length ( ) , null , false , new Region ( currOffset , nextOffset - currOffset ) ) ) ; currOffset = nextOffset ; } currEndLine = root . getLineNumber ( nextOffset + nextLength ) ; } boolean isStatic = curr . isStatic ( ) ; String name = getFullName ( curr ) ; String packName = getQualifier ( curr ) ; if ( currPackage == null || currPackage . compareTo ( packName , isStatic ) != <NUM_LIT:0> ) { currPackage = new PackageEntry ( packName , null , isStatic ) ; this . packageEntries . add ( currPackage ) ; } int length = this . replaceRange . getOffset ( ) + this . replaceRange . getLength ( ) - curr . getStartPosition ( ) ; currPackage . add ( new ImportDeclEntry ( packName . length ( ) , name , isStatic , new Region ( curr . getStartPosition ( ) , length ) ) ) ; } public void setFilterImplicitImports ( boolean filterImplicitImports ) { this . filterImplicitImports = filterImplicitImports ; } public void setFindAmbiguousImports ( boolean findAmbiguousImports ) { this . findAmbiguousImports = findAmbiguousImports ; } private static class PackageMatcher { private String newName ; private String bestName ; private int bestMatchLen ; public PackageMatcher ( ) { } public void initialize ( String newImportName , String bestImportName ) { this . newName = newImportName ; this . bestName = bestImportName ; this . bestMatchLen = getCommonPrefixLength ( bestImportName , newImportName ) ; } public boolean isBetterMatch ( String currName , boolean preferCurr ) { boolean isBetter ; int currMatchLen = getCommonPrefixLength ( currName , this . newName ) ; int matchDiff = currMatchLen - this . bestMatchLen ; if ( matchDiff == <NUM_LIT:0> ) { if ( currMatchLen == this . newName . length ( ) && currMatchLen == currName . length ( ) && currMatchLen == this . bestName . length ( ) ) { isBetter = preferCurr ; } else { isBetter = sameMatchLenTest ( currName ) ; } } else { isBetter = ( matchDiff > <NUM_LIT:0> ) ; } if ( isBetter ) { this . bestName = currName ; this . bestMatchLen = currMatchLen ; } return isBetter ; } private boolean sameMatchLenTest ( String currName ) { int matchLen = this . bestMatchLen ; char newChar = getCharAt ( this . newName , matchLen ) ; char currChar = getCharAt ( currName , matchLen ) ; char bestChar = getCharAt ( this . bestName , matchLen ) ; if ( newChar < currChar ) { if ( bestChar < newChar ) { return ( currChar - newChar ) < ( newChar - bestChar ) ; } else { if ( currChar == bestChar ) { return false ; } else { return currChar < bestChar ; } } } else { if ( bestChar > newChar ) { return ( newChar - currChar ) < ( bestChar - newChar ) ; } else { if ( currChar == bestChar ) { return true ; } else { return currChar > bestChar ; } } } } } static int getCommonPrefixLength ( String s , String t ) { int len = Math . min ( s . length ( ) , t . length ( ) ) ; for ( int i = <NUM_LIT:0> ; i < len ; i ++ ) { if ( s . charAt ( i ) != t . charAt ( i ) ) { return i ; } } return len ; } static char getCharAt ( String str , int index ) { if ( str . length ( ) > index ) { return str . charAt ( index ) ; } return <NUM_LIT:0> ; } private PackageEntry findBestMatch ( String newName , boolean isStatic ) { if ( this . packageEntries . isEmpty ( ) ) { return null ; } String groupId = null ; int longestPrefix = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < this . packageEntries . size ( ) ; i ++ ) { PackageEntry curr = ( PackageEntry ) this . packageEntries . get ( i ) ; if ( isStatic == curr . isStatic ( ) ) { String currGroup = curr . getGroupID ( ) ; if ( currGroup != null && newName . startsWith ( currGroup ) ) { int prefixLen = currGroup . length ( ) ; if ( prefixLen == newName . length ( ) ) { return curr ; } if ( ( newName . charAt ( prefixLen ) == '<CHAR_LIT:.>' || prefixLen == <NUM_LIT:0> ) && prefixLen > longestPrefix ) { longestPrefix = prefixLen ; groupId = currGroup ; } } } } PackageEntry bestMatch = null ; PackageMatcher matcher = new PackageMatcher ( ) ; matcher . initialize ( newName , "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i < this . packageEntries . size ( ) ; i ++ ) { PackageEntry curr = ( PackageEntry ) this . packageEntries . get ( i ) ; if ( ! curr . isComment ( ) && curr . isStatic ( ) == isStatic ) { if ( groupId == null || groupId . equals ( curr . getGroupID ( ) ) ) { boolean preferrCurr = ( bestMatch == null ) || ( curr . getNumberOfImports ( ) > bestMatch . getNumberOfImports ( ) ) ; if ( matcher . isBetterMatch ( curr . getName ( ) , preferrCurr ) ) { bestMatch = curr ; } } } } return bestMatch ; } private boolean isImplicitImport ( String qualifier ) { if ( JAVA_LANG . equals ( qualifier ) ) { return true ; } ICompilationUnit cu = this . compilationUnit ; String packageName = cu . getParent ( ) . getElementName ( ) ; if ( qualifier . equals ( packageName ) ) { return true ; } String mainTypeName = JavaCore . removeJavaLikeExtension ( cu . getElementName ( ) ) ; if ( packageName . length ( ) == <NUM_LIT:0> ) { return qualifier . equals ( mainTypeName ) ; } return qualifier . equals ( packageName + '<CHAR_LIT:.>' + mainTypeName ) ; } public void addImport ( String fullTypeName , boolean isStatic ) { String typeContainerName = getQualifier ( fullTypeName , isStatic ) ; ImportDeclEntry decl = new ImportDeclEntry ( typeContainerName . length ( ) , fullTypeName , isStatic , null ) ; sortIn ( typeContainerName , decl , isStatic ) ; } public boolean removeImport ( String qualifiedName , boolean isStatic ) { String containerName = getQualifier ( qualifiedName , isStatic ) ; int nPackages = this . packageEntries . size ( ) ; for ( int i = <NUM_LIT:0> ; i < nPackages ; i ++ ) { PackageEntry entry = ( PackageEntry ) this . packageEntries . get ( i ) ; if ( entry . compareTo ( containerName , isStatic ) == <NUM_LIT:0> ) { if ( entry . remove ( qualifiedName , isStatic ) ) { return true ; } } } return false ; } private int getIndexAfterStatics ( ) { for ( int i = <NUM_LIT:0> ; i < this . packageEntries . size ( ) ; i ++ ) { if ( ! ( ( PackageEntry ) this . packageEntries . get ( i ) ) . isStatic ( ) ) { return i ; } } return this . packageEntries . size ( ) ; } private void sortIn ( String typeContainerName , ImportDeclEntry decl , boolean isStatic ) { PackageEntry bestMatch = findBestMatch ( typeContainerName , isStatic ) ; if ( bestMatch == null ) { PackageEntry packEntry = new PackageEntry ( typeContainerName , null , isStatic ) ; packEntry . add ( decl ) ; int insertPos = packEntry . isStatic ( ) ? <NUM_LIT:0> : getIndexAfterStatics ( ) ; this . packageEntries . add ( insertPos , packEntry ) ; } else { int cmp = typeContainerName . compareTo ( bestMatch . getName ( ) ) ; if ( cmp == <NUM_LIT:0> ) { bestMatch . sortIn ( decl ) ; } else { String group = bestMatch . getGroupID ( ) ; if ( group != null ) { if ( ! typeContainerName . startsWith ( group ) ) { group = null ; } } PackageEntry packEntry = new PackageEntry ( typeContainerName , group , isStatic ) ; packEntry . add ( decl ) ; int index = this . packageEntries . indexOf ( bestMatch ) ; if ( cmp < <NUM_LIT:0> ) { this . packageEntries . add ( index , packEntry ) ; } else { this . packageEntries . add ( index + <NUM_LIT:1> , packEntry ) ; } } } } private IRegion evaluateReplaceRange ( CompilationUnit root ) { List imports = root . imports ( ) ; if ( ! imports . isEmpty ( ) ) { ImportDeclaration first = ( ImportDeclaration ) imports . get ( <NUM_LIT:0> ) ; ImportDeclaration last = ( ImportDeclaration ) imports . get ( imports . size ( ) - <NUM_LIT:1> ) ; int startPos = first . getStartPosition ( ) ; int endPos = root . getExtendedStartPosition ( last ) + root . getExtendedLength ( last ) ; int endLine = root . getLineNumber ( endPos ) ; if ( endLine > <NUM_LIT:0> ) { int nextLinePos = root . getPosition ( endLine + <NUM_LIT:1> , <NUM_LIT:0> ) ; if ( nextLinePos >= <NUM_LIT:0> ) { int firstTypePos = getFirstTypeBeginPos ( root ) ; if ( firstTypePos != - <NUM_LIT:1> && firstTypePos < nextLinePos ) { endPos = firstTypePos ; } else { endPos = nextLinePos ; } } } return new Region ( startPos , endPos - startPos ) ; } else { int start = getPackageStatementEndPos ( root ) ; return new Region ( start , <NUM_LIT:0> ) ; } } public MultiTextEdit getResultingEdits ( IProgressMonitor monitor ) throws JavaModelException { if ( monitor == null ) { monitor = new NullProgressMonitor ( ) ; } try { int importsStart = this . replaceRange . getOffset ( ) ; int importsLen = this . replaceRange . getLength ( ) ; String lineDelim = this . compilationUnit . findRecommendedLineSeparator ( ) ; IBuffer buffer = this . compilationUnit . getBuffer ( ) ; int currPos = importsStart ; MultiTextEdit resEdit = new MultiTextEdit ( ) ; if ( ( this . flags & F_NEEDS_LEADING_DELIM ) != <NUM_LIT:0> ) { resEdit . addChild ( new InsertEdit ( currPos , lineDelim ) ) ; } PackageEntry lastPackage = null ; Set onDemandConflicts = null ; if ( this . findAmbiguousImports ) { onDemandConflicts = evaluateStarImportConflicts ( monitor ) ; } int spacesBetweenGroups = getSpacesBetweenImportGroups ( ) ; ArrayList stringsToInsert = new ArrayList ( ) ; int nPackageEntries = this . packageEntries . size ( ) ; for ( int i = <NUM_LIT:0> ; i < nPackageEntries ; i ++ ) { PackageEntry pack = ( PackageEntry ) this . packageEntries . get ( i ) ; if ( this . filterImplicitImports && ! pack . isStatic ( ) && isImplicitImport ( pack . getName ( ) ) ) { pack . filterImplicitImports ( this . useContextToFilterImplicitImports ) ; } int nImports = pack . getNumberOfImports ( ) ; if ( nImports == <NUM_LIT:0> ) { continue ; } if ( spacesBetweenGroups > <NUM_LIT:0> ) { if ( lastPackage != null && ! pack . isComment ( ) && ! pack . isSameGroup ( lastPackage ) ) { ImportDeclEntry last = lastPackage . getImportAt ( lastPackage . getNumberOfImports ( ) - <NUM_LIT:1> ) ; ImportDeclEntry first = pack . getImportAt ( <NUM_LIT:0> ) ; if ( ! lastPackage . isComment ( ) && ( last . isNew ( ) || first . isNew ( ) ) ) { for ( int k = spacesBetweenGroups ; k > <NUM_LIT:0> ; k -- ) { stringsToInsert . add ( lineDelim ) ; } } } } lastPackage = pack ; boolean isStatic = pack . isStatic ( ) ; int threshold = isStatic ? this . staticImportOnDemandThreshold : this . importOnDemandThreshold ; boolean doStarImport = pack . hasStarImport ( threshold , onDemandConflicts ) ; if ( doStarImport && ( pack . find ( "<STR_LIT:*>" ) == null ) ) { String [ ] imports = getNewImportStrings ( pack , isStatic , lineDelim ) ; for ( int j = <NUM_LIT:0> , max = imports . length ; j < max ; j ++ ) { stringsToInsert . add ( imports [ j ] ) ; } } for ( int k = <NUM_LIT:0> ; k < nImports ; k ++ ) { ImportDeclEntry currDecl = pack . getImportAt ( k ) ; IRegion region = currDecl . getSourceRange ( ) ; if ( region == null ) { if ( ! doStarImport || currDecl . isOnDemand ( ) || ( onDemandConflicts != null && onDemandConflicts . contains ( currDecl . getSimpleName ( ) ) ) ) { String str = getNewImportString ( currDecl . getElementName ( ) , isStatic , lineDelim ) ; stringsToInsert . add ( str ) ; } else if ( doStarImport && ! currDecl . isOnDemand ( ) ) { String simpleName = currDecl . getTypeQualifiedName ( ) ; if ( simpleName . indexOf ( '<CHAR_LIT:.>' ) != - <NUM_LIT:1> ) { String str = getNewImportString ( currDecl . getElementName ( ) , isStatic , lineDelim ) ; if ( stringsToInsert . indexOf ( str ) == - <NUM_LIT:1> ) { stringsToInsert . add ( str ) ; } } } } else if ( ! doStarImport || currDecl . isOnDemand ( ) || onDemandConflicts == null || onDemandConflicts . contains ( currDecl . getSimpleName ( ) ) ) { int offset = region . getOffset ( ) ; removeAndInsertNew ( buffer , currPos , offset , stringsToInsert , resEdit ) ; stringsToInsert . clear ( ) ; currPos = offset + region . getLength ( ) ; } else if ( doStarImport && ! currDecl . isOnDemand ( ) ) { String simpleName = currDecl . getTypeQualifiedName ( ) ; if ( simpleName . indexOf ( '<CHAR_LIT:.>' ) != - <NUM_LIT:1> ) { String str = getNewImportString ( currDecl . getElementName ( ) , isStatic , lineDelim ) ; if ( stringsToInsert . indexOf ( str ) == - <NUM_LIT:1> ) { stringsToInsert . add ( str ) ; } } } } } int end = importsStart + importsLen ; removeAndInsertNew ( buffer , currPos , end , stringsToInsert , resEdit ) ; if ( importsLen == <NUM_LIT:0> ) { if ( ! this . importsCreated . isEmpty ( ) || ! this . staticImportsCreated . isEmpty ( ) ) { if ( ( this . flags & F_NEEDS_TRAILING_DELIM ) != <NUM_LIT:0> ) { resEdit . addChild ( new InsertEdit ( currPos , lineDelim ) ) ; } } else { return new MultiTextEdit ( ) ; } } return resEdit ; } finally { monitor . done ( ) ; } } private void removeAndInsertNew ( IBuffer buffer , int contentOffset , int contentEnd , ArrayList stringsToInsert , MultiTextEdit resEdit ) { int pos = contentOffset ; for ( int i = <NUM_LIT:0> ; i < stringsToInsert . size ( ) ; i ++ ) { String curr = ( String ) stringsToInsert . get ( i ) ; int idx = findInBuffer ( buffer , curr , pos , contentEnd ) ; if ( idx != - <NUM_LIT:1> ) { if ( idx != pos ) { resEdit . addChild ( new DeleteEdit ( pos , idx - pos ) ) ; } pos = idx + curr . length ( ) ; } else { resEdit . addChild ( new InsertEdit ( pos , curr ) ) ; } } if ( pos < contentEnd ) { resEdit . addChild ( new DeleteEdit ( pos , contentEnd - pos ) ) ; } } private int findInBuffer ( IBuffer buffer , String str , int start , int end ) { int pos = start ; int len = str . length ( ) ; if ( pos + len > end || str . length ( ) == <NUM_LIT:0> ) { return - <NUM_LIT:1> ; } char first = str . charAt ( <NUM_LIT:0> ) ; int step = str . indexOf ( first , <NUM_LIT:1> ) ; if ( step == - <NUM_LIT:1> ) { step = len ; } while ( pos + len <= end ) { if ( buffer . getChar ( pos ) == first ) { int k = <NUM_LIT:1> ; while ( k < len && buffer . getChar ( pos + k ) == str . charAt ( k ) ) { k ++ ; } if ( k == len ) { return pos ; } if ( k < step ) { pos += k ; } else { pos += step ; } } else { pos ++ ; } } return - <NUM_LIT:1> ; } private Set evaluateStarImportConflicts ( IProgressMonitor monitor ) throws JavaModelException { final HashSet onDemandConflicts = new HashSet ( ) ; IJavaSearchScope scope = SearchEngine . createJavaSearchScope ( new IJavaElement [ ] { this . compilationUnit . getJavaProject ( ) } ) ; ArrayList starImportPackages = new ArrayList ( ) ; ArrayList simpleTypeNames = new ArrayList ( ) ; int nPackageEntries = this . packageEntries . size ( ) ; for ( int i = <NUM_LIT:0> ; i < nPackageEntries ; i ++ ) { PackageEntry pack = ( PackageEntry ) this . packageEntries . get ( i ) ; if ( ! pack . isStatic ( ) && pack . hasStarImport ( this . importOnDemandThreshold , null ) ) { starImportPackages . add ( pack . getName ( ) . toCharArray ( ) ) ; for ( int k = <NUM_LIT:0> ; k < pack . getNumberOfImports ( ) ; k ++ ) { ImportDeclEntry curr = pack . getImportAt ( k ) ; if ( ! curr . isOnDemand ( ) && ! curr . isComment ( ) ) { simpleTypeNames . add ( curr . getSimpleName ( ) . toCharArray ( ) ) ; } } } } if ( starImportPackages . isEmpty ( ) ) { return null ; } starImportPackages . add ( this . compilationUnit . getParent ( ) . getElementName ( ) . toCharArray ( ) ) ; starImportPackages . add ( JAVA_LANG . toCharArray ( ) ) ; char [ ] [ ] allPackages = ( char [ ] [ ] ) starImportPackages . toArray ( new char [ starImportPackages . size ( ) ] [ ] ) ; char [ ] [ ] allTypes = ( char [ ] [ ] ) simpleTypeNames . toArray ( new char [ simpleTypeNames . size ( ) ] [ ] ) ; TypeNameRequestor requestor = new TypeNameRequestor ( ) { HashMap foundTypes = new HashMap ( ) ; private String getTypeContainerName ( char [ ] packageName , char [ ] [ ] enclosingTypeNames ) { StringBuffer buf = new StringBuffer ( ) ; buf . append ( packageName ) ; for ( int i = <NUM_LIT:0> ; i < enclosingTypeNames . length ; i ++ ) { if ( buf . length ( ) > <NUM_LIT:0> ) buf . append ( '<CHAR_LIT:.>' ) ; buf . append ( enclosingTypeNames [ i ] ) ; } return buf . toString ( ) ; } public void acceptType ( int modifiers , char [ ] packageName , char [ ] simpleTypeName , char [ ] [ ] enclosingTypeNames , String path ) { String name = new String ( simpleTypeName ) ; String containerName = getTypeContainerName ( packageName , enclosingTypeNames ) ; String oldContainer = ( String ) this . foundTypes . put ( name , containerName ) ; if ( oldContainer != null && ! oldContainer . equals ( containerName ) ) { onDemandConflicts . add ( name ) ; } } } ; new SearchEngine ( ) . searchAllTypeNames ( allPackages , allTypes , scope , requestor , IJavaSearchConstants . WAIT_UNTIL_READY_TO_SEARCH , monitor ) ; return onDemandConflicts ; } private String getNewImportString ( String importName , boolean isStatic , String lineDelim ) { StringBuffer buf = new StringBuffer ( ) ; buf . append ( "<STR_LIT>" ) ; if ( isStatic ) { buf . append ( "<STR_LIT>" ) ; } buf . append ( importName ) ; if ( insertSpaceBeforeSemicolon ( ) ) buf . append ( '<CHAR_LIT:U+0020>' ) ; buf . append ( '<CHAR_LIT:;>' ) ; buf . append ( lineDelim ) ; if ( isStatic ) { this . staticImportsCreated . add ( importName ) ; } else { this . importsCreated . add ( importName ) ; } return buf . toString ( ) ; } private String [ ] getNewImportStrings ( PackageEntry packageEntry , boolean isStatic , String lineDelim ) { boolean isStarImportAdded = false ; List allImports = new ArrayList ( ) ; int nImports = packageEntry . getNumberOfImports ( ) ; for ( int i = <NUM_LIT:0> ; i < nImports ; i ++ ) { ImportDeclEntry curr = packageEntry . getImportAt ( i ) ; String simpleName = curr . getTypeQualifiedName ( ) ; if ( simpleName . indexOf ( '<CHAR_LIT:.>' ) != - <NUM_LIT:1> ) { allImports . add ( getNewImportString ( curr . getElementName ( ) , isStatic , lineDelim ) ) ; } else if ( ! isStarImportAdded ) { String starImportString = packageEntry . getName ( ) + "<STR_LIT>" ; allImports . add ( getNewImportString ( starImportString , isStatic , lineDelim ) ) ; isStarImportAdded = true ; } } return ( String [ ] ) allImports . toArray ( new String [ allImports . size ( ) ] ) ; } private static int getFirstTypeBeginPos ( CompilationUnit root ) { List types = root . types ( ) ; if ( ! types . isEmpty ( ) ) { return root . getExtendedStartPosition ( ( ( ASTNode ) types . get ( <NUM_LIT:0> ) ) ) ; } return - <NUM_LIT:1> ; } private int getPackageStatementEndPos ( CompilationUnit root ) { PackageDeclaration packDecl = root . getPackage ( ) ; if ( packDecl != null ) { int afterPackageStatementPos = - <NUM_LIT:1> ; int lineNumber = root . getLineNumber ( packDecl . getStartPosition ( ) + packDecl . getLength ( ) ) ; if ( lineNumber >= <NUM_LIT:0> ) { int lineAfterPackage = lineNumber + <NUM_LIT:1> ; afterPackageStatementPos = root . getPosition ( lineAfterPackage , <NUM_LIT:0> ) ; } if ( afterPackageStatementPos < <NUM_LIT:0> ) { this . flags |= F_NEEDS_LEADING_DELIM ; return packDecl . getStartPosition ( ) + packDecl . getLength ( ) ; } int firstTypePos = getFirstTypeBeginPos ( root ) ; if ( firstTypePos != - <NUM_LIT:1> && firstTypePos <= afterPackageStatementPos ) { this . flags |= F_NEEDS_TRAILING_DELIM ; if ( firstTypePos == afterPackageStatementPos ) { this . flags |= F_NEEDS_LEADING_DELIM ; } return firstTypePos ; } this . flags |= F_NEEDS_LEADING_DELIM ; return afterPackageStatementPos ; } this . flags |= F_NEEDS_TRAILING_DELIM ; return <NUM_LIT:0> ; } public String toString ( ) { int nPackages = this . packageEntries . size ( ) ; StringBuffer buf = new StringBuffer ( "<STR_LIT>" ) ; for ( int i = <NUM_LIT:0> ; i < nPackages ; i ++ ) { PackageEntry entry = ( PackageEntry ) this . packageEntries . get ( i ) ; if ( entry . isStatic ( ) ) { buf . append ( "<STR_LIT>" ) ; } buf . append ( entry . toString ( ) ) ; } return buf . toString ( ) ; } private static final class ImportDeclEntry { private String elementName ; private IRegion sourceRange ; private final boolean isStatic ; private int containerNameLength ; public ImportDeclEntry ( int containerNameLength , String elementName , boolean isStatic , IRegion sourceRange ) { this . elementName = elementName ; this . sourceRange = sourceRange ; this . isStatic = isStatic ; this . containerNameLength = containerNameLength ; } public String getElementName ( ) { return this . elementName ; } public int compareTo ( String fullName , boolean isStaticImport ) { int cmp = this . elementName . compareTo ( fullName ) ; if ( cmp == <NUM_LIT:0> ) { if ( this . isStatic == isStaticImport ) { return <NUM_LIT:0> ; } return this . isStatic ? - <NUM_LIT:1> : <NUM_LIT:1> ; } return cmp ; } public String getSimpleName ( ) { return Signature . getSimpleName ( this . elementName ) ; } public String getTypeQualifiedName ( ) { return this . elementName . substring ( this . containerNameLength + <NUM_LIT:1> ) ; } public boolean isOnDemand ( ) { return this . elementName != null && this . elementName . endsWith ( "<STR_LIT>" ) ; } public boolean isStatic ( ) { return this . isStatic ; } public boolean isNew ( ) { return this . sourceRange == null ; } public boolean isComment ( ) { return this . elementName == null ; } public IRegion getSourceRange ( ) { return this . sourceRange ; } } private final static class PackageEntry { private String name ; private ArrayList importEntries ; private String group ; private boolean isStatic ; public PackageEntry ( ) { this ( "<STR_LIT:!>" , null , false ) ; } public PackageEntry ( String name , String group , boolean isStatic ) { this . name = name ; this . importEntries = new ArrayList ( <NUM_LIT:5> ) ; this . group = group ; this . isStatic = isStatic ; } public boolean isStatic ( ) { return this . isStatic ; } public int compareTo ( String otherName , boolean isOtherStatic ) { int cmp = this . name . compareTo ( otherName ) ; if ( cmp == <NUM_LIT:0> ) { if ( this . isStatic == isOtherStatic ) { return <NUM_LIT:0> ; } return this . isStatic ? - <NUM_LIT:1> : <NUM_LIT:1> ; } return cmp ; } public void sortIn ( ImportDeclEntry imp ) { String fullImportName = imp . getElementName ( ) ; int insertPosition = - <NUM_LIT:1> ; int nInports = this . importEntries . size ( ) ; for ( int i = <NUM_LIT:0> ; i < nInports ; i ++ ) { ImportDeclEntry curr = getImportAt ( i ) ; if ( ! curr . isComment ( ) ) { int cmp = curr . compareTo ( fullImportName , imp . isStatic ( ) ) ; if ( cmp == <NUM_LIT:0> ) { return ; } else if ( cmp > <NUM_LIT:0> && insertPosition == - <NUM_LIT:1> ) { insertPosition = i ; } } } if ( insertPosition == - <NUM_LIT:1> ) { this . importEntries . add ( imp ) ; } else { this . importEntries . add ( insertPosition , imp ) ; } } public void add ( ImportDeclEntry imp ) { this . importEntries . add ( imp ) ; } public ImportDeclEntry find ( String simpleName ) { int nInports = this . importEntries . size ( ) ; for ( int i = <NUM_LIT:0> ; i < nInports ; i ++ ) { ImportDeclEntry curr = getImportAt ( i ) ; if ( ! curr . isComment ( ) ) { String currName = curr . getElementName ( ) ; if ( currName . endsWith ( simpleName ) ) { int dotPos = currName . length ( ) - simpleName . length ( ) - <NUM_LIT:1> ; if ( ( dotPos == - <NUM_LIT:1> ) || ( dotPos > <NUM_LIT:0> && currName . charAt ( dotPos ) == '<CHAR_LIT:.>' ) ) { return curr ; } } } } return null ; } public boolean remove ( String fullName , boolean isStaticImport ) { int nInports = this . importEntries . size ( ) ; for ( int i = <NUM_LIT:0> ; i < nInports ; i ++ ) { ImportDeclEntry curr = getImportAt ( i ) ; if ( ! curr . isComment ( ) && curr . compareTo ( fullName , isStaticImport ) == <NUM_LIT:0> ) { this . importEntries . remove ( i ) ; return true ; } } return false ; } public void filterImplicitImports ( boolean useContextToFilterImplicitImports ) { int nInports = this . importEntries . size ( ) ; for ( int i = nInports - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { ImportDeclEntry curr = getImportAt ( i ) ; if ( curr . isNew ( ) ) { if ( ! useContextToFilterImplicitImports ) { this . importEntries . remove ( i ) ; } else { String elementName = curr . getElementName ( ) ; int lastIndexOf = elementName . lastIndexOf ( '<CHAR_LIT:.>' ) ; boolean internalClassImport = lastIndexOf > getName ( ) . length ( ) ; if ( ! internalClassImport ) { this . importEntries . remove ( i ) ; } } } } } public ImportDeclEntry getImportAt ( int index ) { return ( ImportDeclEntry ) this . importEntries . get ( index ) ; } public boolean hasStarImport ( int threshold , Set explicitImports ) { if ( isComment ( ) || isDefaultPackage ( ) ) { return false ; } int nImports = getNumberOfImports ( ) ; int count = <NUM_LIT:0> ; boolean containsNew = false ; for ( int i = <NUM_LIT:0> ; i < nImports ; i ++ ) { ImportDeclEntry curr = getImportAt ( i ) ; if ( curr . isOnDemand ( ) ) { return true ; } if ( ! curr . isComment ( ) ) { count ++ ; boolean isExplicit = ! curr . isStatic ( ) && ( explicitImports != null ) && explicitImports . contains ( curr . getSimpleName ( ) ) ; containsNew |= curr . isNew ( ) && ! isExplicit ; } } return ( count >= threshold ) && containsNew ; } public int getNumberOfImports ( ) { return this . importEntries . size ( ) ; } public String getName ( ) { return this . name ; } public String getGroupID ( ) { return this . group ; } public void setGroupID ( String groupID ) { this . group = groupID ; } public boolean isSameGroup ( PackageEntry other ) { if ( this . group == null ) { return other . getGroupID ( ) == null ; } else { return this . group . equals ( other . getGroupID ( ) ) && ( this . isStatic == other . isStatic ( ) ) ; } } public boolean isComment ( ) { return "<STR_LIT:!>" . equals ( this . name ) ; } public boolean isDefaultPackage ( ) { return this . name . length ( ) == <NUM_LIT:0> ; } public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; if ( isComment ( ) ) { buf . append ( "<STR_LIT>" ) ; } else { buf . append ( this . name ) ; buf . append ( "<STR_LIT>" ) ; buf . append ( this . group ) ; buf . append ( "<STR_LIT:n>" ) ; int nImports = getNumberOfImports ( ) ; for ( int i = <NUM_LIT:0> ; i < nImports ; i ++ ) { ImportDeclEntry curr = getImportAt ( i ) ; buf . append ( "<STR_LIT:U+0020>" ) ; if ( curr . isStatic ( ) ) { buf . append ( "<STR_LIT>" ) ; } buf . append ( curr . getTypeQualifiedName ( ) ) ; if ( curr . isNew ( ) ) { buf . append ( "<STR_LIT>" ) ; } buf . append ( "<STR_LIT:n>" ) ; } } return buf . toString ( ) ; } } public String [ ] getCreatedImports ( ) { return ( String [ ] ) this . importsCreated . toArray ( new String [ this . importsCreated . size ( ) ] ) ; } public String [ ] getCreatedStaticImports ( ) { return ( String [ ] ) this . staticImportsCreated . toArray ( new String [ this . staticImportsCreated . size ( ) ] ) ; } } </s>
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import org . eclipse . jdt . core . dom . CompilationUnit ; import org . eclipse . jface . text . BadLocationException ; import org . eclipse . jface . text . IDocument ; public abstract class LineInformation { public static LineInformation create ( final IDocument doc ) { return new LineInformation ( ) { public int getLineOfOffset ( int offset ) { try { return doc . getLineOfOffset ( offset ) ; } catch ( BadLocationException e ) { return - <NUM_LIT:1> ; } } public int getLineOffset ( int line ) { try { return doc . getLineOffset ( line ) ; } catch ( BadLocationException e ) { return - <NUM_LIT:1> ; } } } ; } public static LineInformation create ( final CompilationUnit astRoot ) { return new LineInformation ( ) { public int getLineOfOffset ( int offset ) { return astRoot . getLineNumber ( offset ) - <NUM_LIT:1> ; } public int getLineOffset ( int line ) { return astRoot . getPosition ( line + <NUM_LIT:1> , <NUM_LIT:0> ) ; } } ; } public abstract int getLineOfOffset ( int offset ) ; public abstract int getLineOffset ( int line ) ; } </s>
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; public class NodeRewriteEvent extends RewriteEvent { private Object originalValue ; private Object newValue ; public NodeRewriteEvent ( Object originalValue , Object newValue ) { this . originalValue = originalValue ; this . newValue = newValue ; } public Object getNewValue ( ) { return this . newValue ; } public Object getOriginalValue ( ) { return this . originalValue ; } public int getChangeKind ( ) { if ( this . originalValue == this . newValue ) { return UNCHANGED ; } if ( this . originalValue == null ) { return INSERTED ; } if ( this . newValue == null ) { return REMOVED ; } if ( this . originalValue . equals ( this . newValue ) ) { return UNCHANGED ; } return REPLACED ; } public boolean isListRewrite ( ) { return false ; } public void setNewValue ( Object newValue ) { this . newValue = newValue ; } public RewriteEvent [ ] getChildren ( ) { return null ; } public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; switch ( getChangeKind ( ) ) { case INSERTED : buf . append ( "<STR_LIT>" ) ; buf . append ( getNewValue ( ) ) ; buf . append ( '<CHAR_LIT:]>' ) ; break ; case REPLACED : buf . append ( "<STR_LIT>" ) ; buf . append ( getOriginalValue ( ) ) ; buf . append ( "<STR_LIT>" ) ; buf . append ( getNewValue ( ) ) ; buf . append ( '<CHAR_LIT:]>' ) ; break ; case REMOVED : buf . append ( "<STR_LIT>" ) ; buf . append ( getOriginalValue ( ) ) ; buf . append ( '<CHAR_LIT:]>' ) ; break ; default : buf . append ( "<STR_LIT>" ) ; } return buf . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . ArrayList ; import java . util . IdentityHashMap ; import java . util . Iterator ; import java . util . List ; import java . util . Map ; import java . util . Stack ; import org . eclipse . core . runtime . Assert ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . jdt . core . dom . * ; import org . eclipse . jdt . core . dom . rewrite . TargetSourceRangeComputer ; import org . eclipse . jdt . core . dom . rewrite . TargetSourceRangeComputer . SourceRange ; import org . eclipse . jdt . core . formatter . DefaultCodeFormatterConstants ; import org . eclipse . jdt . core . formatter . IndentManipulation ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . parser . RecoveryScanner ; import org . eclipse . jdt . internal . compiler . parser . RecoveryScannerData ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; import org . eclipse . jdt . internal . compiler . util . Util ; import org . eclipse . jdt . internal . core . dom . rewrite . ASTRewriteFormatter . BlockContext ; import org . eclipse . jdt . internal . core . dom . rewrite . ASTRewriteFormatter . NodeMarker ; import org . eclipse . jdt . internal . core . dom . rewrite . ASTRewriteFormatter . Prefix ; import org . eclipse . jdt . internal . core . dom . rewrite . NodeInfoStore . CopyPlaceholderData ; import org . eclipse . jdt . internal . core . dom . rewrite . NodeInfoStore . StringPlaceholderData ; import org . eclipse . jdt . internal . core . dom . rewrite . RewriteEventStore . CopySourceInfo ; import org . eclipse . text . edits . CopySourceEdit ; import org . eclipse . text . edits . CopyTargetEdit ; import org . eclipse . text . edits . DeleteEdit ; import org . eclipse . text . edits . InsertEdit ; import org . eclipse . text . edits . MoveSourceEdit ; import org . eclipse . text . edits . MoveTargetEdit ; import org . eclipse . text . edits . RangeMarker ; import org . eclipse . text . edits . ReplaceEdit ; import org . eclipse . text . edits . TextEdit ; import org . eclipse . text . edits . TextEditGroup ; public final class ASTRewriteAnalyzer extends ASTVisitor { static final int JLS2_INTERNAL = AST . JLS2 ; TextEdit currentEdit ; final RewriteEventStore eventStore ; private TokenScanner tokenScanner ; private final Map sourceCopyInfoToEdit ; private final Stack sourceCopyEndNodes ; private final char [ ] content ; private final LineInformation lineInfo ; private final ASTRewriteFormatter formatter ; private final NodeInfoStore nodeInfos ; private final TargetSourceRangeComputer extendedSourceRangeComputer ; private final LineCommentEndOffsets lineCommentEndOffsets ; private int beforeRequiredSpaceIndex = - <NUM_LIT:1> ; Map options ; private RecoveryScannerData recoveryScannerData ; public ASTRewriteAnalyzer ( char [ ] content , LineInformation lineInfo , String lineDelim , TextEdit rootEdit , RewriteEventStore eventStore , NodeInfoStore nodeInfos , List comments , Map options , TargetSourceRangeComputer extendedSourceRangeComputer , RecoveryScannerData recoveryScannerData ) { this . eventStore = eventStore ; this . content = content ; this . lineInfo = lineInfo ; this . nodeInfos = nodeInfos ; this . tokenScanner = null ; this . currentEdit = rootEdit ; this . sourceCopyInfoToEdit = new IdentityHashMap ( ) ; this . sourceCopyEndNodes = new Stack ( ) ; this . formatter = new ASTRewriteFormatter ( nodeInfos , eventStore , options , lineDelim ) ; this . extendedSourceRangeComputer = extendedSourceRangeComputer ; this . lineCommentEndOffsets = new LineCommentEndOffsets ( comments ) ; this . options = options ; this . recoveryScannerData = recoveryScannerData ; } final TokenScanner getScanner ( ) { if ( this . tokenScanner == null ) { CompilerOptions compilerOptions = new CompilerOptions ( this . options ) ; Scanner scanner ; if ( this . recoveryScannerData == null ) { scanner = new Scanner ( true , false , false , compilerOptions . sourceLevel , compilerOptions . complianceLevel , null , null , true ) ; } else { scanner = new RecoveryScanner ( false , false , compilerOptions . sourceLevel , compilerOptions . complianceLevel , null , null , true , this . recoveryScannerData ) ; } scanner . setSource ( this . content ) ; this . tokenScanner = new TokenScanner ( scanner ) ; } return this . tokenScanner ; } final char [ ] getContent ( ) { return this . content ; } final LineInformation getLineInformation ( ) { return this . lineInfo ; } final SourceRange getExtendedRange ( ASTNode node ) { if ( this . eventStore . isRangeCopyPlaceholder ( node ) ) { return new SourceRange ( node . getStartPosition ( ) , node . getLength ( ) ) ; } return this . extendedSourceRangeComputer . computeSourceRange ( node ) ; } final int getExtendedOffset ( ASTNode node ) { return getExtendedRange ( node ) . getStartPosition ( ) ; } final int getExtendedEnd ( ASTNode node ) { TargetSourceRangeComputer . SourceRange range = getExtendedRange ( node ) ; return range . getStartPosition ( ) + range . getLength ( ) ; } final TextEdit getCopySourceEdit ( CopySourceInfo info ) { TextEdit edit = ( TextEdit ) this . sourceCopyInfoToEdit . get ( info ) ; if ( edit == null ) { SourceRange range = getExtendedRange ( info . getNode ( ) ) ; int start = range . getStartPosition ( ) ; int end = start + range . getLength ( ) ; if ( info . isMove ) { MoveSourceEdit moveSourceEdit = new MoveSourceEdit ( start , end - start ) ; moveSourceEdit . setTargetEdit ( new MoveTargetEdit ( <NUM_LIT:0> ) ) ; edit = moveSourceEdit ; } else { CopySourceEdit copySourceEdit = new CopySourceEdit ( start , end - start ) ; copySourceEdit . setTargetEdit ( new CopyTargetEdit ( <NUM_LIT:0> ) ) ; edit = copySourceEdit ; } this . sourceCopyInfoToEdit . put ( info , edit ) ; } return edit ; } private final int getChangeKind ( ASTNode node , StructuralPropertyDescriptor property ) { RewriteEvent event = getEvent ( node , property ) ; if ( event != null ) { return event . getChangeKind ( ) ; } return RewriteEvent . UNCHANGED ; } private final boolean hasChildrenChanges ( ASTNode node ) { return this . eventStore . hasChangedProperties ( node ) ; } private final boolean isChanged ( ASTNode node , StructuralPropertyDescriptor property ) { RewriteEvent event = getEvent ( node , property ) ; if ( event != null ) { return event . getChangeKind ( ) != RewriteEvent . UNCHANGED ; } return false ; } private final boolean isCollapsed ( ASTNode node ) { return this . nodeInfos . isCollapsed ( node ) ; } final boolean isInsertBoundToPrevious ( ASTNode node ) { return this . eventStore . isInsertBoundToPrevious ( node ) ; } private final TextEditGroup getEditGroup ( ASTNode parent , StructuralPropertyDescriptor property ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null ) { return getEditGroup ( event ) ; } return null ; } final RewriteEvent getEvent ( ASTNode parent , StructuralPropertyDescriptor property ) { return this . eventStore . getEvent ( parent , property ) ; } final TextEditGroup getEditGroup ( RewriteEvent change ) { return this . eventStore . getEventEditGroup ( change ) ; } private final Object getOriginalValue ( ASTNode parent , StructuralPropertyDescriptor property ) { return this . eventStore . getOriginalValue ( parent , property ) ; } private final Object getNewValue ( ASTNode parent , StructuralPropertyDescriptor property ) { return this . eventStore . getNewValue ( parent , property ) ; } final void addEdit ( TextEdit edit ) { this . currentEdit . addChild ( edit ) ; } final String getLineDelimiter ( ) { return this . formatter . getLineDelimiter ( ) ; } final String createIndentString ( int indent ) { return this . formatter . createIndentString ( indent ) ; } final private String getIndentOfLine ( int pos ) { int line = getLineInformation ( ) . getLineOfOffset ( pos ) ; if ( line >= <NUM_LIT:0> ) { char [ ] cont = getContent ( ) ; int lineStart = getLineInformation ( ) . getLineOffset ( line ) ; int i = lineStart ; while ( i < cont . length && IndentManipulation . isIndentChar ( this . content [ i ] ) ) { i ++ ; } return new String ( cont , lineStart , i - lineStart ) ; } return Util . EMPTY_STRING ; } final String getIndentAtOffset ( int pos ) { return this . formatter . getIndentString ( getIndentOfLine ( pos ) ) ; } final void doTextInsert ( int offset , String insertString , TextEditGroup editGroup ) { if ( insertString . length ( ) > <NUM_LIT:0> ) { if ( this . lineCommentEndOffsets . isEndOfLineComment ( offset , this . content ) ) { if ( ! insertString . startsWith ( getLineDelimiter ( ) ) ) { TextEdit edit = new InsertEdit ( offset , getLineDelimiter ( ) ) ; addEdit ( edit ) ; if ( editGroup != null ) { addEditGroup ( editGroup , edit ) ; } } this . lineCommentEndOffsets . remove ( offset ) ; } TextEdit edit = new InsertEdit ( offset , insertString ) ; addEdit ( edit ) ; if ( editGroup != null ) { addEditGroup ( editGroup , edit ) ; } } } final void addEditGroup ( TextEditGroup editGroup , TextEdit edit ) { editGroup . addTextEdit ( edit ) ; } final TextEdit doTextRemove ( int offset , int len , TextEditGroup editGroup ) { if ( len == <NUM_LIT:0> ) { return null ; } TextEdit edit = new DeleteEdit ( offset , len ) ; addEdit ( edit ) ; if ( editGroup != null ) { addEditGroup ( editGroup , edit ) ; } return edit ; } final void doTextRemoveAndVisit ( int offset , int len , ASTNode node , TextEditGroup editGroup ) { TextEdit edit = doTextRemove ( offset , len , editGroup ) ; if ( edit != null ) { this . currentEdit = edit ; voidVisit ( node ) ; this . currentEdit = edit . getParent ( ) ; } else { voidVisit ( node ) ; } } final int doVisit ( ASTNode node ) { node . accept ( this ) ; return getExtendedEnd ( node ) ; } private final int doVisit ( ASTNode parent , StructuralPropertyDescriptor property , int offset ) { Object node = getOriginalValue ( parent , property ) ; if ( property . isChildProperty ( ) && node != null ) { return doVisit ( ( ASTNode ) node ) ; } else if ( property . isChildListProperty ( ) ) { return doVisitList ( ( List ) node , offset ) ; } return offset ; } private int doVisitList ( List list , int offset ) { int endPos = offset ; for ( Iterator iter = list . iterator ( ) ; iter . hasNext ( ) ; ) { ASTNode curr = ( ( ASTNode ) iter . next ( ) ) ; endPos = doVisit ( curr ) ; } return endPos ; } final void voidVisit ( ASTNode node ) { node . accept ( this ) ; } private final void voidVisit ( ASTNode parent , StructuralPropertyDescriptor property ) { Object node = getOriginalValue ( parent , property ) ; if ( property . isChildProperty ( ) && node != null ) { voidVisit ( ( ASTNode ) node ) ; } else if ( property . isChildListProperty ( ) ) { voidVisitList ( ( List ) node ) ; } } private void voidVisitList ( List list ) { for ( Iterator iter = list . iterator ( ) ; iter . hasNext ( ) ; ) { doVisit ( ( ( ASTNode ) iter . next ( ) ) ) ; } } private final boolean doVisitUnchangedChildren ( ASTNode parent ) { List properties = parent . structuralPropertiesForType ( ) ; for ( int i = <NUM_LIT:0> ; i < properties . size ( ) ; i ++ ) { voidVisit ( parent , ( StructuralPropertyDescriptor ) properties . get ( i ) ) ; } return false ; } private final void doTextReplace ( int offset , int len , String insertString , TextEditGroup editGroup ) { if ( len > <NUM_LIT:0> || insertString . length ( ) > <NUM_LIT:0> ) { TextEdit edit = new ReplaceEdit ( offset , len , insertString ) ; addEdit ( edit ) ; if ( editGroup != null ) { addEditGroup ( editGroup , edit ) ; } } } private final TextEdit doTextCopy ( TextEdit sourceEdit , int destOffset , int sourceIndentLevel , String destIndentString , TextEditGroup editGroup ) { TextEdit targetEdit ; SourceModifier modifier = new SourceModifier ( sourceIndentLevel , destIndentString , this . formatter . getTabWidth ( ) , this . formatter . getIndentWidth ( ) ) ; if ( sourceEdit instanceof MoveSourceEdit ) { MoveSourceEdit moveEdit = ( MoveSourceEdit ) sourceEdit ; moveEdit . setSourceModifier ( modifier ) ; targetEdit = new MoveTargetEdit ( destOffset , moveEdit ) ; addEdit ( targetEdit ) ; } else { CopySourceEdit copyEdit = ( CopySourceEdit ) sourceEdit ; copyEdit . setSourceModifier ( modifier ) ; targetEdit = new CopyTargetEdit ( destOffset , copyEdit ) ; addEdit ( targetEdit ) ; } if ( editGroup != null ) { addEditGroup ( editGroup , sourceEdit ) ; addEditGroup ( editGroup , targetEdit ) ; } return targetEdit ; } private void changeNotSupported ( ASTNode node ) { Assert . isTrue ( false , "<STR_LIT>" + node . getClass ( ) . getName ( ) ) ; } class ListRewriter { protected String contantSeparator ; protected int startPos ; protected RewriteEvent [ ] list ; protected final ASTNode getOriginalNode ( int index ) { return ( ASTNode ) this . list [ index ] . getOriginalValue ( ) ; } protected final ASTNode getNewNode ( int index ) { return ( ASTNode ) this . list [ index ] . getNewValue ( ) ; } protected String getSeparatorString ( int nodeIndex ) { return this . contantSeparator ; } protected int getInitialIndent ( ) { return getIndent ( this . startPos ) ; } protected int getNodeIndent ( int nodeIndex ) { ASTNode node = getOriginalNode ( nodeIndex ) ; if ( node == null ) { for ( int i = nodeIndex - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { ASTNode curr = getOriginalNode ( i ) ; if ( curr != null ) { return getIndent ( curr . getStartPosition ( ) ) ; } } return getInitialIndent ( ) ; } return getIndent ( node . getStartPosition ( ) ) ; } protected int getStartOfNextNode ( int nextIndex , int defaultPos ) { for ( int i = nextIndex ; i < this . list . length ; i ++ ) { RewriteEvent elem = this . list [ i ] ; if ( elem . getChangeKind ( ) != RewriteEvent . INSERTED ) { ASTNode node = ( ASTNode ) elem . getOriginalValue ( ) ; return getExtendedOffset ( node ) ; } } return defaultPos ; } protected int getEndOfNode ( ASTNode node ) { return getExtendedEnd ( node ) ; } public final int rewriteList ( ASTNode parent , StructuralPropertyDescriptor property , int offset , String keyword , String separator ) { this . contantSeparator = separator ; return rewriteList ( parent , property , offset , keyword ) ; } private boolean insertAfterSeparator ( ASTNode node ) { return ! isInsertBoundToPrevious ( node ) ; } protected boolean mustRemoveSeparator ( int originalOffset , int nodeIndex ) { return true ; } public final int rewriteList ( ASTNode parent , StructuralPropertyDescriptor property , int offset , String keyword ) { this . startPos = offset ; this . list = getEvent ( parent , property ) . getChildren ( ) ; int total = this . list . length ; if ( total == <NUM_LIT:0> ) { return this . startPos ; } int currPos = - <NUM_LIT:1> ; int lastNonInsert = - <NUM_LIT:1> ; int lastNonDelete = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < total ; i ++ ) { int currMark = this . list [ i ] . getChangeKind ( ) ; if ( currMark != RewriteEvent . INSERTED ) { lastNonInsert = i ; if ( currPos == - <NUM_LIT:1> ) { ASTNode elem = ( ASTNode ) this . list [ i ] . getOriginalValue ( ) ; currPos = getExtendedOffset ( elem ) ; } } if ( currMark != RewriteEvent . REMOVED ) { lastNonDelete = i ; } } if ( currPos == - <NUM_LIT:1> ) { if ( keyword . length ( ) > <NUM_LIT:0> ) { TextEditGroup editGroup = getEditGroup ( this . list [ <NUM_LIT:0> ] ) ; doTextInsert ( offset , keyword , editGroup ) ; } currPos = offset ; } if ( lastNonDelete == - <NUM_LIT:1> ) { currPos = offset ; } int prevEnd = currPos ; int prevMark = RewriteEvent . UNCHANGED ; final int NONE = <NUM_LIT:0> , NEW = <NUM_LIT:1> , EXISTING = <NUM_LIT:2> ; int separatorState = NEW ; for ( int i = <NUM_LIT:0> ; i < total ; i ++ ) { RewriteEvent currEvent = this . list [ i ] ; int currMark = currEvent . getChangeKind ( ) ; int nextIndex = i + <NUM_LIT:1> ; if ( currMark == RewriteEvent . INSERTED ) { TextEditGroup editGroup = getEditGroup ( currEvent ) ; ASTNode node = ( ASTNode ) currEvent . getNewValue ( ) ; if ( separatorState == NONE ) { doTextInsert ( currPos , getSeparatorString ( i - <NUM_LIT:1> ) , editGroup ) ; separatorState = NEW ; } if ( separatorState == NEW || insertAfterSeparator ( node ) ) { if ( separatorState == EXISTING ) { updateIndent ( prevMark , currPos , i , editGroup ) ; } doTextInsert ( currPos , node , getNodeIndent ( i ) , true , editGroup ) ; separatorState = NEW ; if ( i != lastNonDelete ) { if ( this . list [ nextIndex ] . getChangeKind ( ) != RewriteEvent . INSERTED ) { doTextInsert ( currPos , getSeparatorString ( i ) , editGroup ) ; } else { separatorState = NONE ; } } } else { doTextInsert ( prevEnd , getSeparatorString ( i - <NUM_LIT:1> ) , editGroup ) ; doTextInsert ( prevEnd , node , getNodeIndent ( i ) , true , editGroup ) ; } } else if ( currMark == RewriteEvent . REMOVED ) { ASTNode node = ( ASTNode ) currEvent . getOriginalValue ( ) ; TextEditGroup editGroup = getEditGroup ( currEvent ) ; int currEnd = getEndOfNode ( node ) ; if ( i > lastNonDelete && separatorState == EXISTING ) { doTextRemove ( prevEnd , currPos - prevEnd , editGroup ) ; doTextRemoveAndVisit ( currPos , currEnd - currPos , node , editGroup ) ; currPos = currEnd ; prevEnd = currEnd ; } else { if ( i < lastNonDelete ) { updateIndent ( prevMark , currPos , i , editGroup ) ; } int end = getStartOfNextNode ( nextIndex , currEnd ) ; doTextRemoveAndVisit ( currPos , currEnd - currPos , node , getEditGroup ( currEvent ) ) ; if ( mustRemoveSeparator ( currPos , i ) ) { doTextRemove ( currEnd , end - currEnd , editGroup ) ; } currPos = end ; prevEnd = currEnd ; separatorState = NEW ; } } else { if ( currMark == RewriteEvent . REPLACED ) { ASTNode node = ( ASTNode ) currEvent . getOriginalValue ( ) ; int currEnd = getEndOfNode ( node ) ; TextEditGroup editGroup = getEditGroup ( currEvent ) ; ASTNode changed = ( ASTNode ) currEvent . getNewValue ( ) ; updateIndent ( prevMark , currPos , i , editGroup ) ; doTextRemoveAndVisit ( currPos , currEnd - currPos , node , editGroup ) ; doTextInsert ( currPos , changed , getNodeIndent ( i ) , true , editGroup ) ; prevEnd = currEnd ; } else { ASTNode node = ( ASTNode ) currEvent . getOriginalValue ( ) ; voidVisit ( node ) ; } if ( i == lastNonInsert ) { separatorState = NONE ; if ( currMark == RewriteEvent . UNCHANGED ) { ASTNode node = ( ASTNode ) currEvent . getOriginalValue ( ) ; prevEnd = getEndOfNode ( node ) ; } currPos = prevEnd ; } else if ( this . list [ nextIndex ] . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { if ( currMark == RewriteEvent . UNCHANGED ) { ASTNode node = ( ASTNode ) currEvent . getOriginalValue ( ) ; prevEnd = getEndOfNode ( node ) ; } currPos = getStartOfNextNode ( nextIndex , prevEnd ) ; separatorState = EXISTING ; } } prevMark = currMark ; } return currPos ; } protected void updateIndent ( int prevMark , int originalOffset , int nodeIndex , TextEditGroup editGroup ) { } } private int rewriteRequiredNode ( ASTNode parent , StructuralPropertyDescriptor property ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null && event . getChangeKind ( ) == RewriteEvent . REPLACED ) { ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; SourceRange range = getExtendedRange ( node ) ; int offset = range . getStartPosition ( ) ; int length = range . getLength ( ) ; doTextRemoveAndVisit ( offset , length , node , editGroup ) ; doTextInsert ( offset , ( ASTNode ) event . getNewValue ( ) , getIndent ( offset ) , true , editGroup ) ; return offset + length ; } return doVisit ( parent , property , <NUM_LIT:0> ) ; } private int rewriteNode ( ASTNode parent , StructuralPropertyDescriptor property , int offset , Prefix prefix ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null ) { switch ( event . getChangeKind ( ) ) { case RewriteEvent . INSERTED : { ASTNode node = ( ASTNode ) event . getNewValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; int indent = getIndent ( offset ) ; doTextInsert ( offset , prefix . getPrefix ( indent ) , editGroup ) ; doTextInsert ( offset , node , indent , true , editGroup ) ; return offset ; } case RewriteEvent . REMOVED : { ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; int nodeEnd ; int len ; if ( offset == <NUM_LIT:0> ) { SourceRange range = getExtendedRange ( node ) ; offset = range . getStartPosition ( ) ; len = range . getLength ( ) ; nodeEnd = offset + len ; } else { nodeEnd = getExtendedEnd ( node ) ; len = nodeEnd - offset ; } doTextRemoveAndVisit ( offset , len , node , editGroup ) ; return nodeEnd ; } case RewriteEvent . REPLACED : { ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; SourceRange range = getExtendedRange ( node ) ; int nodeOffset = range . getStartPosition ( ) ; int nodeLen = range . getLength ( ) ; doTextRemoveAndVisit ( nodeOffset , nodeLen , node , editGroup ) ; doTextInsert ( nodeOffset , ( ASTNode ) event . getNewValue ( ) , getIndent ( offset ) , true , editGroup ) ; return nodeOffset + nodeLen ; } } } return doVisit ( parent , property , offset ) ; } private int rewriteJavadoc ( ASTNode node , StructuralPropertyDescriptor property ) { int pos = rewriteNode ( node , property , node . getStartPosition ( ) , ASTRewriteFormatter . NONE ) ; int changeKind = getChangeKind ( node , property ) ; if ( changeKind == RewriteEvent . INSERTED ) { String indent = getLineDelimiter ( ) + getIndentAtOffset ( pos ) ; doTextInsert ( pos , indent , getEditGroup ( node , property ) ) ; } else if ( changeKind == RewriteEvent . REMOVED ) { try { getScanner ( ) . readNext ( pos , false ) ; doTextRemove ( pos , getScanner ( ) . getCurrentStartOffset ( ) - pos , getEditGroup ( node , property ) ) ; pos = getScanner ( ) . getCurrentStartOffset ( ) ; } catch ( CoreException e ) { handleException ( e ) ; } } return pos ; } private int rewriteBodyNode ( ASTNode parent , StructuralPropertyDescriptor property , int offset , int endPos , int indent , BlockContext context ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null ) { switch ( event . getChangeKind ( ) ) { case RewriteEvent . INSERTED : { ASTNode node = ( ASTNode ) event . getNewValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; String [ ] strings = context . getPrefixAndSuffix ( indent , node , this . eventStore ) ; doTextInsert ( offset , strings [ <NUM_LIT:0> ] , editGroup ) ; doTextInsert ( offset , node , indent , true , editGroup ) ; doTextInsert ( offset , strings [ <NUM_LIT:1> ] , editGroup ) ; return offset ; } case RewriteEvent . REMOVED : { ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; if ( endPos == - <NUM_LIT:1> ) { endPos = getExtendedEnd ( node ) ; } TextEditGroup editGroup = getEditGroup ( event ) ; int len = endPos - offset ; doTextRemoveAndVisit ( offset , len , node , editGroup ) ; return endPos ; } case RewriteEvent . REPLACED : { ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; boolean insertNewLine = false ; if ( endPos == - <NUM_LIT:1> ) { int previousEnd = node . getStartPosition ( ) + node . getLength ( ) ; endPos = getExtendedEnd ( node ) ; if ( endPos != previousEnd ) { int token = TokenScanner . END_OF_FILE ; try { token = getScanner ( ) . readNext ( previousEnd , false ) ; } catch ( CoreException e ) { } if ( token == TerminalTokens . TokenNameCOMMENT_LINE ) { insertNewLine = true ; } } } TextEditGroup editGroup = getEditGroup ( event ) ; int nodeLen = endPos - offset ; ASTNode replacingNode = ( ASTNode ) event . getNewValue ( ) ; String [ ] strings = context . getPrefixAndSuffix ( indent , replacingNode , this . eventStore ) ; doTextRemoveAndVisit ( offset , nodeLen , node , editGroup ) ; String prefix = strings [ <NUM_LIT:0> ] ; String insertedPrefix = prefix ; if ( insertNewLine ) { insertedPrefix = getLineDelimiter ( ) + this . formatter . createIndentString ( indent ) + insertedPrefix . trim ( ) + '<CHAR_LIT:U+0020>' ; } doTextInsert ( offset , insertedPrefix , editGroup ) ; String lineInPrefix = getCurrentLine ( prefix , prefix . length ( ) ) ; if ( prefix . length ( ) != lineInPrefix . length ( ) ) { indent = this . formatter . computeIndentUnits ( lineInPrefix ) ; } doTextInsert ( offset , replacingNode , indent , true , editGroup ) ; doTextInsert ( offset , strings [ <NUM_LIT:1> ] , editGroup ) ; return endPos ; } } } int pos = doVisit ( parent , property , offset ) ; if ( endPos != - <NUM_LIT:1> ) { return endPos ; } return pos ; } private int rewriteOptionalQualifier ( ASTNode parent , StructuralPropertyDescriptor property , int startPos ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null ) { switch ( event . getChangeKind ( ) ) { case RewriteEvent . INSERTED : { ASTNode node = ( ASTNode ) event . getNewValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; doTextInsert ( startPos , node , getIndent ( startPos ) , true , editGroup ) ; doTextInsert ( startPos , "<STR_LIT:.>" , editGroup ) ; return startPos ; } case RewriteEvent . REMOVED : { try { ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; int dotEnd = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameDOT , node . getStartPosition ( ) + node . getLength ( ) ) ; doTextRemoveAndVisit ( startPos , dotEnd - startPos , node , editGroup ) ; return dotEnd ; } catch ( CoreException e ) { handleException ( e ) ; } break ; } case RewriteEvent . REPLACED : { ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; SourceRange range = getExtendedRange ( node ) ; int offset = range . getStartPosition ( ) ; int length = range . getLength ( ) ; doTextRemoveAndVisit ( offset , length , node , editGroup ) ; doTextInsert ( offset , ( ASTNode ) event . getNewValue ( ) , getIndent ( startPos ) , true , editGroup ) ; try { return getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameDOT , offset + length ) ; } catch ( CoreException e ) { handleException ( e ) ; } break ; } } } Object node = getOriginalValue ( parent , property ) ; if ( node == null ) { return startPos ; } int pos = doVisit ( ( ASTNode ) node ) ; try { return getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameDOT , pos ) ; } catch ( CoreException e ) { handleException ( e ) ; } return pos ; } class ParagraphListRewriter extends ListRewriter { public final static int DEFAULT_SPACING = <NUM_LIT:1> ; private int initialIndent ; private int separatorLines ; public ParagraphListRewriter ( int initialIndent , int separator ) { this . initialIndent = initialIndent ; this . separatorLines = separator ; } protected int getInitialIndent ( ) { return this . initialIndent ; } protected String getSeparatorString ( int nodeIndex ) { return getSeparatorString ( nodeIndex , nodeIndex + <NUM_LIT:1> ) ; } protected String getSeparatorString ( int nodeIndex , int nextNodeIndex ) { int newLines = this . separatorLines == - <NUM_LIT:1> ? getNewLines ( nodeIndex ) : this . separatorLines ; String lineDelim = getLineDelimiter ( ) ; StringBuffer buf = new StringBuffer ( lineDelim ) ; for ( int i = <NUM_LIT:0> ; i < newLines ; i ++ ) { buf . append ( lineDelim ) ; } buf . append ( createIndentString ( getNodeIndent ( nextNodeIndex ) ) ) ; return buf . toString ( ) ; } private ASTNode getNode ( int nodeIndex ) { ASTNode elem = ( ASTNode ) this . list [ nodeIndex ] . getOriginalValue ( ) ; if ( elem == null ) { elem = ( ASTNode ) this . list [ nodeIndex ] . getNewValue ( ) ; } return elem ; } private int getNewLines ( int nodeIndex ) { ASTNode curr = getNode ( nodeIndex ) ; ASTNode next = getNode ( nodeIndex + <NUM_LIT:1> ) ; int currKind = curr . getNodeType ( ) ; int nextKind = next . getNodeType ( ) ; ASTNode last = null ; ASTNode secondLast = null ; for ( int i = <NUM_LIT:0> ; i < this . list . length ; i ++ ) { ASTNode elem = ( ASTNode ) this . list [ i ] . getOriginalValue ( ) ; if ( elem != null ) { if ( last != null ) { if ( elem . getNodeType ( ) == nextKind && last . getNodeType ( ) == currKind ) { return countEmptyLines ( last ) ; } secondLast = last ; } last = elem ; } } if ( currKind == ASTNode . FIELD_DECLARATION && nextKind == ASTNode . FIELD_DECLARATION ) { return <NUM_LIT:0> ; } if ( secondLast != null ) { return countEmptyLines ( secondLast ) ; } return DEFAULT_SPACING ; } private int countEmptyLines ( ASTNode last ) { LineInformation lineInformation = getLineInformation ( ) ; int lastLine = lineInformation . getLineOfOffset ( getExtendedEnd ( last ) ) ; if ( lastLine >= <NUM_LIT:0> ) { int startLine = lastLine + <NUM_LIT:1> ; int start = lineInformation . getLineOffset ( startLine ) ; if ( start < <NUM_LIT:0> ) { return <NUM_LIT:0> ; } char [ ] cont = getContent ( ) ; int i = start ; while ( i < cont . length && ScannerHelper . isWhitespace ( cont [ i ] ) ) { i ++ ; } if ( i > start ) { lastLine = lineInformation . getLineOfOffset ( i ) ; if ( lastLine > startLine ) { return lastLine - startLine ; } } } return <NUM_LIT:0> ; } protected boolean mustRemoveSeparator ( int originalOffset , int nodeIndex ) { int previousNonRemovedNodeIndex = nodeIndex - <NUM_LIT:1> ; while ( previousNonRemovedNodeIndex >= <NUM_LIT:0> && this . list [ previousNonRemovedNodeIndex ] . getChangeKind ( ) == RewriteEvent . REMOVED ) { previousNonRemovedNodeIndex -- ; } if ( previousNonRemovedNodeIndex > - <NUM_LIT:1> ) { LineInformation lineInformation = getLineInformation ( ) ; RewriteEvent prevEvent = this . list [ previousNonRemovedNodeIndex ] ; int prevKind = prevEvent . getChangeKind ( ) ; if ( prevKind == RewriteEvent . UNCHANGED || prevKind == RewriteEvent . REPLACED ) { ASTNode prevNode = ( ASTNode ) this . list [ previousNonRemovedNodeIndex ] . getOriginalValue ( ) ; int prevEndPosition = prevNode . getStartPosition ( ) + prevNode . getLength ( ) ; int prevLine = lineInformation . getLineOfOffset ( prevEndPosition ) ; int line = lineInformation . getLineOfOffset ( originalOffset ) ; if ( prevLine == line && nodeIndex + <NUM_LIT:1> < this . list . length ) { RewriteEvent nextEvent = this . list [ nodeIndex + <NUM_LIT:1> ] ; int nextKind = nextEvent . getChangeKind ( ) ; if ( nextKind == RewriteEvent . UNCHANGED || prevKind == RewriteEvent . REPLACED ) { ASTNode nextNode = ( ASTNode ) nextEvent . getOriginalValue ( ) ; int nextStartPosition = nextNode . getStartPosition ( ) ; int nextLine = lineInformation . getLineOfOffset ( nextStartPosition ) ; return nextLine == line ; } return false ; } } } return true ; } } private int rewriteParagraphList ( ASTNode parent , StructuralPropertyDescriptor property , int insertPos , int insertIndent , int separator , int lead ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event == null || event . getChangeKind ( ) == RewriteEvent . UNCHANGED ) { return doVisit ( parent , property , insertPos ) ; } RewriteEvent [ ] events = event . getChildren ( ) ; ParagraphListRewriter listRewriter = new ParagraphListRewriter ( insertIndent , separator ) ; StringBuffer leadString = new StringBuffer ( ) ; if ( isAllOfKind ( events , RewriteEvent . INSERTED ) ) { for ( int i = <NUM_LIT:0> ; i < lead ; i ++ ) { leadString . append ( getLineDelimiter ( ) ) ; } leadString . append ( createIndentString ( insertIndent ) ) ; } return listRewriter . rewriteList ( parent , property , insertPos , leadString . toString ( ) ) ; } private int rewriteOptionalTypeParameters ( ASTNode parent , StructuralPropertyDescriptor property , int offset , String keyword , boolean adjustOnNext , boolean needsSpaceOnRemoveAll ) { int pos = offset ; RewriteEvent event = getEvent ( parent , property ) ; if ( event != null && event . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { RewriteEvent [ ] children = event . getChildren ( ) ; try { boolean isAllInserted = isAllOfKind ( children , RewriteEvent . INSERTED ) ; if ( isAllInserted && adjustOnNext ) { pos = getScanner ( ) . getNextStartOffset ( pos , false ) ; } boolean isAllRemoved = ! isAllInserted && isAllOfKind ( children , RewriteEvent . REMOVED ) ; if ( isAllRemoved ) { int posBeforeOpenBracket = getScanner ( ) . getTokenStartOffset ( TerminalTokens . TokenNameLESS , pos ) ; if ( posBeforeOpenBracket != pos ) { needsSpaceOnRemoveAll = false ; } pos = posBeforeOpenBracket ; } pos = new ListRewriter ( ) . rewriteList ( parent , property , pos , String . valueOf ( '<CHAR_LIT>' ) , "<STR_LIT:U+002CU+0020>" ) ; if ( isAllRemoved ) { int endPos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameGREATER , pos ) ; endPos = getScanner ( ) . getNextStartOffset ( endPos , false ) ; String replacement = needsSpaceOnRemoveAll ? String . valueOf ( '<CHAR_LIT:U+0020>' ) : Util . EMPTY_STRING ; doTextReplace ( pos , endPos - pos , replacement , getEditGroup ( children [ children . length - <NUM_LIT:1> ] ) ) ; return endPos ; } else if ( isAllInserted ) { doTextInsert ( pos , String . valueOf ( '<CHAR_LIT:>>' + keyword ) , getEditGroup ( children [ children . length - <NUM_LIT:1> ] ) ) ; return pos ; } } catch ( CoreException e ) { handleException ( e ) ; } } else { pos = doVisit ( parent , property , pos ) ; } if ( pos != offset ) { try { return getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameGREATER , pos ) ; } catch ( CoreException e ) { handleException ( e ) ; } } return pos ; } private boolean isAllOfKind ( RewriteEvent [ ] children , int kind ) { for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { if ( children [ i ] . getChangeKind ( ) != kind ) { return false ; } } return true ; } private int rewriteNodeList ( ASTNode parent , StructuralPropertyDescriptor property , int pos , String keyword , String separator ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null && event . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { return new ListRewriter ( ) . rewriteList ( parent , property , pos , keyword , separator ) ; } return doVisit ( parent , property , pos ) ; } private void rewriteMethodBody ( MethodDeclaration parent , int startPos ) { RewriteEvent event = getEvent ( parent , MethodDeclaration . BODY_PROPERTY ) ; if ( event != null ) { switch ( event . getChangeKind ( ) ) { case RewriteEvent . INSERTED : { int endPos = parent . getStartPosition ( ) + parent . getLength ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; ASTNode body = ( ASTNode ) event . getNewValue ( ) ; doTextRemove ( startPos , endPos - startPos , editGroup ) ; int indent = getIndent ( parent . getStartPosition ( ) ) ; String prefix = this . formatter . METHOD_BODY . getPrefix ( indent ) ; doTextInsert ( startPos , prefix , editGroup ) ; doTextInsert ( startPos , body , indent , true , editGroup ) ; return ; } case RewriteEvent . REMOVED : { TextEditGroup editGroup = getEditGroup ( event ) ; ASTNode body = ( ASTNode ) event . getOriginalValue ( ) ; int endPos = parent . getStartPosition ( ) + parent . getLength ( ) ; doTextRemoveAndVisit ( startPos , endPos - startPos , body , editGroup ) ; doTextInsert ( startPos , "<STR_LIT:;>" , editGroup ) ; return ; } case RewriteEvent . REPLACED : { TextEditGroup editGroup = getEditGroup ( event ) ; ASTNode body = ( ASTNode ) event . getOriginalValue ( ) ; doTextRemoveAndVisit ( body . getStartPosition ( ) , body . getLength ( ) , body , editGroup ) ; doTextInsert ( body . getStartPosition ( ) , ( ASTNode ) event . getNewValue ( ) , getIndent ( body . getStartPosition ( ) ) , true , editGroup ) ; return ; } } } voidVisit ( parent , MethodDeclaration . BODY_PROPERTY ) ; } private int rewriteExtraDimensions ( ASTNode parent , StructuralPropertyDescriptor property , int pos ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event == null || event . getChangeKind ( ) == RewriteEvent . UNCHANGED ) { return ( ( Integer ) getOriginalValue ( parent , property ) ) . intValue ( ) ; } int oldDim = ( ( Integer ) event . getOriginalValue ( ) ) . intValue ( ) ; int newDim = ( ( Integer ) event . getNewValue ( ) ) . intValue ( ) ; if ( oldDim != newDim ) { TextEditGroup editGroup = getEditGroup ( event ) ; rewriteExtraDimensions ( oldDim , newDim , pos , editGroup ) ; } return oldDim ; } private void rewriteExtraDimensions ( int oldDim , int newDim , int pos , TextEditGroup editGroup ) { if ( oldDim < newDim ) { for ( int i = oldDim ; i < newDim ; i ++ ) { doTextInsert ( pos , "<STR_LIT:[]>" , editGroup ) ; } } else if ( newDim < oldDim ) { try { getScanner ( ) . setOffset ( pos ) ; for ( int i = newDim ; i < oldDim ; i ++ ) { getScanner ( ) . readToToken ( TerminalTokens . TokenNameRBRACKET ) ; } doTextRemove ( pos , getScanner ( ) . getCurrentEndOffset ( ) - pos , editGroup ) ; } catch ( CoreException e ) { handleException ( e ) ; } } } private int getPosAfterLeftBrace ( int pos ) { try { int nextToken = getScanner ( ) . readNext ( pos , true ) ; if ( nextToken == TerminalTokens . TokenNameLBRACE ) { return getScanner ( ) . getCurrentEndOffset ( ) ; } } catch ( CoreException e ) { handleException ( e ) ; } return pos ; } final int getIndent ( int offset ) { return this . formatter . computeIndentUnits ( getIndentOfLine ( offset ) ) ; } final void doTextInsert ( int insertOffset , ASTNode node , int initialIndentLevel , boolean removeLeadingIndent , TextEditGroup editGroup ) { ArrayList markers = new ArrayList ( ) ; String formatted = this . formatter . getFormattedResult ( node , initialIndentLevel , markers ) ; int currPos = <NUM_LIT:0> ; if ( removeLeadingIndent ) { while ( currPos < formatted . length ( ) && ScannerHelper . isWhitespace ( formatted . charAt ( currPos ) ) ) { currPos ++ ; } } for ( int i = <NUM_LIT:0> ; i < markers . size ( ) ; i ++ ) { NodeMarker curr = ( NodeMarker ) markers . get ( i ) ; int offset = curr . offset ; if ( offset >= currPos ) { String insertStr = formatted . substring ( currPos , offset ) ; doTextInsert ( insertOffset , insertStr , editGroup ) ; } else { continue ; } Object data = curr . data ; if ( data instanceof TextEditGroup ) { TextEdit edit = new RangeMarker ( insertOffset , <NUM_LIT:0> ) ; addEditGroup ( ( TextEditGroup ) data , edit ) ; addEdit ( edit ) ; if ( curr . length != <NUM_LIT:0> ) { int end = offset + curr . length ; int k = i + <NUM_LIT:1> ; while ( k < markers . size ( ) && ( ( NodeMarker ) markers . get ( k ) ) . offset < end ) { k ++ ; } curr . offset = end ; curr . length = <NUM_LIT:0> ; markers . add ( k , curr ) ; } currPos = offset ; } else { String destIndentString = this . formatter . getIndentString ( getCurrentLine ( formatted , offset ) ) ; if ( data instanceof CopyPlaceholderData ) { CopySourceInfo copySource = ( ( CopyPlaceholderData ) data ) . copySource ; int srcIndentLevel = getIndent ( copySource . getNode ( ) . getStartPosition ( ) ) ; TextEdit sourceEdit = getCopySourceEdit ( copySource ) ; doTextCopy ( sourceEdit , insertOffset , srcIndentLevel , destIndentString , editGroup ) ; currPos = offset + curr . length ; if ( needsNewLineForLineComment ( copySource . getNode ( ) , formatted , currPos ) ) { doTextInsert ( insertOffset , getLineDelimiter ( ) , editGroup ) ; } } else if ( data instanceof StringPlaceholderData ) { String code = ( ( StringPlaceholderData ) data ) . code ; String str = this . formatter . changeIndent ( code , <NUM_LIT:0> , destIndentString ) ; doTextInsert ( insertOffset , str , editGroup ) ; currPos = offset + curr . length ; } } } if ( currPos < formatted . length ( ) ) { String insertStr = formatted . substring ( currPos ) ; doTextInsert ( insertOffset , insertStr , editGroup ) ; } } private boolean needsNewLineForLineComment ( ASTNode node , String formatted , int offset ) { if ( ! this . lineCommentEndOffsets . isEndOfLineComment ( getExtendedEnd ( node ) , this . content ) ) { return false ; } return offset < formatted . length ( ) && ! IndentManipulation . isLineDelimiterChar ( formatted . charAt ( offset ) ) ; } private String getCurrentLine ( String str , int pos ) { for ( int i = pos - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { char ch = str . charAt ( i ) ; if ( IndentManipulation . isLineDelimiterChar ( ch ) ) { return str . substring ( i + <NUM_LIT:1> , pos ) ; } } return str . substring ( <NUM_LIT:0> , pos ) ; } private void rewriteModifiers ( ASTNode parent , StructuralPropertyDescriptor property , int offset ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event == null || event . getChangeKind ( ) != RewriteEvent . REPLACED ) { return ; } try { int oldModifiers = ( ( Integer ) event . getOriginalValue ( ) ) . intValue ( ) ; int newModifiers = ( ( Integer ) event . getNewValue ( ) ) . intValue ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; TokenScanner scanner = getScanner ( ) ; int tok = scanner . readNext ( offset , false ) ; int startPos = scanner . getCurrentStartOffset ( ) ; int nextStart = startPos ; loop : while ( true ) { if ( TokenScanner . isComment ( tok ) ) { tok = scanner . readNext ( true ) ; } boolean keep = true ; switch ( tok ) { case TerminalTokens . TokenNamepublic : keep = Modifier . isPublic ( newModifiers ) ; break ; case TerminalTokens . TokenNameprotected : keep = Modifier . isProtected ( newModifiers ) ; break ; case TerminalTokens . TokenNameprivate : keep = Modifier . isPrivate ( newModifiers ) ; break ; case TerminalTokens . TokenNamestatic : keep = Modifier . isStatic ( newModifiers ) ; break ; case TerminalTokens . TokenNamefinal : keep = Modifier . isFinal ( newModifiers ) ; break ; case TerminalTokens . TokenNameabstract : keep = Modifier . isAbstract ( newModifiers ) ; break ; case TerminalTokens . TokenNamenative : keep = Modifier . isNative ( newModifiers ) ; break ; case TerminalTokens . TokenNamevolatile : keep = Modifier . isVolatile ( newModifiers ) ; break ; case TerminalTokens . TokenNamestrictfp : keep = Modifier . isStrictfp ( newModifiers ) ; break ; case TerminalTokens . TokenNametransient : keep = Modifier . isTransient ( newModifiers ) ; break ; case TerminalTokens . TokenNamesynchronized : keep = Modifier . isSynchronized ( newModifiers ) ; break ; default : break loop ; } tok = getScanner ( ) . readNext ( false ) ; int currPos = nextStart ; nextStart = getScanner ( ) . getCurrentStartOffset ( ) ; if ( ! keep ) { doTextRemove ( currPos , nextStart - currPos , editGroup ) ; } } int addedModifiers = newModifiers & ~ oldModifiers ; if ( addedModifiers != <NUM_LIT:0> ) { if ( startPos != nextStart ) { int visibilityModifiers = addedModifiers & ( Modifier . PUBLIC | Modifier . PRIVATE | Modifier . PROTECTED ) ; if ( visibilityModifiers != <NUM_LIT:0> ) { StringBuffer buf = new StringBuffer ( ) ; ASTRewriteFlattener . printModifiers ( visibilityModifiers , buf ) ; doTextInsert ( startPos , buf . toString ( ) , editGroup ) ; addedModifiers &= ~ visibilityModifiers ; } } StringBuffer buf = new StringBuffer ( ) ; ASTRewriteFlattener . printModifiers ( addedModifiers , buf ) ; doTextInsert ( nextStart , buf . toString ( ) , editGroup ) ; } } catch ( CoreException e ) { handleException ( e ) ; } } class ModifierRewriter extends ListRewriter { private final Prefix annotationSeparation ; public ModifierRewriter ( Prefix annotationSeparation ) { this . annotationSeparation = annotationSeparation ; } protected String getSeparatorString ( int nodeIndex ) { ASTNode curr = getNewNode ( nodeIndex ) ; if ( curr instanceof Annotation ) { return this . annotationSeparation . getPrefix ( getNodeIndent ( nodeIndex + <NUM_LIT:1> ) ) ; } return super . getSeparatorString ( nodeIndex ) ; } } private int rewriteModifiers2 ( ASTNode node , ChildListPropertyDescriptor property , int pos ) { RewriteEvent event = getEvent ( node , property ) ; if ( event == null || event . getChangeKind ( ) == RewriteEvent . UNCHANGED ) { return doVisit ( node , property , pos ) ; } RewriteEvent [ ] children = event . getChildren ( ) ; boolean isAllInsert = isAllOfKind ( children , RewriteEvent . INSERTED ) ; boolean isAllRemove = isAllOfKind ( children , RewriteEvent . REMOVED ) ; if ( isAllInsert || isAllRemove ) { try { pos = getScanner ( ) . getNextStartOffset ( pos , false ) ; } catch ( CoreException e ) { handleException ( e ) ; } } Prefix formatterPrefix ; if ( property == SingleVariableDeclaration . MODIFIERS2_PROPERTY ) formatterPrefix = this . formatter . PARAM_ANNOTATION_SEPARATION ; else formatterPrefix = this . formatter . ANNOTATION_SEPARATION ; int endPos = new ModifierRewriter ( formatterPrefix ) . rewriteList ( node , property , pos , "<STR_LIT>" , "<STR_LIT:U+0020>" ) ; try { int nextPos = getScanner ( ) . getNextStartOffset ( endPos , false ) ; boolean lastUnchanged = children [ children . length - <NUM_LIT:1> ] . getChangeKind ( ) != RewriteEvent . UNCHANGED ; if ( isAllRemove ) { doTextRemove ( endPos , nextPos - endPos , getEditGroup ( children [ children . length - <NUM_LIT:1> ] ) ) ; return nextPos ; } else if ( isAllInsert || ( nextPos == endPos && lastUnchanged ) ) { RewriteEvent lastChild = children [ children . length - <NUM_LIT:1> ] ; String separator ; if ( lastChild . getNewValue ( ) instanceof Annotation ) { separator = formatterPrefix . getPrefix ( getIndent ( pos ) ) ; } else { separator = String . valueOf ( '<CHAR_LIT:U+0020>' ) ; } doTextInsert ( endPos , separator , getEditGroup ( lastChild ) ) ; } } catch ( CoreException e ) { handleException ( e ) ; } return endPos ; } private void replaceOperation ( int posBeforeOperation , String newOperation , TextEditGroup editGroup ) { try { getScanner ( ) . readNext ( posBeforeOperation , true ) ; doTextReplace ( getScanner ( ) . getCurrentStartOffset ( ) , getScanner ( ) . getCurrentLength ( ) , newOperation , editGroup ) ; } catch ( CoreException e ) { handleException ( e ) ; } } private void rewriteOperation ( ASTNode parent , StructuralPropertyDescriptor property , int posBeforeOperation ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null && event . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { try { String newOperation = event . getNewValue ( ) . toString ( ) ; TextEditGroup editGroup = getEditGroup ( event ) ; getScanner ( ) . readNext ( posBeforeOperation , true ) ; doTextReplace ( getScanner ( ) . getCurrentStartOffset ( ) , getScanner ( ) . getCurrentLength ( ) , newOperation , editGroup ) ; } catch ( CoreException e ) { handleException ( e ) ; } } } public void postVisit ( ASTNode node ) { TextEditGroup editGroup = this . eventStore . getTrackedNodeData ( node ) ; if ( editGroup != null ) { this . currentEdit = this . currentEdit . getParent ( ) ; } doCopySourcePostVisit ( node , this . sourceCopyEndNodes ) ; } public void preVisit ( ASTNode node ) { CopySourceInfo [ ] infos = this . eventStore . getNodeCopySources ( node ) ; doCopySourcePreVisit ( infos , this . sourceCopyEndNodes ) ; TextEditGroup editGroup = this . eventStore . getTrackedNodeData ( node ) ; if ( editGroup != null ) { SourceRange range = getExtendedRange ( node ) ; int offset = range . getStartPosition ( ) ; int length = range . getLength ( ) ; TextEdit edit = new RangeMarker ( offset , length ) ; addEditGroup ( editGroup , edit ) ; addEdit ( edit ) ; this . currentEdit = edit ; } ensureSpaceBeforeReplace ( node ) ; } final void doCopySourcePreVisit ( CopySourceInfo [ ] infos , Stack nodeEndStack ) { if ( infos != null ) { for ( int i = <NUM_LIT:0> ; i < infos . length ; i ++ ) { CopySourceInfo curr = infos [ i ] ; TextEdit edit = getCopySourceEdit ( curr ) ; addEdit ( edit ) ; this . currentEdit = edit ; nodeEndStack . push ( curr . getNode ( ) ) ; } } } final void doCopySourcePostVisit ( ASTNode node , Stack nodeEndStack ) { while ( ! nodeEndStack . isEmpty ( ) && nodeEndStack . peek ( ) == node ) { nodeEndStack . pop ( ) ; this . currentEdit = this . currentEdit . getParent ( ) ; } } public boolean visit ( CompilationUnit node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int startPos = rewriteNode ( node , CompilationUnit . PACKAGE_PROPERTY , <NUM_LIT:0> , ASTRewriteFormatter . NONE ) ; if ( getChangeKind ( node , CompilationUnit . PACKAGE_PROPERTY ) == RewriteEvent . INSERTED ) { doTextInsert ( <NUM_LIT:0> , getLineDelimiter ( ) , getEditGroup ( node , CompilationUnit . PACKAGE_PROPERTY ) ) ; } startPos = rewriteParagraphList ( node , CompilationUnit . IMPORTS_PROPERTY , startPos , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:2> ) ; rewriteParagraphList ( node , CompilationUnit . TYPES_PROPERTY , startPos , <NUM_LIT:0> , - <NUM_LIT:1> , <NUM_LIT:2> ) ; return false ; } public boolean visit ( TypeDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int apiLevel = node . getAST ( ) . apiLevel ( ) ; int pos = rewriteJavadoc ( node , TypeDeclaration . JAVADOC_PROPERTY ) ; boolean isJLS2 = apiLevel == JLS2_INTERNAL ; if ( isJLS2 ) { rewriteModifiers ( node , TypeDeclaration . MODIFIERS_PROPERTY , pos ) ; } else { rewriteModifiers2 ( node , TypeDeclaration . MODIFIERS2_PROPERTY , pos ) ; } boolean isInterface = ( ( Boolean ) getOriginalValue ( node , TypeDeclaration . INTERFACE_PROPERTY ) ) . booleanValue ( ) ; boolean invertType = isChanged ( node , TypeDeclaration . INTERFACE_PROPERTY ) ; if ( invertType ) { try { int typeToken = isInterface ? TerminalTokens . TokenNameinterface : TerminalTokens . TokenNameclass ; int startPosition = node . getStartPosition ( ) ; if ( ! isJLS2 ) { List modifiers = node . modifiers ( ) ; final int size = modifiers . size ( ) ; if ( size != <NUM_LIT:0> ) { ASTNode modifierNode = ( ASTNode ) modifiers . get ( size - <NUM_LIT:1> ) ; startPosition = modifierNode . getStartPosition ( ) + modifierNode . getLength ( ) ; } } getScanner ( ) . readToToken ( typeToken , startPosition ) ; String str = isInterface ? "<STR_LIT:class>" : "<STR_LIT>" ; int start = getScanner ( ) . getCurrentStartOffset ( ) ; int end = getScanner ( ) . getCurrentEndOffset ( ) ; doTextReplace ( start , end - start , str , getEditGroup ( node , TypeDeclaration . INTERFACE_PROPERTY ) ) ; } catch ( CoreException e ) { } } pos = rewriteRequiredNode ( node , TypeDeclaration . NAME_PROPERTY ) ; if ( ! isJLS2 ) { pos = rewriteOptionalTypeParameters ( node , TypeDeclaration . TYPE_PARAMETERS_PROPERTY , pos , "<STR_LIT>" , false , true ) ; } if ( ! isInterface || invertType ) { ChildPropertyDescriptor superClassProperty = isJLS2 ? TypeDeclaration . SUPERCLASS_PROPERTY : TypeDeclaration . SUPERCLASS_TYPE_PROPERTY ; RewriteEvent superClassEvent = getEvent ( node , superClassProperty ) ; int changeKind = superClassEvent != null ? superClassEvent . getChangeKind ( ) : RewriteEvent . UNCHANGED ; switch ( changeKind ) { case RewriteEvent . INSERTED : { doTextInsert ( pos , "<STR_LIT>" , getEditGroup ( superClassEvent ) ) ; doTextInsert ( pos , ( ASTNode ) superClassEvent . getNewValue ( ) , <NUM_LIT:0> , false , getEditGroup ( superClassEvent ) ) ; break ; } case RewriteEvent . REMOVED : { ASTNode superClass = ( ASTNode ) superClassEvent . getOriginalValue ( ) ; int endPos = getExtendedEnd ( superClass ) ; doTextRemoveAndVisit ( pos , endPos - pos , superClass , getEditGroup ( superClassEvent ) ) ; pos = endPos ; break ; } case RewriteEvent . REPLACED : { ASTNode superClass = ( ASTNode ) superClassEvent . getOriginalValue ( ) ; SourceRange range = getExtendedRange ( superClass ) ; int offset = range . getStartPosition ( ) ; int length = range . getLength ( ) ; doTextRemoveAndVisit ( offset , length , superClass , getEditGroup ( superClassEvent ) ) ; doTextInsert ( offset , ( ASTNode ) superClassEvent . getNewValue ( ) , <NUM_LIT:0> , false , getEditGroup ( superClassEvent ) ) ; pos = offset + length ; break ; } case RewriteEvent . UNCHANGED : { pos = doVisit ( node , superClassProperty , pos ) ; } } } ChildListPropertyDescriptor superInterfaceProperty = isJLS2 ? TypeDeclaration . SUPER_INTERFACES_PROPERTY : TypeDeclaration . SUPER_INTERFACE_TYPES_PROPERTY ; RewriteEvent interfaceEvent = getEvent ( node , superInterfaceProperty ) ; if ( interfaceEvent == null || interfaceEvent . getChangeKind ( ) == RewriteEvent . UNCHANGED ) { if ( invertType ) { List originalNodes = ( List ) getOriginalValue ( node , superInterfaceProperty ) ; if ( ! originalNodes . isEmpty ( ) ) { String keyword = isInterface ? "<STR_LIT>" : "<STR_LIT>" ; ASTNode firstNode = ( ASTNode ) originalNodes . get ( <NUM_LIT:0> ) ; doTextReplace ( pos , firstNode . getStartPosition ( ) - pos , keyword , getEditGroup ( node , TypeDeclaration . INTERFACE_PROPERTY ) ) ; } } pos = doVisit ( node , superInterfaceProperty , pos ) ; } else { String keyword = ( isInterface == invertType ) ? "<STR_LIT>" : "<STR_LIT>" ; if ( invertType ) { List newNodes = ( List ) interfaceEvent . getNewValue ( ) ; if ( ! newNodes . isEmpty ( ) ) { List origNodes = ( List ) interfaceEvent . getOriginalValue ( ) ; int firstStart = pos ; if ( ! origNodes . isEmpty ( ) ) { firstStart = ( ( ASTNode ) origNodes . get ( <NUM_LIT:0> ) ) . getStartPosition ( ) ; } doTextReplace ( pos , firstStart - pos , keyword , getEditGroup ( node , TypeDeclaration . INTERFACE_PROPERTY ) ) ; keyword = "<STR_LIT>" ; pos = firstStart ; } } pos = rewriteNodeList ( node , superInterfaceProperty , pos , keyword , "<STR_LIT:U+002CU+0020>" ) ; } int startIndent = getIndent ( node . getStartPosition ( ) ) + <NUM_LIT:1> ; int startPos = getPosAfterLeftBrace ( pos ) ; rewriteParagraphList ( node , TypeDeclaration . BODY_DECLARATIONS_PROPERTY , startPos , startIndent , - <NUM_LIT:1> , <NUM_LIT:2> ) ; return false ; } private void rewriteReturnType ( MethodDeclaration node , boolean isConstructor , boolean isConstructorChange ) { ChildPropertyDescriptor property = ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) ? MethodDeclaration . RETURN_TYPE_PROPERTY : MethodDeclaration . RETURN_TYPE2_PROPERTY ; ASTNode originalReturnType = ( ASTNode ) getOriginalValue ( node , property ) ; boolean returnTypeExists = originalReturnType != null && originalReturnType . getStartPosition ( ) != - <NUM_LIT:1> ; if ( ! isConstructorChange && returnTypeExists ) { rewriteRequiredNode ( node , property ) ; ensureSpaceAfterReplace ( node , property ) ; return ; } ASTNode newReturnType = ( ASTNode ) getNewValue ( node , property ) ; if ( isConstructorChange || ! returnTypeExists && newReturnType != originalReturnType ) { ASTNode originalMethodName = ( ASTNode ) getOriginalValue ( node , MethodDeclaration . NAME_PROPERTY ) ; int nextStart = originalMethodName . getStartPosition ( ) ; TextEditGroup editGroup = getEditGroup ( node , property ) ; if ( isConstructor || ! returnTypeExists ) { doTextInsert ( nextStart , newReturnType , getIndent ( nextStart ) , true , editGroup ) ; doTextInsert ( nextStart , "<STR_LIT:U+0020>" , editGroup ) ; } else { int offset = getExtendedOffset ( originalReturnType ) ; doTextRemoveAndVisit ( offset , nextStart - offset , originalReturnType , editGroup ) ; } } } public boolean visit ( MethodDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteJavadoc ( node , MethodDeclaration . JAVADOC_PROPERTY ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { rewriteModifiers ( node , MethodDeclaration . MODIFIERS_PROPERTY , pos ) ; } else { pos = rewriteModifiers2 ( node , MethodDeclaration . MODIFIERS2_PROPERTY , pos ) ; pos = rewriteOptionalTypeParameters ( node , MethodDeclaration . TYPE_PARAMETERS_PROPERTY , pos , "<STR_LIT:U+0020>" , true , pos != node . getStartPosition ( ) ) ; } boolean isConstructorChange = isChanged ( node , MethodDeclaration . CONSTRUCTOR_PROPERTY ) ; boolean isConstructor = ( ( Boolean ) getOriginalValue ( node , MethodDeclaration . CONSTRUCTOR_PROPERTY ) ) . booleanValue ( ) ; if ( ! isConstructor || isConstructorChange ) { rewriteReturnType ( node , isConstructor , isConstructorChange ) ; } pos = rewriteRequiredNode ( node , MethodDeclaration . NAME_PROPERTY ) ; try { if ( isChanged ( node , MethodDeclaration . PARAMETERS_PROPERTY ) ) { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; pos = rewriteNodeList ( node , MethodDeclaration . PARAMETERS_PROPERTY , pos , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; } else { pos = doVisit ( node , MethodDeclaration . PARAMETERS_PROPERTY , pos ) ; } pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameRPAREN , pos ) ; int extraDims = rewriteExtraDimensions ( node , MethodDeclaration . EXTRA_DIMENSIONS_PROPERTY , pos ) ; boolean hasExceptionChanges = isChanged ( node , MethodDeclaration . THROWN_EXCEPTIONS_PROPERTY ) ; int bodyChangeKind = getChangeKind ( node , MethodDeclaration . BODY_PROPERTY ) ; if ( ( extraDims > <NUM_LIT:0> ) && ( hasExceptionChanges || bodyChangeKind == RewriteEvent . INSERTED || bodyChangeKind == RewriteEvent . REMOVED ) ) { int dim = ( ( Integer ) getOriginalValue ( node , MethodDeclaration . EXTRA_DIMENSIONS_PROPERTY ) ) . intValue ( ) ; while ( dim > <NUM_LIT:0> ) { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameRBRACKET , pos ) ; dim -- ; } } pos = rewriteNodeList ( node , MethodDeclaration . THROWN_EXCEPTIONS_PROPERTY , pos , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; rewriteMethodBody ( node , pos ) ; } catch ( CoreException e ) { } return false ; } public boolean visit ( Block node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int startPos ; if ( isCollapsed ( node ) ) { startPos = node . getStartPosition ( ) ; } else { startPos = getPosAfterLeftBrace ( node . getStartPosition ( ) ) ; } int startIndent = getIndent ( node . getStartPosition ( ) ) + <NUM_LIT:1> ; rewriteParagraphList ( node , Block . STATEMENTS_PROPERTY , startPos , startIndent , <NUM_LIT:0> , <NUM_LIT:1> ) ; return false ; } public boolean visit ( ReturnStatement node ) { try { this . beforeRequiredSpaceIndex = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNamereturn , node . getStartPosition ( ) ) ; if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } ensureSpaceBeforeReplace ( node ) ; rewriteNode ( node , ReturnStatement . EXPRESSION_PROPERTY , this . beforeRequiredSpaceIndex , ASTRewriteFormatter . SPACE ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( AnonymousClassDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int startPos = getPosAfterLeftBrace ( node . getStartPosition ( ) ) ; int startIndent = getIndent ( node . getStartPosition ( ) ) + <NUM_LIT:1> ; rewriteParagraphList ( node , AnonymousClassDeclaration . BODY_DECLARATIONS_PROPERTY , startPos , startIndent , - <NUM_LIT:1> , <NUM_LIT:2> ) ; return false ; } public boolean visit ( ArrayAccess node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , ArrayAccess . ARRAY_PROPERTY ) ; rewriteRequiredNode ( node , ArrayAccess . INDEX_PROPERTY ) ; return false ; } public boolean visit ( ArrayCreation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } ArrayType arrayType = ( ArrayType ) getOriginalValue ( node , ArrayCreation . TYPE_PROPERTY ) ; int nOldBrackets = getDimensions ( arrayType ) ; int nNewBrackets = nOldBrackets ; TextEditGroup editGroup = null ; RewriteEvent typeEvent = getEvent ( node , ArrayCreation . TYPE_PROPERTY ) ; if ( typeEvent != null && typeEvent . getChangeKind ( ) == RewriteEvent . REPLACED ) { ArrayType replacingType = ( ArrayType ) typeEvent . getNewValue ( ) ; editGroup = getEditGroup ( typeEvent ) ; Type newType = replacingType . getElementType ( ) ; Type oldType = getElementType ( arrayType ) ; if ( ! newType . equals ( oldType ) ) { SourceRange range = getExtendedRange ( oldType ) ; int offset = range . getStartPosition ( ) ; int length = range . getLength ( ) ; doTextRemove ( offset , length , editGroup ) ; doTextInsert ( offset , newType , <NUM_LIT:0> , false , editGroup ) ; } nNewBrackets = replacingType . getDimensions ( ) ; } voidVisit ( arrayType ) ; try { int offset = getScanner ( ) . getTokenStartOffset ( TerminalTokens . TokenNameLBRACKET , arrayType . getStartPosition ( ) ) ; RewriteEvent dimEvent = getEvent ( node , ArrayCreation . DIMENSIONS_PROPERTY ) ; boolean hasDimensionChanges = ( dimEvent != null && dimEvent . getChangeKind ( ) != RewriteEvent . UNCHANGED ) ; if ( hasDimensionChanges ) { RewriteEvent [ ] events = dimEvent . getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < events . length ; i ++ ) { RewriteEvent event = events [ i ] ; int changeKind = event . getChangeKind ( ) ; if ( changeKind == RewriteEvent . INSERTED ) { editGroup = getEditGroup ( event ) ; doTextInsert ( offset , "<STR_LIT:[>" , editGroup ) ; doTextInsert ( offset , ( ASTNode ) event . getNewValue ( ) , <NUM_LIT:0> , false , editGroup ) ; doTextInsert ( offset , "<STR_LIT:]>" , editGroup ) ; nNewBrackets -- ; } else { ASTNode elem = ( ASTNode ) event . getOriginalValue ( ) ; int elemEnd = elem . getStartPosition ( ) + elem . getLength ( ) ; int endPos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameRBRACKET , elemEnd ) ; if ( changeKind == RewriteEvent . REMOVED ) { editGroup = getEditGroup ( event ) ; doTextRemoveAndVisit ( offset , endPos - offset , elem , editGroup ) ; } else if ( changeKind == RewriteEvent . REPLACED ) { editGroup = getEditGroup ( event ) ; SourceRange range = getExtendedRange ( elem ) ; int elemOffset = range . getStartPosition ( ) ; int elemLength = range . getLength ( ) ; doTextRemoveAndVisit ( elemOffset , elemLength , elem , editGroup ) ; doTextInsert ( elemOffset , ( ASTNode ) event . getNewValue ( ) , <NUM_LIT:0> , false , editGroup ) ; nNewBrackets -- ; } else { voidVisit ( elem ) ; nNewBrackets -- ; } offset = endPos ; nOldBrackets -- ; } } } else { offset = doVisit ( node , ArrayCreation . DIMENSIONS_PROPERTY , offset ) ; } if ( nOldBrackets != nNewBrackets ) { if ( ! hasDimensionChanges ) { offset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameRBRACKET , offset ) ; } rewriteExtraDimensions ( nOldBrackets , nNewBrackets , offset , editGroup ) ; } int kind = getChangeKind ( node , ArrayCreation . INITIALIZER_PROPERTY ) ; if ( kind == RewriteEvent . REMOVED ) { offset = getScanner ( ) . getPreviousTokenEndOffset ( TerminalTokens . TokenNameLBRACE , offset ) ; } else { offset = node . getStartPosition ( ) + node . getLength ( ) ; } rewriteNode ( node , ArrayCreation . INITIALIZER_PROPERTY , offset , ASTRewriteFormatter . SPACE ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } private Type getElementType ( ArrayType parent ) { Type t = ( Type ) getOriginalValue ( parent , ArrayType . COMPONENT_TYPE_PROPERTY ) ; while ( t . isArrayType ( ) ) { t = ( Type ) getOriginalValue ( t , ArrayType . COMPONENT_TYPE_PROPERTY ) ; } return t ; } private int getDimensions ( ArrayType parent ) { Type t = ( Type ) getOriginalValue ( parent , ArrayType . COMPONENT_TYPE_PROPERTY ) ; int dimensions = <NUM_LIT:1> ; while ( t . isArrayType ( ) ) { dimensions ++ ; t = ( Type ) getOriginalValue ( t , ArrayType . COMPONENT_TYPE_PROPERTY ) ; } return dimensions ; } public boolean visit ( ArrayInitializer node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int startPos = getPosAfterLeftBrace ( node . getStartPosition ( ) ) ; rewriteNodeList ( node , ArrayInitializer . EXPRESSIONS_PROPERTY , startPos , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; return false ; } public boolean visit ( ArrayType node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , ArrayType . COMPONENT_TYPE_PROPERTY ) ; return false ; } public boolean visit ( AssertStatement node ) { try { this . beforeRequiredSpaceIndex = getScanner ( ) . getNextEndOffset ( node . getStartPosition ( ) , true ) ; if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } ensureSpaceBeforeReplace ( node ) ; int offset = rewriteRequiredNode ( node , AssertStatement . EXPRESSION_PROPERTY ) ; rewriteNode ( node , AssertStatement . MESSAGE_PROPERTY , offset , ASTRewriteFormatter . ASSERT_COMMENT ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( Assignment node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , Assignment . LEFT_HAND_SIDE_PROPERTY ) ; rewriteOperation ( node , Assignment . OPERATOR_PROPERTY , pos ) ; rewriteRequiredNode ( node , Assignment . RIGHT_HAND_SIDE_PROPERTY ) ; return false ; } public boolean visit ( BooleanLiteral node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } Boolean newLiteral = ( Boolean ) getNewValue ( node , BooleanLiteral . BOOLEAN_VALUE_PROPERTY ) ; TextEditGroup group = getEditGroup ( node , BooleanLiteral . BOOLEAN_VALUE_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , node . getLength ( ) , newLiteral . toString ( ) , group ) ; return false ; } public boolean visit ( BreakStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } try { int offset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNamebreak , node . getStartPosition ( ) ) ; rewriteNode ( node , BreakStatement . LABEL_PROPERTY , offset , ASTRewriteFormatter . SPACE ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( CastExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , CastExpression . TYPE_PROPERTY ) ; rewriteRequiredNode ( node , CastExpression . EXPRESSION_PROPERTY ) ; return false ; } public boolean visit ( CatchClause node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , CatchClause . EXCEPTION_PROPERTY ) ; rewriteRequiredNode ( node , CatchClause . BODY_PROPERTY ) ; return false ; } public boolean visit ( CharacterLiteral node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } String escapedSeq = ( String ) getNewValue ( node , CharacterLiteral . ESCAPED_VALUE_PROPERTY ) ; TextEditGroup group = getEditGroup ( node , CharacterLiteral . ESCAPED_VALUE_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , node . getLength ( ) , escapedSeq , group ) ; return false ; } public boolean visit ( ClassInstanceCreation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteOptionalQualifier ( node , ClassInstanceCreation . EXPRESSION_PROPERTY , node . getStartPosition ( ) ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { pos = rewriteRequiredNode ( node , ClassInstanceCreation . NAME_PROPERTY ) ; } else { if ( isChanged ( node , ClassInstanceCreation . TYPE_ARGUMENTS_PROPERTY ) ) { try { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNamenew , pos ) ; rewriteOptionalTypeParameters ( node , ClassInstanceCreation . TYPE_ARGUMENTS_PROPERTY , pos , "<STR_LIT:U+0020>" , true , true ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , ClassInstanceCreation . TYPE_ARGUMENTS_PROPERTY ) ; } pos = rewriteRequiredNode ( node , ClassInstanceCreation . TYPE_PROPERTY ) ; } if ( isChanged ( node , ClassInstanceCreation . ARGUMENTS_PROPERTY ) ) { try { int startpos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; rewriteNodeList ( node , ClassInstanceCreation . ARGUMENTS_PROPERTY , startpos , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , ClassInstanceCreation . ARGUMENTS_PROPERTY ) ; } int kind = getChangeKind ( node , ClassInstanceCreation . ANONYMOUS_CLASS_DECLARATION_PROPERTY ) ; if ( kind == RewriteEvent . REMOVED ) { try { pos = getScanner ( ) . getPreviousTokenEndOffset ( TerminalTokens . TokenNameLBRACE , pos ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { pos = node . getStartPosition ( ) + node . getLength ( ) ; } rewriteNode ( node , ClassInstanceCreation . ANONYMOUS_CLASS_DECLARATION_PROPERTY , pos , ASTRewriteFormatter . SPACE ) ; return false ; } public boolean visit ( ConditionalExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , ConditionalExpression . EXPRESSION_PROPERTY ) ; rewriteRequiredNode ( node , ConditionalExpression . THEN_EXPRESSION_PROPERTY ) ; rewriteRequiredNode ( node , ConditionalExpression . ELSE_EXPRESSION_PROPERTY ) ; return false ; } public boolean visit ( ConstructorInvocation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = node . getStartPosition ( ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { pos = rewriteOptionalTypeParameters ( node , ConstructorInvocation . TYPE_ARGUMENTS_PROPERTY , pos , "<STR_LIT>" , false , false ) ; } try { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; rewriteNodeList ( node , ConstructorInvocation . ARGUMENTS_PROPERTY , pos , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( ContinueStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } try { int offset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNamecontinue , node . getStartPosition ( ) ) ; rewriteNode ( node , ContinueStatement . LABEL_PROPERTY , offset , ASTRewriteFormatter . SPACE ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( DoStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = node . getStartPosition ( ) ; try { RewriteEvent event = getEvent ( node , DoStatement . BODY_PROPERTY ) ; if ( event != null && event . getChangeKind ( ) == RewriteEvent . REPLACED ) { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNamedo , pos ) ; ASTNode body = ( ASTNode ) event . getOriginalValue ( ) ; int bodyEnd = body . getStartPosition ( ) + body . getLength ( ) ; int endPos = getScanner ( ) . getTokenStartOffset ( TerminalTokens . TokenNamewhile , bodyEnd ) ; rewriteBodyNode ( node , DoStatement . BODY_PROPERTY , startOffset , endPos , getIndent ( node . getStartPosition ( ) ) , this . formatter . DO_BLOCK ) ; } else { voidVisit ( node , DoStatement . BODY_PROPERTY ) ; } } catch ( CoreException e ) { handleException ( e ) ; } rewriteRequiredNode ( node , DoStatement . EXPRESSION_PROPERTY ) ; return false ; } public boolean visit ( EmptyStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } changeNotSupported ( node ) ; return false ; } public boolean visit ( ExpressionStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , ExpressionStatement . EXPRESSION_PROPERTY ) ; return false ; } public boolean visit ( FieldAccess node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , FieldAccess . EXPRESSION_PROPERTY ) ; rewriteRequiredNode ( node , FieldAccess . NAME_PROPERTY ) ; return false ; } public boolean visit ( FieldDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteJavadoc ( node , FieldDeclaration . JAVADOC_PROPERTY ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { rewriteModifiers ( node , FieldDeclaration . MODIFIERS_PROPERTY , pos ) ; } else { rewriteModifiers2 ( node , FieldDeclaration . MODIFIERS2_PROPERTY , pos ) ; } pos = rewriteRequiredNode ( node , FieldDeclaration . TYPE_PROPERTY ) ; ensureSpaceAfterReplace ( node , FieldDeclaration . TYPE_PROPERTY ) ; rewriteNodeList ( node , FieldDeclaration . FRAGMENTS_PROPERTY , pos , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; return false ; } public boolean visit ( ForStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } try { int pos = node . getStartPosition ( ) ; if ( isChanged ( node , ForStatement . INITIALIZERS_PROPERTY ) ) { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; pos = rewriteNodeList ( node , ForStatement . INITIALIZERS_PROPERTY , startOffset , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; } else { pos = doVisit ( node , ForStatement . INITIALIZERS_PROPERTY , pos ) ; } pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameSEMICOLON , pos ) ; pos = rewriteNode ( node , ForStatement . EXPRESSION_PROPERTY , pos , ASTRewriteFormatter . NONE ) ; if ( isChanged ( node , ForStatement . UPDATERS_PROPERTY ) ) { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameSEMICOLON , pos ) ; pos = rewriteNodeList ( node , ForStatement . UPDATERS_PROPERTY , startOffset , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; } else { pos = doVisit ( node , ForStatement . UPDATERS_PROPERTY , pos ) ; } RewriteEvent bodyEvent = getEvent ( node , ForStatement . BODY_PROPERTY ) ; if ( bodyEvent != null && bodyEvent . getChangeKind ( ) == RewriteEvent . REPLACED ) { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameRPAREN , pos ) ; rewriteBodyNode ( node , ForStatement . BODY_PROPERTY , startOffset , - <NUM_LIT:1> , getIndent ( node . getStartPosition ( ) ) , this . formatter . FOR_BLOCK ) ; } else { voidVisit ( node , ForStatement . BODY_PROPERTY ) ; } } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( IfStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , IfStatement . EXPRESSION_PROPERTY ) ; RewriteEvent thenEvent = getEvent ( node , IfStatement . THEN_STATEMENT_PROPERTY ) ; int elseChange = getChangeKind ( node , IfStatement . ELSE_STATEMENT_PROPERTY ) ; if ( thenEvent != null && thenEvent . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { try { int tok = getScanner ( ) . readNext ( pos , true ) ; pos = ( tok == TerminalTokens . TokenNameRPAREN ) ? getScanner ( ) . getCurrentEndOffset ( ) : getScanner ( ) . getCurrentStartOffset ( ) ; int indent = getIndent ( node . getStartPosition ( ) ) ; int endPos = - <NUM_LIT:1> ; Object elseStatement = getOriginalValue ( node , IfStatement . ELSE_STATEMENT_PROPERTY ) ; if ( elseStatement != null ) { ASTNode thenStatement = ( ASTNode ) thenEvent . getOriginalValue ( ) ; endPos = getScanner ( ) . getTokenStartOffset ( TerminalTokens . TokenNameelse , thenStatement . getStartPosition ( ) + thenStatement . getLength ( ) ) ; } if ( elseStatement == null || elseChange != RewriteEvent . UNCHANGED ) { pos = rewriteBodyNode ( node , IfStatement . THEN_STATEMENT_PROPERTY , pos , endPos , indent , this . formatter . IF_BLOCK_NO_ELSE ) ; } else { pos = rewriteBodyNode ( node , IfStatement . THEN_STATEMENT_PROPERTY , pos , endPos , indent , this . formatter . IF_BLOCK_WITH_ELSE ) ; } } catch ( CoreException e ) { handleException ( e ) ; } } else { pos = doVisit ( node , IfStatement . THEN_STATEMENT_PROPERTY , pos ) ; } if ( elseChange != RewriteEvent . UNCHANGED ) { int indent = getIndent ( node . getStartPosition ( ) ) ; Object newThen = getNewValue ( node , IfStatement . THEN_STATEMENT_PROPERTY ) ; if ( newThen instanceof Block ) { rewriteBodyNode ( node , IfStatement . ELSE_STATEMENT_PROPERTY , pos , - <NUM_LIT:1> , indent , this . formatter . ELSE_AFTER_BLOCK ) ; } else { rewriteBodyNode ( node , IfStatement . ELSE_STATEMENT_PROPERTY , pos , - <NUM_LIT:1> , indent , this . formatter . ELSE_AFTER_STATEMENT ) ; } } else { pos = doVisit ( node , IfStatement . ELSE_STATEMENT_PROPERTY , pos ) ; } return false ; } public boolean visit ( ImportDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { RewriteEvent event = getEvent ( node , ImportDeclaration . STATIC_PROPERTY ) ; if ( event != null && event . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { try { int pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameimport , node . getStartPosition ( ) ) ; boolean wasStatic = ( ( Boolean ) event . getOriginalValue ( ) ) . booleanValue ( ) ; if ( wasStatic ) { int endPos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNamestatic , pos ) ; doTextRemove ( pos , endPos - pos , getEditGroup ( event ) ) ; } else { doTextInsert ( pos , "<STR_LIT>" , getEditGroup ( event ) ) ; } } catch ( CoreException e ) { handleException ( e ) ; } } } int pos = rewriteRequiredNode ( node , ImportDeclaration . NAME_PROPERTY ) ; RewriteEvent event = getEvent ( node , ImportDeclaration . ON_DEMAND_PROPERTY ) ; if ( event != null && event . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { boolean isOnDemand = ( ( Boolean ) event . getOriginalValue ( ) ) . booleanValue ( ) ; if ( ! isOnDemand ) { doTextInsert ( pos , "<STR_LIT>" , getEditGroup ( event ) ) ; } else { try { int endPos = getScanner ( ) . getTokenStartOffset ( TerminalTokens . TokenNameSEMICOLON , pos ) ; doTextRemove ( pos , endPos - pos , getEditGroup ( event ) ) ; } catch ( CoreException e ) { handleException ( e ) ; } } } return false ; } public boolean visit ( InfixExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , InfixExpression . LEFT_OPERAND_PROPERTY ) ; boolean needsNewOperation = isChanged ( node , InfixExpression . OPERATOR_PROPERTY ) ; String operation = getNewValue ( node , InfixExpression . OPERATOR_PROPERTY ) . toString ( ) ; if ( needsNewOperation ) { replaceOperation ( pos , operation , getEditGroup ( node , InfixExpression . OPERATOR_PROPERTY ) ) ; } pos = rewriteRequiredNode ( node , InfixExpression . RIGHT_OPERAND_PROPERTY ) ; RewriteEvent event = getEvent ( node , InfixExpression . EXTENDED_OPERANDS_PROPERTY ) ; String prefixString = '<CHAR_LIT:U+0020>' + operation + '<CHAR_LIT:U+0020>' ; if ( needsNewOperation ) { int startPos = pos ; TextEditGroup editGroup = getEditGroup ( node , InfixExpression . OPERATOR_PROPERTY ) ; if ( event != null && event . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { RewriteEvent [ ] extendedOperands = event . getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < extendedOperands . length ; i ++ ) { RewriteEvent curr = extendedOperands [ i ] ; ASTNode elem = ( ASTNode ) curr . getOriginalValue ( ) ; if ( elem != null ) { if ( curr . getChangeKind ( ) != RewriteEvent . REPLACED ) { replaceOperation ( startPos , operation , editGroup ) ; } startPos = elem . getStartPosition ( ) + elem . getLength ( ) ; } } } else { List extendedOperands = ( List ) getOriginalValue ( node , InfixExpression . EXTENDED_OPERANDS_PROPERTY ) ; for ( int i = <NUM_LIT:0> ; i < extendedOperands . size ( ) ; i ++ ) { ASTNode elem = ( ASTNode ) extendedOperands . get ( i ) ; replaceOperation ( startPos , operation , editGroup ) ; startPos = elem . getStartPosition ( ) + elem . getLength ( ) ; } } } rewriteNodeList ( node , InfixExpression . EXTENDED_OPERANDS_PROPERTY , pos , prefixString , prefixString ) ; return false ; } public boolean visit ( Initializer node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteJavadoc ( node , Initializer . JAVADOC_PROPERTY ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { rewriteModifiers ( node , Initializer . MODIFIERS_PROPERTY , pos ) ; } else { rewriteModifiers2 ( node , Initializer . MODIFIERS2_PROPERTY , pos ) ; } rewriteRequiredNode ( node , Initializer . BODY_PROPERTY ) ; return false ; } public boolean visit ( InstanceofExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , InstanceofExpression . LEFT_OPERAND_PROPERTY ) ; ensureSpaceAfterReplace ( node , InstanceofExpression . LEFT_OPERAND_PROPERTY ) ; rewriteRequiredNode ( node , InstanceofExpression . RIGHT_OPERAND_PROPERTY ) ; return false ; } public void ensureSpaceAfterReplace ( ASTNode node , ChildPropertyDescriptor desc ) { if ( getChangeKind ( node , desc ) == RewriteEvent . REPLACED ) { int leftOperandEnd = getExtendedEnd ( ( ASTNode ) getOriginalValue ( node , desc ) ) ; try { int offset = getScanner ( ) . getNextStartOffset ( leftOperandEnd , true ) ; if ( offset == leftOperandEnd ) { doTextInsert ( offset , String . valueOf ( '<CHAR_LIT:U+0020>' ) , getEditGroup ( node , desc ) ) ; } } catch ( CoreException e ) { handleException ( e ) ; } } } public void ensureSpaceBeforeReplace ( ASTNode node ) { if ( this . beforeRequiredSpaceIndex == - <NUM_LIT:1> ) return ; List events = this . eventStore . getChangedPropertieEvents ( node ) ; for ( Iterator iterator = events . iterator ( ) ; iterator . hasNext ( ) ; ) { RewriteEvent event = ( RewriteEvent ) iterator . next ( ) ; if ( event . getChangeKind ( ) == RewriteEvent . REPLACED && event . getOriginalValue ( ) instanceof ASTNode ) { if ( this . beforeRequiredSpaceIndex == getExtendedOffset ( ( ASTNode ) event . getOriginalValue ( ) ) ) { doTextInsert ( this . beforeRequiredSpaceIndex , String . valueOf ( '<CHAR_LIT:U+0020>' ) , getEditGroup ( event ) ) ; this . beforeRequiredSpaceIndex = - <NUM_LIT:1> ; return ; } } } if ( this . beforeRequiredSpaceIndex < getExtendedOffset ( node ) ) { this . beforeRequiredSpaceIndex = - <NUM_LIT:1> ; } } public boolean visit ( Javadoc node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int startPos = node . getStartPosition ( ) + <NUM_LIT:3> ; String separator = getLineDelimiter ( ) + getIndentAtOffset ( node . getStartPosition ( ) ) + "<STR_LIT>" ; rewriteNodeList ( node , Javadoc . TAGS_PROPERTY , startPos , separator , separator ) ; return false ; } public boolean visit ( LabeledStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , LabeledStatement . LABEL_PROPERTY ) ; rewriteRequiredNode ( node , LabeledStatement . BODY_PROPERTY ) ; return false ; } public boolean visit ( MethodInvocation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteOptionalQualifier ( node , MethodInvocation . EXPRESSION_PROPERTY , node . getStartPosition ( ) ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { pos = rewriteOptionalTypeParameters ( node , MethodInvocation . TYPE_ARGUMENTS_PROPERTY , pos , "<STR_LIT>" , false , false ) ; } pos = rewriteRequiredNode ( node , MethodInvocation . NAME_PROPERTY ) ; if ( isChanged ( node , MethodInvocation . ARGUMENTS_PROPERTY ) ) { try { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; rewriteNodeList ( node , MethodInvocation . ARGUMENTS_PROPERTY , startOffset , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , MethodInvocation . ARGUMENTS_PROPERTY ) ; } return false ; } public boolean visit ( NullLiteral node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } changeNotSupported ( node ) ; return false ; } public boolean visit ( NumberLiteral node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } String newLiteral = ( String ) getNewValue ( node , NumberLiteral . TOKEN_PROPERTY ) ; TextEditGroup group = getEditGroup ( node , NumberLiteral . TOKEN_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , node . getLength ( ) , newLiteral , group ) ; return false ; } public boolean visit ( PackageDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { int pos = rewriteJavadoc ( node , PackageDeclaration . JAVADOC_PROPERTY ) ; rewriteModifiers2 ( node , PackageDeclaration . ANNOTATIONS_PROPERTY , pos ) ; } rewriteRequiredNode ( node , PackageDeclaration . NAME_PROPERTY ) ; return false ; } public boolean visit ( ParenthesizedExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , ParenthesizedExpression . EXPRESSION_PROPERTY ) ; return false ; } public boolean visit ( PostfixExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , PostfixExpression . OPERAND_PROPERTY ) ; rewriteOperation ( node , PostfixExpression . OPERATOR_PROPERTY , pos ) ; return false ; } public boolean visit ( PrefixExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteOperation ( node , PrefixExpression . OPERATOR_PROPERTY , node . getStartPosition ( ) ) ; rewriteRequiredNode ( node , PrefixExpression . OPERAND_PROPERTY ) ; return false ; } public boolean visit ( PrimitiveType node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } PrimitiveType . Code newCode = ( PrimitiveType . Code ) getNewValue ( node , PrimitiveType . PRIMITIVE_TYPE_CODE_PROPERTY ) ; TextEditGroup group = getEditGroup ( node , PrimitiveType . PRIMITIVE_TYPE_CODE_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , node . getLength ( ) , newCode . toString ( ) , group ) ; return false ; } public boolean visit ( QualifiedName node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , QualifiedName . QUALIFIER_PROPERTY ) ; rewriteRequiredNode ( node , QualifiedName . NAME_PROPERTY ) ; return false ; } public boolean visit ( SimpleName node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } String newString = ( String ) getNewValue ( node , SimpleName . IDENTIFIER_PROPERTY ) ; TextEditGroup group = getEditGroup ( node , SimpleName . IDENTIFIER_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , node . getLength ( ) , newString , group ) ; return false ; } public boolean visit ( SimpleType node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , SimpleType . NAME_PROPERTY ) ; return false ; } public boolean visit ( SingleVariableDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = node . getStartPosition ( ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { rewriteModifiers ( node , SingleVariableDeclaration . MODIFIERS_PROPERTY , pos ) ; } else { rewriteModifiers2 ( node , SingleVariableDeclaration . MODIFIERS2_PROPERTY , pos ) ; } pos = rewriteRequiredNode ( node , SingleVariableDeclaration . TYPE_PROPERTY ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { if ( isChanged ( node , SingleVariableDeclaration . VARARGS_PROPERTY ) ) { if ( getNewValue ( node , SingleVariableDeclaration . VARARGS_PROPERTY ) . equals ( Boolean . TRUE ) ) { doTextInsert ( pos , "<STR_LIT:...>" , getEditGroup ( node , SingleVariableDeclaration . VARARGS_PROPERTY ) ) ; } else { try { int ellipsisEnd = getScanner ( ) . getNextEndOffset ( pos , true ) ; doTextRemove ( pos , ellipsisEnd - pos , getEditGroup ( node , SingleVariableDeclaration . VARARGS_PROPERTY ) ) ; } catch ( CoreException e ) { handleException ( e ) ; } } } if ( ! node . isVarargs ( ) ) { ensureSpaceAfterReplace ( node , SingleVariableDeclaration . TYPE_PROPERTY ) ; } } else { ensureSpaceAfterReplace ( node , SingleVariableDeclaration . TYPE_PROPERTY ) ; } pos = rewriteRequiredNode ( node , SingleVariableDeclaration . NAME_PROPERTY ) ; int extraDims = rewriteExtraDimensions ( node , SingleVariableDeclaration . EXTRA_DIMENSIONS_PROPERTY , pos ) ; if ( extraDims > <NUM_LIT:0> ) { int kind = getChangeKind ( node , SingleVariableDeclaration . INITIALIZER_PROPERTY ) ; if ( kind == RewriteEvent . REMOVED ) { try { pos = getScanner ( ) . getPreviousTokenEndOffset ( TerminalTokens . TokenNameEQUAL , pos ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { pos = node . getStartPosition ( ) + node . getLength ( ) ; } } rewriteNode ( node , SingleVariableDeclaration . INITIALIZER_PROPERTY , pos , this . formatter . VAR_INITIALIZER ) ; return false ; } public boolean visit ( StringLiteral node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } String escapedSeq = ( String ) getNewValue ( node , StringLiteral . ESCAPED_VALUE_PROPERTY ) ; TextEditGroup group = getEditGroup ( node , StringLiteral . ESCAPED_VALUE_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , node . getLength ( ) , escapedSeq , group ) ; return false ; } public boolean visit ( SuperConstructorInvocation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteOptionalQualifier ( node , SuperConstructorInvocation . EXPRESSION_PROPERTY , node . getStartPosition ( ) ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { pos = rewriteOptionalTypeParameters ( node , SuperConstructorInvocation . TYPE_ARGUMENTS_PROPERTY , pos , "<STR_LIT>" , false , false ) ; } if ( isChanged ( node , SuperConstructorInvocation . ARGUMENTS_PROPERTY ) ) { try { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; rewriteNodeList ( node , SuperConstructorInvocation . ARGUMENTS_PROPERTY , pos , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , SuperConstructorInvocation . ARGUMENTS_PROPERTY ) ; } return false ; } public boolean visit ( SuperFieldAccess node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteOptionalQualifier ( node , SuperFieldAccess . QUALIFIER_PROPERTY , node . getStartPosition ( ) ) ; rewriteRequiredNode ( node , SuperFieldAccess . NAME_PROPERTY ) ; return false ; } public boolean visit ( SuperMethodInvocation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteOptionalQualifier ( node , SuperMethodInvocation . QUALIFIER_PROPERTY , node . getStartPosition ( ) ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { if ( isChanged ( node , SuperMethodInvocation . TYPE_ARGUMENTS_PROPERTY ) ) { try { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameDOT , pos ) ; rewriteOptionalTypeParameters ( node , SuperMethodInvocation . TYPE_ARGUMENTS_PROPERTY , pos , "<STR_LIT>" , false , false ) ; } catch ( CoreException e ) { handleException ( e ) ; } } } pos = rewriteRequiredNode ( node , SuperMethodInvocation . NAME_PROPERTY ) ; if ( isChanged ( node , SuperMethodInvocation . ARGUMENTS_PROPERTY ) ) { try { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; rewriteNodeList ( node , SuperMethodInvocation . ARGUMENTS_PROPERTY , pos , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , SuperMethodInvocation . ARGUMENTS_PROPERTY ) ; } return false ; } public boolean visit ( SwitchCase node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , SwitchCase . EXPRESSION_PROPERTY ) ; return false ; } class SwitchListRewriter extends ParagraphListRewriter { private boolean indentSwitchStatementsCompareToCases ; public SwitchListRewriter ( int initialIndent ) { super ( initialIndent , <NUM_LIT:0> ) ; this . indentSwitchStatementsCompareToCases = DefaultCodeFormatterConstants . TRUE . equals ( ASTRewriteAnalyzer . this . options . get ( DefaultCodeFormatterConstants . FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES ) ) ; } protected int getNodeIndent ( int nodeIndex ) { int indent = getInitialIndent ( ) ; if ( this . indentSwitchStatementsCompareToCases ) { RewriteEvent event = this . list [ nodeIndex ] ; int changeKind = event . getChangeKind ( ) ; ASTNode node ; if ( changeKind == RewriteEvent . INSERTED || changeKind == RewriteEvent . REPLACED ) { node = ( ASTNode ) event . getNewValue ( ) ; } else { node = ( ASTNode ) event . getOriginalValue ( ) ; } if ( node . getNodeType ( ) != ASTNode . SWITCH_CASE ) { indent ++ ; } } return indent ; } protected String getSeparatorString ( int nodeIndex ) { int total = this . list . length ; int nextNodeIndex = nodeIndex + <NUM_LIT:1> ; while ( nextNodeIndex < total && this . list [ nextNodeIndex ] . getChangeKind ( ) == RewriteEvent . REMOVED ) { nextNodeIndex ++ ; } if ( nextNodeIndex == total ) { return super . getSeparatorString ( nodeIndex ) ; } return getSeparatorString ( nodeIndex , nextNodeIndex ) ; } protected void updateIndent ( int prevMark , int originalOffset , int nodeIndex , TextEditGroup editGroup ) { if ( prevMark != RewriteEvent . UNCHANGED && prevMark != RewriteEvent . REPLACED ) return ; int previousNonRemovedNodeIndex = nodeIndex - <NUM_LIT:1> ; while ( previousNonRemovedNodeIndex >= <NUM_LIT:0> && this . list [ previousNonRemovedNodeIndex ] . getChangeKind ( ) == RewriteEvent . REMOVED ) { previousNonRemovedNodeIndex -- ; } if ( previousNonRemovedNodeIndex > - <NUM_LIT:1> ) { LineInformation lineInformation = getLineInformation ( ) ; RewriteEvent prevEvent = this . list [ previousNonRemovedNodeIndex ] ; int prevKind = prevEvent . getChangeKind ( ) ; if ( prevKind == RewriteEvent . UNCHANGED || prevKind == RewriteEvent . REPLACED ) { ASTNode prevNode = ( ASTNode ) this . list [ previousNonRemovedNodeIndex ] . getOriginalValue ( ) ; int prevEndPosition = prevNode . getStartPosition ( ) + prevNode . getLength ( ) ; int prevLine = lineInformation . getLineOfOffset ( prevEndPosition ) ; int line = lineInformation . getLineOfOffset ( originalOffset ) ; if ( prevLine == line ) { return ; } } } int total = this . list . length ; while ( nodeIndex < total && this . list [ nodeIndex ] . getChangeKind ( ) == RewriteEvent . REMOVED ) { nodeIndex ++ ; } int originalIndent = getIndent ( originalOffset ) ; int newIndent = getNodeIndent ( nodeIndex ) ; if ( originalIndent != newIndent ) { int line = getLineInformation ( ) . getLineOfOffset ( originalOffset ) ; if ( line >= <NUM_LIT:0> ) { int lineStart = getLineInformation ( ) . getLineOffset ( line ) ; doTextRemove ( lineStart , originalOffset - lineStart , editGroup ) ; doTextInsert ( lineStart , createIndentString ( newIndent ) , editGroup ) ; } } } } public boolean visit ( SwitchStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , SwitchStatement . EXPRESSION_PROPERTY ) ; ChildListPropertyDescriptor property = SwitchStatement . STATEMENTS_PROPERTY ; if ( getChangeKind ( node , property ) != RewriteEvent . UNCHANGED ) { try { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLBRACE , pos ) ; int insertIndent = getIndent ( node . getStartPosition ( ) ) ; if ( DefaultCodeFormatterConstants . TRUE . equals ( this . options . get ( DefaultCodeFormatterConstants . FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH ) ) ) { insertIndent ++ ; } ParagraphListRewriter listRewriter = new SwitchListRewriter ( insertIndent ) ; StringBuffer leadString = new StringBuffer ( ) ; leadString . append ( getLineDelimiter ( ) ) ; leadString . append ( createIndentString ( insertIndent ) ) ; listRewriter . rewriteList ( node , property , pos , leadString . toString ( ) ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , SwitchStatement . STATEMENTS_PROPERTY ) ; } return false ; } public boolean visit ( SynchronizedStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , SynchronizedStatement . EXPRESSION_PROPERTY ) ; rewriteRequiredNode ( node , SynchronizedStatement . BODY_PROPERTY ) ; return false ; } public boolean visit ( ThisExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteOptionalQualifier ( node , ThisExpression . QUALIFIER_PROPERTY , node . getStartPosition ( ) ) ; return false ; } public boolean visit ( ThrowStatement node ) { try { this . beforeRequiredSpaceIndex = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNamethrow , node . getStartPosition ( ) ) ; if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } ensureSpaceBeforeReplace ( node ) ; rewriteRequiredNode ( node , ThrowStatement . EXPRESSION_PROPERTY ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( TryStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , TryStatement . BODY_PROPERTY ) ; if ( isChanged ( node , TryStatement . CATCH_CLAUSES_PROPERTY ) ) { int indent = getIndent ( node . getStartPosition ( ) ) ; String prefix = this . formatter . CATCH_BLOCK . getPrefix ( indent ) ; pos = rewriteNodeList ( node , TryStatement . CATCH_CLAUSES_PROPERTY , pos , prefix , prefix ) ; } else { pos = doVisit ( node , TryStatement . CATCH_CLAUSES_PROPERTY , pos ) ; } rewriteNode ( node , TryStatement . FINALLY_PROPERTY , pos , this . formatter . FINALLY_BLOCK ) ; return false ; } public boolean visit ( TypeDeclarationStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { rewriteRequiredNode ( node , TypeDeclarationStatement . TYPE_DECLARATION_PROPERTY ) ; } else { rewriteRequiredNode ( node , TypeDeclarationStatement . DECLARATION_PROPERTY ) ; } return false ; } public boolean visit ( TypeLiteral node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , TypeLiteral . TYPE_PROPERTY ) ; return false ; } public boolean visit ( VariableDeclarationExpression node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = node . getStartPosition ( ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { rewriteModifiers ( node , VariableDeclarationExpression . MODIFIERS_PROPERTY , pos ) ; } else { rewriteModifiers2 ( node , VariableDeclarationExpression . MODIFIERS2_PROPERTY , pos ) ; } pos = rewriteRequiredNode ( node , VariableDeclarationExpression . TYPE_PROPERTY ) ; rewriteNodeList ( node , VariableDeclarationExpression . FRAGMENTS_PROPERTY , pos , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; return false ; } public boolean visit ( VariableDeclarationFragment node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , VariableDeclarationFragment . NAME_PROPERTY ) ; int extraDims = rewriteExtraDimensions ( node , VariableDeclarationFragment . EXTRA_DIMENSIONS_PROPERTY , pos ) ; if ( extraDims > <NUM_LIT:0> ) { int kind = getChangeKind ( node , VariableDeclarationFragment . INITIALIZER_PROPERTY ) ; if ( kind == RewriteEvent . REMOVED ) { try { pos = getScanner ( ) . getPreviousTokenEndOffset ( TerminalTokens . TokenNameEQUAL , pos ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { pos = node . getStartPosition ( ) + node . getLength ( ) ; } } rewriteNode ( node , VariableDeclarationFragment . INITIALIZER_PROPERTY , pos , this . formatter . VAR_INITIALIZER ) ; return false ; } public boolean visit ( VariableDeclarationStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = node . getStartPosition ( ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2_INTERNAL ) { rewriteModifiers ( node , VariableDeclarationStatement . MODIFIERS_PROPERTY , pos ) ; } else { rewriteModifiers2 ( node , VariableDeclarationStatement . MODIFIERS2_PROPERTY , pos ) ; } pos = rewriteRequiredNode ( node , VariableDeclarationStatement . TYPE_PROPERTY ) ; rewriteNodeList ( node , VariableDeclarationStatement . FRAGMENTS_PROPERTY , pos , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; return false ; } public boolean visit ( WhileStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , WhileStatement . EXPRESSION_PROPERTY ) ; try { if ( isChanged ( node , WhileStatement . BODY_PROPERTY ) ) { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameRPAREN , pos ) ; rewriteBodyNode ( node , WhileStatement . BODY_PROPERTY , startOffset , - <NUM_LIT:1> , getIndent ( node . getStartPosition ( ) ) , this . formatter . WHILE_BLOCK ) ; } else { voidVisit ( node , WhileStatement . BODY_PROPERTY ) ; } } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( MemberRef node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteNode ( node , MemberRef . QUALIFIER_PROPERTY , node . getStartPosition ( ) , ASTRewriteFormatter . NONE ) ; rewriteRequiredNode ( node , MemberRef . NAME_PROPERTY ) ; return false ; } public boolean visit ( MethodRef node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteNode ( node , MethodRef . QUALIFIER_PROPERTY , node . getStartPosition ( ) , ASTRewriteFormatter . NONE ) ; int pos = rewriteRequiredNode ( node , MethodRef . NAME_PROPERTY ) ; if ( isChanged ( node , MethodRef . PARAMETERS_PROPERTY ) ) { try { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; rewriteNodeList ( node , MethodRef . PARAMETERS_PROPERTY , startOffset , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , MethodRef . PARAMETERS_PROPERTY ) ; } return false ; } public boolean visit ( MethodRefParameter node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , MethodRefParameter . TYPE_PROPERTY ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { if ( isChanged ( node , MethodRefParameter . VARARGS_PROPERTY ) ) { if ( getNewValue ( node , MethodRefParameter . VARARGS_PROPERTY ) . equals ( Boolean . TRUE ) ) { doTextInsert ( pos , "<STR_LIT:...>" , getEditGroup ( node , MethodRefParameter . VARARGS_PROPERTY ) ) ; } else { try { int ellipsisEnd = getScanner ( ) . getNextEndOffset ( pos , true ) ; doTextRemove ( pos , ellipsisEnd - pos , getEditGroup ( node , MethodRefParameter . VARARGS_PROPERTY ) ) ; } catch ( CoreException e ) { handleException ( e ) ; } } } } rewriteNode ( node , MethodRefParameter . NAME_PROPERTY , pos , ASTRewriteFormatter . SPACE ) ; return false ; } public boolean visit ( TagElement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int changeKind = getChangeKind ( node , TagElement . TAG_NAME_PROPERTY ) ; switch ( changeKind ) { case RewriteEvent . INSERTED : { String newTagName = ( String ) getNewValue ( node , TagElement . TAG_NAME_PROPERTY ) ; doTextInsert ( node . getStartPosition ( ) , newTagName , getEditGroup ( node , TagElement . TAG_NAME_PROPERTY ) ) ; break ; } case RewriteEvent . REMOVED : { doTextRemove ( node . getStartPosition ( ) , findTagNameEnd ( node ) - node . getStartPosition ( ) , getEditGroup ( node , TagElement . TAG_NAME_PROPERTY ) ) ; break ; } case RewriteEvent . REPLACED : { String newTagName = ( String ) getNewValue ( node , TagElement . TAG_NAME_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , findTagNameEnd ( node ) - node . getStartPosition ( ) , newTagName , getEditGroup ( node , TagElement . TAG_NAME_PROPERTY ) ) ; break ; } } if ( isChanged ( node , TagElement . FRAGMENTS_PROPERTY ) ) { int endOffset = findTagNameEnd ( node ) ; rewriteNodeList ( node , TagElement . FRAGMENTS_PROPERTY , endOffset , "<STR_LIT:U+0020>" , "<STR_LIT:U+0020>" ) ; } else { voidVisit ( node , TagElement . FRAGMENTS_PROPERTY ) ; } return false ; } private int findTagNameEnd ( TagElement tagNode ) { if ( tagNode . getTagName ( ) != null ) { char [ ] cont = getContent ( ) ; int len = cont . length ; int i = tagNode . getStartPosition ( ) ; while ( i < len && ! IndentManipulation . isIndentChar ( cont [ i ] ) ) { i ++ ; } return i ; } return tagNode . getStartPosition ( ) ; } public boolean visit ( TextElement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } String newText = ( String ) getNewValue ( node , TextElement . TEXT_PROPERTY ) ; TextEditGroup group = getEditGroup ( node , TextElement . TEXT_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , node . getLength ( ) , newText , group ) ; return false ; } public boolean visit ( AnnotationTypeDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteJavadoc ( node , AnnotationTypeDeclaration . JAVADOC_PROPERTY ) ; rewriteModifiers2 ( node , AnnotationTypeDeclaration . MODIFIERS2_PROPERTY , pos ) ; pos = rewriteRequiredNode ( node , AnnotationTypeDeclaration . NAME_PROPERTY ) ; int startIndent = getIndent ( node . getStartPosition ( ) ) + <NUM_LIT:1> ; int startPos = getPosAfterLeftBrace ( pos ) ; rewriteParagraphList ( node , AnnotationTypeDeclaration . BODY_DECLARATIONS_PROPERTY , startPos , startIndent , - <NUM_LIT:1> , <NUM_LIT:2> ) ; return false ; } public boolean visit ( AnnotationTypeMemberDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteJavadoc ( node , AnnotationTypeMemberDeclaration . JAVADOC_PROPERTY ) ; rewriteModifiers2 ( node , AnnotationTypeMemberDeclaration . MODIFIERS2_PROPERTY , pos ) ; rewriteRequiredNode ( node , AnnotationTypeMemberDeclaration . TYPE_PROPERTY ) ; pos = rewriteRequiredNode ( node , AnnotationTypeMemberDeclaration . NAME_PROPERTY ) ; try { int changeKind = getChangeKind ( node , AnnotationTypeMemberDeclaration . DEFAULT_PROPERTY ) ; if ( changeKind == RewriteEvent . INSERTED || changeKind == RewriteEvent . REMOVED ) { pos = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameRPAREN , pos ) ; } rewriteNode ( node , AnnotationTypeMemberDeclaration . DEFAULT_PROPERTY , pos , this . formatter . ANNOT_MEMBER_DEFAULT ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } public boolean visit ( EnhancedForStatement node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , EnhancedForStatement . PARAMETER_PROPERTY ) ; int pos = rewriteRequiredNode ( node , EnhancedForStatement . EXPRESSION_PROPERTY ) ; RewriteEvent bodyEvent = getEvent ( node , EnhancedForStatement . BODY_PROPERTY ) ; if ( bodyEvent != null && bodyEvent . getChangeKind ( ) == RewriteEvent . REPLACED ) { int startOffset ; try { startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameRPAREN , pos ) ; rewriteBodyNode ( node , EnhancedForStatement . BODY_PROPERTY , startOffset , - <NUM_LIT:1> , getIndent ( node . getStartPosition ( ) ) , this . formatter . FOR_BLOCK ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , EnhancedForStatement . BODY_PROPERTY ) ; } return false ; } public boolean visit ( EnumConstantDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteJavadoc ( node , EnumConstantDeclaration . JAVADOC_PROPERTY ) ; rewriteModifiers2 ( node , EnumConstantDeclaration . MODIFIERS2_PROPERTY , pos ) ; pos = rewriteRequiredNode ( node , EnumConstantDeclaration . NAME_PROPERTY ) ; RewriteEvent argsEvent = getEvent ( node , EnumConstantDeclaration . ARGUMENTS_PROPERTY ) ; if ( argsEvent != null && argsEvent . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { RewriteEvent [ ] children = argsEvent . getChildren ( ) ; try { int nextTok = getScanner ( ) . readNext ( pos , true ) ; boolean hasParents = ( nextTok == TerminalTokens . TokenNameLPAREN ) ; boolean isAllRemoved = hasParents && isAllOfKind ( children , RewriteEvent . REMOVED ) ; String prefix = "<STR_LIT>" ; if ( ! hasParents ) { prefix = "<STR_LIT:(>" ; } else if ( ! isAllRemoved ) { pos = getScanner ( ) . getCurrentEndOffset ( ) ; } pos = rewriteNodeList ( node , EnumConstantDeclaration . ARGUMENTS_PROPERTY , pos , prefix , "<STR_LIT:U+002CU+0020>" ) ; if ( ! hasParents ) { doTextInsert ( pos , "<STR_LIT:)>" , getEditGroup ( children [ children . length - <NUM_LIT:1> ] ) ) ; } else if ( isAllRemoved ) { int afterClosing = getScanner ( ) . getNextEndOffset ( pos , true ) ; doTextRemove ( pos , afterClosing - pos , getEditGroup ( children [ children . length - <NUM_LIT:1> ] ) ) ; pos = afterClosing ; } } catch ( CoreException e ) { handleException ( e ) ; } } else { pos = doVisit ( node , EnumConstantDeclaration . ARGUMENTS_PROPERTY , pos ) ; } if ( isChanged ( node , EnumConstantDeclaration . ANONYMOUS_CLASS_DECLARATION_PROPERTY ) ) { int kind = getChangeKind ( node , EnumConstantDeclaration . ANONYMOUS_CLASS_DECLARATION_PROPERTY ) ; if ( kind == RewriteEvent . REMOVED ) { try { pos = getScanner ( ) . getPreviousTokenEndOffset ( TerminalTokens . TokenNameLBRACE , pos ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { pos = node . getStartPosition ( ) + node . getLength ( ) ; } rewriteNode ( node , EnumConstantDeclaration . ANONYMOUS_CLASS_DECLARATION_PROPERTY , pos , ASTRewriteFormatter . SPACE ) ; } return false ; } public boolean visit ( EnumDeclaration node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteJavadoc ( node , EnumDeclaration . JAVADOC_PROPERTY ) ; rewriteModifiers2 ( node , EnumDeclaration . MODIFIERS2_PROPERTY , pos ) ; pos = rewriteRequiredNode ( node , EnumDeclaration . NAME_PROPERTY ) ; pos = rewriteNodeList ( node , EnumDeclaration . SUPER_INTERFACE_TYPES_PROPERTY , pos , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; pos = getPosAfterLeftBrace ( pos ) ; String leadString = "<STR_LIT>" ; RewriteEvent constEvent = getEvent ( node , EnumDeclaration . ENUM_CONSTANTS_PROPERTY ) ; if ( constEvent != null && constEvent . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { RewriteEvent [ ] events = constEvent . getChildren ( ) ; if ( isAllOfKind ( events , RewriteEvent . INSERTED ) ) { leadString = this . formatter . FIRST_ENUM_CONST . getPrefix ( getIndent ( node . getStartPosition ( ) ) ) ; } } pos = rewriteNodeList ( node , EnumDeclaration . ENUM_CONSTANTS_PROPERTY , pos , leadString , "<STR_LIT:U+002CU+0020>" ) ; RewriteEvent bodyEvent = getEvent ( node , EnumDeclaration . BODY_DECLARATIONS_PROPERTY ) ; int indent = <NUM_LIT:0> ; if ( bodyEvent != null && bodyEvent . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { boolean hasConstants = ! ( ( List ) getNewValue ( node , EnumDeclaration . ENUM_CONSTANTS_PROPERTY ) ) . isEmpty ( ) ; RewriteEvent [ ] children = bodyEvent . getChildren ( ) ; try { if ( hasConstants ) { indent = getIndent ( pos ) ; } else { indent = getIndent ( node . getStartPosition ( ) ) + <NUM_LIT:1> ; } int token = getScanner ( ) . readNext ( pos , true ) ; boolean hasSemicolon = token == TerminalTokens . TokenNameSEMICOLON ; if ( ! hasSemicolon && isAllOfKind ( children , RewriteEvent . INSERTED ) ) { if ( ! hasConstants ) { String str = this . formatter . FIRST_ENUM_CONST . getPrefix ( indent - <NUM_LIT:1> ) ; doTextInsert ( pos , str , getEditGroup ( children [ <NUM_LIT:0> ] ) ) ; } if ( token == TerminalTokens . TokenNameCOMMA ) { int endPos = getScanner ( ) . getCurrentEndOffset ( ) ; int nextToken = getScanner ( ) . readNext ( endPos , true ) ; if ( nextToken != TerminalTokens . TokenNameSEMICOLON ) { doTextInsert ( endPos , "<STR_LIT:;>" , getEditGroup ( children [ <NUM_LIT:0> ] ) ) ; } else { endPos = getScanner ( ) . getCurrentEndOffset ( ) ; if ( isAllOfKind ( children , RewriteEvent . REMOVED ) ) { doTextRemove ( pos , endPos - pos , getEditGroup ( children [ <NUM_LIT:0> ] ) ) ; } } pos = endPos ; } else { doTextInsert ( pos , "<STR_LIT:;>" , getEditGroup ( children [ <NUM_LIT:0> ] ) ) ; } } else if ( hasSemicolon ) { int endPos = getScanner ( ) . getCurrentEndOffset ( ) ; if ( isAllOfKind ( children , RewriteEvent . REMOVED ) ) { doTextRemove ( pos , endPos - pos , getEditGroup ( children [ <NUM_LIT:0> ] ) ) ; } pos = endPos ; } } catch ( CoreException e ) { handleException ( e ) ; } } rewriteParagraphList ( node , EnumDeclaration . BODY_DECLARATIONS_PROPERTY , pos , indent , - <NUM_LIT:1> , <NUM_LIT:2> ) ; return false ; } public boolean visit ( MarkerAnnotation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , MarkerAnnotation . TYPE_NAME_PROPERTY ) ; return false ; } public boolean visit ( MemberValuePair node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , MemberValuePair . NAME_PROPERTY ) ; rewriteRequiredNode ( node , MemberValuePair . VALUE_PROPERTY ) ; return false ; } public boolean visit ( Modifier node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } String newText = getNewValue ( node , Modifier . KEYWORD_PROPERTY ) . toString ( ) ; TextEditGroup group = getEditGroup ( node , Modifier . KEYWORD_PROPERTY ) ; doTextReplace ( node . getStartPosition ( ) , node . getLength ( ) , newText , group ) ; return false ; } public boolean visit ( NormalAnnotation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , NormalAnnotation . TYPE_NAME_PROPERTY ) ; if ( isChanged ( node , NormalAnnotation . VALUES_PROPERTY ) ) { try { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLPAREN , pos ) ; rewriteNodeList ( node , NormalAnnotation . VALUES_PROPERTY , startOffset , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , NormalAnnotation . VALUES_PROPERTY ) ; } return false ; } public boolean visit ( ParameterizedType node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , ParameterizedType . TYPE_PROPERTY ) ; if ( isChanged ( node , ParameterizedType . TYPE_ARGUMENTS_PROPERTY ) ) { try { int startOffset = getScanner ( ) . getTokenEndOffset ( TerminalTokens . TokenNameLESS , pos ) ; rewriteNodeList ( node , ParameterizedType . TYPE_ARGUMENTS_PROPERTY , startOffset , "<STR_LIT>" , "<STR_LIT:U+002CU+0020>" ) ; } catch ( CoreException e ) { handleException ( e ) ; } } else { voidVisit ( node , ParameterizedType . TYPE_ARGUMENTS_PROPERTY ) ; } return false ; } public boolean visit ( QualifiedType node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , QualifiedType . QUALIFIER_PROPERTY ) ; rewriteRequiredNode ( node , QualifiedType . NAME_PROPERTY ) ; return false ; } public boolean visit ( SingleMemberAnnotation node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } rewriteRequiredNode ( node , SingleMemberAnnotation . TYPE_NAME_PROPERTY ) ; rewriteRequiredNode ( node , SingleMemberAnnotation . VALUE_PROPERTY ) ; return false ; } public boolean visit ( TypeParameter node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } int pos = rewriteRequiredNode ( node , TypeParameter . NAME_PROPERTY ) ; if ( isChanged ( node , TypeParameter . TYPE_BOUNDS_PROPERTY ) ) { rewriteNodeList ( node , TypeParameter . TYPE_BOUNDS_PROPERTY , pos , "<STR_LIT>" , "<STR_LIT>" ) ; } else { voidVisit ( node , TypeParameter . TYPE_BOUNDS_PROPERTY ) ; } return false ; } public boolean visit ( WildcardType node ) { if ( ! hasChildrenChanges ( node ) ) { return doVisitUnchangedChildren ( node ) ; } try { int pos = getScanner ( ) . getNextEndOffset ( node . getStartPosition ( ) , true ) ; Prefix prefix ; if ( Boolean . TRUE . equals ( getNewValue ( node , WildcardType . UPPER_BOUND_PROPERTY ) ) ) { prefix = this . formatter . WILDCARD_EXTENDS ; } else { prefix = this . formatter . WILDCARD_SUPER ; } int boundKindChange = getChangeKind ( node , WildcardType . UPPER_BOUND_PROPERTY ) ; if ( boundKindChange != RewriteEvent . UNCHANGED ) { int boundTypeChange = getChangeKind ( node , WildcardType . BOUND_PROPERTY ) ; if ( boundTypeChange != RewriteEvent . INSERTED && boundTypeChange != RewriteEvent . REMOVED ) { ASTNode type = ( ASTNode ) getOriginalValue ( node , WildcardType . BOUND_PROPERTY ) ; String str = prefix . getPrefix ( <NUM_LIT:0> ) ; doTextReplace ( pos , type . getStartPosition ( ) - pos , str , getEditGroup ( node , WildcardType . BOUND_PROPERTY ) ) ; } } rewriteNode ( node , WildcardType . BOUND_PROPERTY , pos , prefix ) ; } catch ( CoreException e ) { handleException ( e ) ; } return false ; } final void handleException ( Throwable e ) { IllegalArgumentException runtimeException = new IllegalArgumentException ( "<STR_LIT>" ) ; runtimeException . initCause ( e ) ; throw runtimeException ; } } </s>
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . * ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . Block ; import org . eclipse . jdt . core . dom . StructuralPropertyDescriptor ; import org . eclipse . jdt . core . dom . rewrite . TargetSourceRangeComputer ; import org . eclipse . text . edits . TextEditGroup ; public final class RewriteEventStore { public static final class PropertyLocation { private final ASTNode parent ; private final StructuralPropertyDescriptor property ; public PropertyLocation ( ASTNode parent , StructuralPropertyDescriptor property ) { this . parent = parent ; this . property = property ; } public ASTNode getParent ( ) { return this . parent ; } public StructuralPropertyDescriptor getProperty ( ) { return this . property ; } public boolean equals ( Object obj ) { if ( obj != null && obj . getClass ( ) . equals ( getClass ( ) ) ) { PropertyLocation other = ( PropertyLocation ) obj ; return other . getParent ( ) . equals ( getParent ( ) ) && other . getProperty ( ) . equals ( getProperty ( ) ) ; } return false ; } public int hashCode ( ) { return getParent ( ) . hashCode ( ) + getProperty ( ) . hashCode ( ) ; } } public static interface INodePropertyMapper { Object getOriginalValue ( ASTNode parent , StructuralPropertyDescriptor childProperty ) ; } private static class EventHolder { public final ASTNode parent ; public final StructuralPropertyDescriptor childProperty ; public final RewriteEvent event ; public EventHolder ( ASTNode parent , StructuralPropertyDescriptor childProperty , RewriteEvent change ) { this . parent = parent ; this . childProperty = childProperty ; this . event = change ; } public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; buf . append ( this . parent ) . append ( "<STR_LIT:U+0020-U+0020>" ) ; buf . append ( this . childProperty . getId ( ) ) . append ( "<STR_LIT::U+0020>" ) ; buf . append ( this . event ) . append ( '<STR_LIT:\n>' ) ; return buf . toString ( ) ; } } public static class CopySourceInfo implements Comparable { public final PropertyLocation location ; private final ASTNode node ; public final boolean isMove ; public CopySourceInfo ( PropertyLocation location , ASTNode node , boolean isMove ) { this . location = location ; this . node = node ; this . isMove = isMove ; } public ASTNode getNode ( ) { return this . node ; } public int compareTo ( Object o2 ) { CopySourceInfo r2 = ( CopySourceInfo ) o2 ; int startDiff = getNode ( ) . getStartPosition ( ) - r2 . getNode ( ) . getStartPosition ( ) ; if ( startDiff != <NUM_LIT:0> ) { return startDiff ; } if ( r2 . isMove != this . isMove ) { return this . isMove ? - <NUM_LIT:1> : <NUM_LIT:1> ; } return <NUM_LIT:0> ; } public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; if ( this . isMove ) { buf . append ( "<STR_LIT>" ) ; } else { buf . append ( "<STR_LIT>" ) ; } buf . append ( this . node ) ; return buf . toString ( ) ; } } private static class NodeRangeInfo implements Comparable { private final ASTNode first ; private final ASTNode last ; public final CopySourceInfo copyInfo ; public final ASTNode replacingNode ; public final TextEditGroup editGroup ; public NodeRangeInfo ( ASTNode parent , StructuralPropertyDescriptor childProperty , ASTNode first , ASTNode last , CopySourceInfo copyInfo , ASTNode replacingNode , TextEditGroup editGroup ) { this . first = first ; this . last = last ; this . copyInfo = copyInfo ; this . replacingNode = replacingNode ; this . editGroup = editGroup ; } public ASTNode getStartNode ( ) { return this . first ; } public ASTNode getEndNode ( ) { return this . last ; } public boolean isMove ( ) { return this . copyInfo . isMove ; } public Block getInternalPlaceholder ( ) { return ( Block ) this . copyInfo . getNode ( ) ; } public int compareTo ( Object o2 ) { NodeRangeInfo r2 = ( NodeRangeInfo ) o2 ; int startDiff = getStartNode ( ) . getStartPosition ( ) - r2 . getStartNode ( ) . getStartPosition ( ) ; if ( startDiff != <NUM_LIT:0> ) { return startDiff ; } int endDiff = getEndNode ( ) . getStartPosition ( ) - r2 . getEndNode ( ) . getStartPosition ( ) ; if ( endDiff != <NUM_LIT:0> ) { return - endDiff ; } if ( r2 . isMove ( ) != isMove ( ) ) { return isMove ( ) ? - <NUM_LIT:1> : <NUM_LIT:1> ; } return <NUM_LIT:0> ; } public void updatePlaceholderSourceRanges ( TargetSourceRangeComputer sourceRangeComputer ) { TargetSourceRangeComputer . SourceRange startRange = sourceRangeComputer . computeSourceRange ( getStartNode ( ) ) ; TargetSourceRangeComputer . SourceRange endRange = sourceRangeComputer . computeSourceRange ( getEndNode ( ) ) ; int startPos = startRange . getStartPosition ( ) ; int endPos = endRange . getStartPosition ( ) + endRange . getLength ( ) ; Block internalPlaceholder = getInternalPlaceholder ( ) ; internalPlaceholder . setSourceRange ( startPos , endPos - startPos ) ; } public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; if ( this . first != this . last ) { buf . append ( "<STR_LIT>" ) ; } if ( isMove ( ) ) { buf . append ( "<STR_LIT>" ) ; } else { buf . append ( "<STR_LIT>" ) ; } buf . append ( this . first ) ; buf . append ( "<STR_LIT:U+0020-U+0020>" ) ; buf . append ( this . last ) ; return buf . toString ( ) ; } } private class ParentIterator implements Iterator { private Iterator eventIter ; private Iterator sourceNodeIter ; private Iterator rangeNodeIter ; private Iterator trackedNodeIter ; public ParentIterator ( ) { this . eventIter = RewriteEventStore . this . eventLookup . keySet ( ) . iterator ( ) ; if ( RewriteEventStore . this . nodeCopySources != null ) { this . sourceNodeIter = RewriteEventStore . this . nodeCopySources . iterator ( ) ; } else { this . sourceNodeIter = Collections . EMPTY_LIST . iterator ( ) ; } if ( RewriteEventStore . this . nodeRangeInfos != null ) { this . rangeNodeIter = RewriteEventStore . this . nodeRangeInfos . keySet ( ) . iterator ( ) ; } else { this . rangeNodeIter = Collections . EMPTY_LIST . iterator ( ) ; } if ( RewriteEventStore . this . trackedNodes != null ) { this . trackedNodeIter = RewriteEventStore . this . trackedNodes . keySet ( ) . iterator ( ) ; } else { this . trackedNodeIter = Collections . EMPTY_LIST . iterator ( ) ; } } public boolean hasNext ( ) { return this . eventIter . hasNext ( ) || this . sourceNodeIter . hasNext ( ) || this . rangeNodeIter . hasNext ( ) || this . trackedNodeIter . hasNext ( ) ; } public Object next ( ) { if ( this . eventIter . hasNext ( ) ) { return this . eventIter . next ( ) ; } if ( this . sourceNodeIter . hasNext ( ) ) { return ( ( CopySourceInfo ) this . sourceNodeIter . next ( ) ) . getNode ( ) ; } if ( this . rangeNodeIter . hasNext ( ) ) { return ( ( PropertyLocation ) this . rangeNodeIter . next ( ) ) . getParent ( ) ; } return this . trackedNodeIter . next ( ) ; } public void remove ( ) { throw new UnsupportedOperationException ( ) ; } } public final static int NEW = <NUM_LIT:1> ; public final static int ORIGINAL = <NUM_LIT:2> ; public final static int BOTH = NEW | ORIGINAL ; final Map eventLookup ; private EventHolder lastEvent ; private Map editGroups ; List nodeCopySources ; Map nodeRangeInfos ; Map trackedNodes ; private Set insertBoundToPrevious ; private INodePropertyMapper nodePropertyMapper ; private static final String INTERNAL_PLACEHOLDER_PROPERTY = "<STR_LIT>" ; public RewriteEventStore ( ) { this . eventLookup = new HashMap ( ) ; this . lastEvent = null ; this . editGroups = null ; this . trackedNodes = null ; this . insertBoundToPrevious = null ; this . nodePropertyMapper = null ; this . nodeCopySources = null ; this . nodeRangeInfos = null ; } public void setNodePropertyMapper ( INodePropertyMapper nodePropertyMapper ) { this . nodePropertyMapper = nodePropertyMapper ; } public void clear ( ) { this . eventLookup . clear ( ) ; this . lastEvent = null ; this . trackedNodes = null ; this . editGroups = null ; this . insertBoundToPrevious = null ; this . nodeCopySources = null ; } public void addEvent ( ASTNode parent , StructuralPropertyDescriptor childProperty , RewriteEvent event ) { validateHasChildProperty ( parent , childProperty ) ; if ( event . isListRewrite ( ) ) { validateIsListProperty ( childProperty ) ; } EventHolder holder = new EventHolder ( parent , childProperty , event ) ; List entriesList = ( List ) this . eventLookup . get ( parent ) ; if ( entriesList != null ) { for ( int i = <NUM_LIT:0> ; i < entriesList . size ( ) ; i ++ ) { EventHolder curr = ( EventHolder ) entriesList . get ( i ) ; if ( curr . childProperty == childProperty ) { entriesList . set ( i , holder ) ; this . lastEvent = null ; return ; } } } else { entriesList = new ArrayList ( <NUM_LIT:3> ) ; this . eventLookup . put ( parent , entriesList ) ; } entriesList . add ( holder ) ; } public RewriteEvent getEvent ( ASTNode parent , StructuralPropertyDescriptor property ) { validateHasChildProperty ( parent , property ) ; if ( this . lastEvent != null && this . lastEvent . parent == parent && this . lastEvent . childProperty == property ) { return this . lastEvent . event ; } List entriesList = ( List ) this . eventLookup . get ( parent ) ; if ( entriesList != null ) { for ( int i = <NUM_LIT:0> ; i < entriesList . size ( ) ; i ++ ) { EventHolder holder = ( EventHolder ) entriesList . get ( i ) ; if ( holder . childProperty == property ) { this . lastEvent = holder ; return holder . event ; } } } return null ; } public NodeRewriteEvent getNodeEvent ( ASTNode parent , StructuralPropertyDescriptor childProperty , boolean forceCreation ) { validateIsNodeProperty ( childProperty ) ; NodeRewriteEvent event = ( NodeRewriteEvent ) getEvent ( parent , childProperty ) ; if ( event == null && forceCreation ) { Object originalValue = accessOriginalValue ( parent , childProperty ) ; event = new NodeRewriteEvent ( originalValue , originalValue ) ; addEvent ( parent , childProperty , event ) ; } return event ; } public ListRewriteEvent getListEvent ( ASTNode parent , StructuralPropertyDescriptor childProperty , boolean forceCreation ) { validateIsListProperty ( childProperty ) ; ListRewriteEvent event = ( ListRewriteEvent ) getEvent ( parent , childProperty ) ; if ( event == null && forceCreation ) { List originalValue = ( List ) accessOriginalValue ( parent , childProperty ) ; event = new ListRewriteEvent ( originalValue ) ; addEvent ( parent , childProperty , event ) ; } return event ; } public Iterator getChangeRootIterator ( ) { return new ParentIterator ( ) ; } public boolean hasChangedProperties ( ASTNode parent ) { List entriesList = ( List ) this . eventLookup . get ( parent ) ; if ( entriesList != null ) { for ( int i = <NUM_LIT:0> ; i < entriesList . size ( ) ; i ++ ) { EventHolder holder = ( EventHolder ) entriesList . get ( i ) ; if ( holder . event . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { return true ; } } } return false ; } public PropertyLocation getPropertyLocation ( Object value , int kind ) { for ( Iterator iter = this . eventLookup . values ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { List events = ( List ) iter . next ( ) ; for ( int i = <NUM_LIT:0> ; i < events . size ( ) ; i ++ ) { EventHolder holder = ( EventHolder ) events . get ( i ) ; RewriteEvent event = holder . event ; if ( isNodeInEvent ( event , value , kind ) ) { return new PropertyLocation ( holder . parent , holder . childProperty ) ; } if ( event . isListRewrite ( ) ) { RewriteEvent [ ] children = event . getChildren ( ) ; for ( int k = <NUM_LIT:0> ; k < children . length ; k ++ ) { if ( isNodeInEvent ( children [ k ] , value , kind ) ) { return new PropertyLocation ( holder . parent , holder . childProperty ) ; } } } } } if ( value instanceof ASTNode ) { ASTNode node = ( ASTNode ) value ; return new PropertyLocation ( node . getParent ( ) , node . getLocationInParent ( ) ) ; } return null ; } public RewriteEvent findEvent ( Object value , int kind ) { for ( Iterator iter = this . eventLookup . values ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { List events = ( List ) iter . next ( ) ; for ( int i = <NUM_LIT:0> ; i < events . size ( ) ; i ++ ) { RewriteEvent event = ( ( EventHolder ) events . get ( i ) ) . event ; if ( isNodeInEvent ( event , value , kind ) ) { return event ; } if ( event . isListRewrite ( ) ) { RewriteEvent [ ] children = event . getChildren ( ) ; for ( int k = <NUM_LIT:0> ; k < children . length ; k ++ ) { if ( isNodeInEvent ( children [ k ] , value , kind ) ) { return children [ k ] ; } } } } } return null ; } private boolean isNodeInEvent ( RewriteEvent event , Object value , int kind ) { if ( ( ( kind & NEW ) != <NUM_LIT:0> ) && event . getNewValue ( ) == value ) { return true ; } if ( ( ( kind & ORIGINAL ) != <NUM_LIT:0> ) && event . getOriginalValue ( ) == value ) { return true ; } return false ; } public Object getOriginalValue ( ASTNode parent , StructuralPropertyDescriptor property ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null ) { return event . getOriginalValue ( ) ; } return accessOriginalValue ( parent , property ) ; } public Object getNewValue ( ASTNode parent , StructuralPropertyDescriptor property ) { RewriteEvent event = getEvent ( parent , property ) ; if ( event != null ) { return event . getNewValue ( ) ; } return accessOriginalValue ( parent , property ) ; } public List getChangedPropertieEvents ( ASTNode parent ) { List changedPropertiesEvent = new ArrayList ( ) ; List entriesList = ( List ) this . eventLookup . get ( parent ) ; if ( entriesList != null ) { for ( int i = <NUM_LIT:0> ; i < entriesList . size ( ) ; i ++ ) { EventHolder holder = ( EventHolder ) entriesList . get ( i ) ; if ( holder . event . getChangeKind ( ) != RewriteEvent . UNCHANGED ) { changedPropertiesEvent . add ( holder . event ) ; } } } return changedPropertiesEvent ; } public int getChangeKind ( ASTNode node ) { RewriteEvent event = findEvent ( node , ORIGINAL ) ; if ( event != null ) { return event . getChangeKind ( ) ; } return RewriteEvent . UNCHANGED ; } private Object accessOriginalValue ( ASTNode parent , StructuralPropertyDescriptor childProperty ) { if ( this . nodePropertyMapper != null ) { return this . nodePropertyMapper . getOriginalValue ( parent , childProperty ) ; } return parent . getStructuralProperty ( childProperty ) ; } public TextEditGroup getEventEditGroup ( RewriteEvent event ) { if ( this . editGroups == null ) { return null ; } return ( TextEditGroup ) this . editGroups . get ( event ) ; } public void setEventEditGroup ( RewriteEvent event , TextEditGroup editGroup ) { if ( this . editGroups == null ) { this . editGroups = new IdentityHashMap ( <NUM_LIT:5> ) ; } this . editGroups . put ( event , editGroup ) ; } public final TextEditGroup getTrackedNodeData ( ASTNode node ) { if ( this . trackedNodes != null ) { return ( TextEditGroup ) this . trackedNodes . get ( node ) ; } return null ; } public void setTrackedNodeData ( ASTNode node , TextEditGroup editGroup ) { if ( this . trackedNodes == null ) { this . trackedNodes = new IdentityHashMap ( ) ; } this . trackedNodes . put ( node , editGroup ) ; } public final void markAsTracked ( ASTNode node , TextEditGroup editGroup ) { if ( getTrackedNodeData ( node ) != null ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } setTrackedNodeData ( node , editGroup ) ; } private final CopySourceInfo createCopySourceInfo ( PropertyLocation location , ASTNode node , boolean isMove ) { CopySourceInfo copySource = new CopySourceInfo ( location , node , isMove ) ; if ( this . nodeCopySources == null ) { this . nodeCopySources = new ArrayList ( ) ; } this . nodeCopySources . add ( copySource ) ; return copySource ; } public final CopySourceInfo markAsCopySource ( ASTNode parent , StructuralPropertyDescriptor property , ASTNode node , boolean isMove ) { return createCopySourceInfo ( new PropertyLocation ( parent , property ) , node , isMove ) ; } public final boolean isRangeCopyPlaceholder ( ASTNode node ) { return node . getProperty ( INTERNAL_PLACEHOLDER_PROPERTY ) != null ; } public final CopySourceInfo createRangeCopy ( ASTNode parent , StructuralPropertyDescriptor childProperty , ASTNode first , ASTNode last , boolean isMove , ASTNode internalPlaceholder , ASTNode replacingNode , TextEditGroup editGroup ) { CopySourceInfo copyInfo = createCopySourceInfo ( null , internalPlaceholder , isMove ) ; internalPlaceholder . setProperty ( INTERNAL_PLACEHOLDER_PROPERTY , internalPlaceholder ) ; NodeRangeInfo copyRangeInfo = new NodeRangeInfo ( parent , childProperty , first , last , copyInfo , replacingNode , editGroup ) ; ListRewriteEvent listEvent = getListEvent ( parent , childProperty , true ) ; int indexFirst = listEvent . getIndex ( first , ListRewriteEvent . OLD ) ; if ( indexFirst == - <NUM_LIT:1> ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } int indexLast = listEvent . getIndex ( last , ListRewriteEvent . OLD ) ; if ( indexLast == - <NUM_LIT:1> ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } if ( indexFirst > indexLast ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } if ( this . nodeRangeInfos == null ) { this . nodeRangeInfos = new HashMap ( ) ; } PropertyLocation loc = new PropertyLocation ( parent , childProperty ) ; List innerList = ( List ) this . nodeRangeInfos . get ( loc ) ; if ( innerList == null ) { innerList = new ArrayList ( <NUM_LIT:2> ) ; this . nodeRangeInfos . put ( loc , innerList ) ; } else { assertNoOverlap ( listEvent , indexFirst , indexLast , innerList ) ; } innerList . add ( copyRangeInfo ) ; return copyInfo ; } public CopySourceInfo [ ] getNodeCopySources ( ASTNode node ) { if ( this . nodeCopySources == null ) { return null ; } return internalGetCopySources ( this . nodeCopySources , node ) ; } public CopySourceInfo [ ] internalGetCopySources ( List copySources , ASTNode node ) { ArrayList res = new ArrayList ( <NUM_LIT:3> ) ; for ( int i = <NUM_LIT:0> ; i < copySources . size ( ) ; i ++ ) { CopySourceInfo curr = ( CopySourceInfo ) copySources . get ( i ) ; if ( curr . getNode ( ) == node ) { res . add ( curr ) ; } } if ( res . isEmpty ( ) ) { return null ; } CopySourceInfo [ ] arr = ( CopySourceInfo [ ] ) res . toArray ( new CopySourceInfo [ res . size ( ) ] ) ; Arrays . sort ( arr ) ; return arr ; } private void assertNoOverlap ( ListRewriteEvent listEvent , int indexFirst , int indexLast , List innerList ) { for ( Iterator iter = innerList . iterator ( ) ; iter . hasNext ( ) ; ) { NodeRangeInfo curr = ( NodeRangeInfo ) iter . next ( ) ; int currStart = listEvent . getIndex ( curr . getStartNode ( ) , ListRewriteEvent . BOTH ) ; int currEnd = listEvent . getIndex ( curr . getEndNode ( ) , ListRewriteEvent . BOTH ) ; if ( currStart < indexFirst && currEnd < indexLast && currEnd >= indexFirst || currStart > indexFirst && currStart <= currEnd && currEnd > indexLast ) { throw new IllegalArgumentException ( "<STR_LIT>" ) ; } } } public void prepareMovedNodes ( TargetSourceRangeComputer sourceRangeComputer ) { if ( this . nodeCopySources != null ) { prepareSingleNodeCopies ( ) ; } if ( this . nodeRangeInfos != null ) { prepareNodeRangeCopies ( sourceRangeComputer ) ; } } public void revertMovedNodes ( ) { if ( this . nodeRangeInfos != null ) { removeMoveRangePlaceholders ( ) ; } } private void removeMoveRangePlaceholders ( ) { for ( Iterator iter = this . nodeRangeInfos . entrySet ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) iter . next ( ) ; Set placeholders = new HashSet ( ) ; List rangeInfos = ( List ) entry . getValue ( ) ; for ( int i = <NUM_LIT:0> ; i < rangeInfos . size ( ) ; i ++ ) { placeholders . add ( ( ( NodeRangeInfo ) rangeInfos . get ( i ) ) . getInternalPlaceholder ( ) ) ; } PropertyLocation loc = ( PropertyLocation ) entry . getKey ( ) ; RewriteEvent [ ] children = getListEvent ( loc . getParent ( ) , loc . getProperty ( ) , true ) . getChildren ( ) ; List revertedChildren = new ArrayList ( ) ; revertListWithRanges ( children , placeholders , revertedChildren ) ; RewriteEvent [ ] revertedChildrenArr = ( RewriteEvent [ ] ) revertedChildren . toArray ( new RewriteEvent [ revertedChildren . size ( ) ] ) ; addEvent ( loc . getParent ( ) , loc . getProperty ( ) , new ListRewriteEvent ( revertedChildrenArr ) ) ; } } private void revertListWithRanges ( RewriteEvent [ ] childEvents , Set placeholders , List revertedChildren ) { for ( int i = <NUM_LIT:0> ; i < childEvents . length ; i ++ ) { RewriteEvent event = childEvents [ i ] ; ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; if ( placeholders . contains ( node ) ) { RewriteEvent [ ] placeholderChildren = getListEvent ( node , Block . STATEMENTS_PROPERTY , false ) . getChildren ( ) ; revertListWithRanges ( placeholderChildren , placeholders , revertedChildren ) ; } else { revertedChildren . add ( event ) ; } } } private void prepareNodeRangeCopies ( TargetSourceRangeComputer sourceRangeComputer ) { for ( Iterator iter = this . nodeRangeInfos . entrySet ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) iter . next ( ) ; List rangeInfos = ( List ) entry . getValue ( ) ; Collections . sort ( rangeInfos ) ; PropertyLocation loc = ( PropertyLocation ) entry . getKey ( ) ; RewriteEvent [ ] children = getListEvent ( loc . getParent ( ) , loc . getProperty ( ) , true ) . getChildren ( ) ; RewriteEvent [ ] newChildren = processListWithRanges ( rangeInfos , children , sourceRangeComputer ) ; addEvent ( loc . getParent ( ) , loc . getProperty ( ) , new ListRewriteEvent ( newChildren ) ) ; } } private RewriteEvent [ ] processListWithRanges ( List rangeInfos , RewriteEvent [ ] childEvents , TargetSourceRangeComputer sourceRangeComputer ) { List newChildEvents = new ArrayList ( childEvents . length ) ; NodeRangeInfo topInfo = null ; Stack newChildrenStack = new Stack ( ) ; Stack topInfoStack = new Stack ( ) ; Iterator rangeInfoIterator = rangeInfos . iterator ( ) ; NodeRangeInfo nextInfo = ( NodeRangeInfo ) rangeInfoIterator . next ( ) ; for ( int k = <NUM_LIT:0> ; k < childEvents . length ; k ++ ) { RewriteEvent event = childEvents [ k ] ; ASTNode node = ( ASTNode ) event . getOriginalValue ( ) ; while ( nextInfo != null && node == nextInfo . getStartNode ( ) ) { nextInfo . updatePlaceholderSourceRanges ( sourceRangeComputer ) ; Block internalPlaceholder = nextInfo . getInternalPlaceholder ( ) ; RewriteEvent newEvent ; if ( nextInfo . isMove ( ) ) { newEvent = new NodeRewriteEvent ( internalPlaceholder , nextInfo . replacingNode ) ; } else { newEvent = new NodeRewriteEvent ( internalPlaceholder , internalPlaceholder ) ; } newChildEvents . add ( newEvent ) ; if ( nextInfo . editGroup != null ) { setEventEditGroup ( newEvent , nextInfo . editGroup ) ; } newChildrenStack . push ( newChildEvents ) ; topInfoStack . push ( topInfo ) ; newChildEvents = new ArrayList ( childEvents . length ) ; topInfo = nextInfo ; nextInfo = rangeInfoIterator . hasNext ( ) ? ( NodeRangeInfo ) rangeInfoIterator . next ( ) : null ; } newChildEvents . add ( event ) ; while ( topInfo != null && node == topInfo . getEndNode ( ) ) { RewriteEvent [ ] placeholderChildEvents = ( RewriteEvent [ ] ) newChildEvents . toArray ( new RewriteEvent [ newChildEvents . size ( ) ] ) ; Block internalPlaceholder = topInfo . getInternalPlaceholder ( ) ; addEvent ( internalPlaceholder , Block . STATEMENTS_PROPERTY , new ListRewriteEvent ( placeholderChildEvents ) ) ; newChildEvents = ( List ) newChildrenStack . pop ( ) ; topInfo = ( NodeRangeInfo ) topInfoStack . pop ( ) ; } } return ( RewriteEvent [ ] ) newChildEvents . toArray ( new RewriteEvent [ newChildEvents . size ( ) ] ) ; } private void prepareSingleNodeCopies ( ) { for ( int i = <NUM_LIT:0> ; i < this . nodeCopySources . size ( ) ; i ++ ) { CopySourceInfo curr = ( CopySourceInfo ) this . nodeCopySources . get ( i ) ; if ( curr . isMove && curr . location != null ) { doMarkMovedAsRemoved ( curr , curr . location . getParent ( ) , curr . location . getProperty ( ) ) ; } } } private void doMarkMovedAsRemoved ( CopySourceInfo curr , ASTNode parent , StructuralPropertyDescriptor childProperty ) { if ( childProperty . isChildListProperty ( ) ) { ListRewriteEvent event = getListEvent ( parent , childProperty , true ) ; int index = event . getIndex ( curr . getNode ( ) , ListRewriteEvent . OLD ) ; if ( index != - <NUM_LIT:1> && event . getChangeKind ( index ) == RewriteEvent . UNCHANGED ) { event . setNewValue ( null , index ) ; } } else { NodeRewriteEvent event = getNodeEvent ( parent , childProperty , true ) ; if ( event . getChangeKind ( ) == RewriteEvent . UNCHANGED ) { event . setNewValue ( null ) ; } } } public boolean isInsertBoundToPrevious ( ASTNode node ) { if ( this . insertBoundToPrevious != null ) { return this . insertBoundToPrevious . contains ( node ) ; } return false ; } public void setInsertBoundToPrevious ( ASTNode node ) { if ( this . insertBoundToPrevious == null ) { this . insertBoundToPrevious = new HashSet ( ) ; } this . insertBoundToPrevious . add ( node ) ; } private void validateIsListProperty ( StructuralPropertyDescriptor property ) { if ( ! property . isChildListProperty ( ) ) { String message = property . getId ( ) + "<STR_LIT>" ; throw new IllegalArgumentException ( message ) ; } } private void validateHasChildProperty ( ASTNode parent , StructuralPropertyDescriptor property ) { if ( ! parent . structuralPropertiesForType ( ) . contains ( property ) ) { String message = Signature . getSimpleName ( parent . getClass ( ) . getName ( ) ) + "<STR_LIT>" + property . getId ( ) ; throw new IllegalArgumentException ( message ) ; } } private void validateIsNodeProperty ( StructuralPropertyDescriptor property ) { if ( property . isChildListProperty ( ) ) { String message = property . getId ( ) + "<STR_LIT>" ; throw new IllegalArgumentException ( message ) ; } } public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; for ( Iterator iter = this . eventLookup . values ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { List events = ( List ) iter . next ( ) ; for ( int i = <NUM_LIT:0> ; i < events . size ( ) ; i ++ ) { buf . append ( events . get ( i ) . toString ( ) ) . append ( '<STR_LIT:\n>' ) ; } } return buf . toString ( ) ; } public static boolean isNewNode ( ASTNode node ) { return ( node . getFlags ( ) & ASTNode . ORIGINAL ) == <NUM_LIT:0> ; } } </s>
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . ArrayList ; import java . util . Collection ; import java . util . Map ; import org . eclipse . core . runtime . Assert ; import org . eclipse . jdt . core . ToolFactory ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . Annotation ; import org . eclipse . jdt . core . dom . Block ; import org . eclipse . jdt . core . dom . BodyDeclaration ; import org . eclipse . jdt . core . dom . Expression ; import org . eclipse . jdt . core . dom . Statement ; import org . eclipse . jdt . core . formatter . CodeFormatter ; import org . eclipse . jdt . core . formatter . IndentManipulation ; import org . eclipse . jface . text . BadLocationException ; import org . eclipse . jface . text . BadPositionCategoryException ; import org . eclipse . jface . text . DefaultPositionUpdater ; import org . eclipse . jface . text . Document ; import org . eclipse . jface . text . Position ; import org . eclipse . text . edits . DeleteEdit ; import org . eclipse . text . edits . InsertEdit ; import org . eclipse . text . edits . MultiTextEdit ; import org . eclipse . text . edits . ReplaceEdit ; import org . eclipse . text . edits . TextEdit ; final class ASTRewriteFormatter { public static class NodeMarker extends Position { public Object data ; } private class ExtendedFlattener extends ASTRewriteFlattener { private ArrayList positions ; public ExtendedFlattener ( RewriteEventStore store ) { super ( store ) ; this . positions = new ArrayList ( ) ; } public void preVisit ( ASTNode node ) { Object trackData = getEventStore ( ) . getTrackedNodeData ( node ) ; if ( trackData != null ) { addMarker ( trackData , this . result . length ( ) , <NUM_LIT:0> ) ; } Object placeholderData = getPlaceholders ( ) . getPlaceholderData ( node ) ; if ( placeholderData != null ) { addMarker ( placeholderData , this . result . length ( ) , <NUM_LIT:0> ) ; } } public void postVisit ( ASTNode node ) { Object placeholderData = getPlaceholders ( ) . getPlaceholderData ( node ) ; if ( placeholderData != null ) { fixupLength ( placeholderData , this . result . length ( ) ) ; } Object trackData = getEventStore ( ) . getTrackedNodeData ( node ) ; if ( trackData != null ) { fixupLength ( trackData , this . result . length ( ) ) ; } } public boolean visit ( Block node ) { if ( getPlaceholders ( ) . isCollapsed ( node ) ) { visitList ( node , Block . STATEMENTS_PROPERTY , null ) ; return false ; } return super . visit ( node ) ; } private NodeMarker addMarker ( Object annotation , int startOffset , int length ) { NodeMarker marker = new NodeMarker ( ) ; marker . offset = startOffset ; marker . length = length ; marker . data = annotation ; this . positions . add ( marker ) ; return marker ; } private void fixupLength ( Object data , int endOffset ) { for ( int i = this . positions . size ( ) - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { NodeMarker marker = ( NodeMarker ) this . positions . get ( i ) ; if ( marker . data == data ) { marker . length = endOffset - marker . offset ; return ; } } } public NodeMarker [ ] getMarkers ( ) { return ( NodeMarker [ ] ) this . positions . toArray ( new NodeMarker [ this . positions . size ( ) ] ) ; } } private final String lineDelimiter ; private final int tabWidth ; private final int indentWidth ; private final NodeInfoStore placeholders ; private final RewriteEventStore eventStore ; private final Map options ; public ASTRewriteFormatter ( NodeInfoStore placeholders , RewriteEventStore eventStore , Map options , String lineDelimiter ) { this . placeholders = placeholders ; this . eventStore = eventStore ; this . options = options ; this . lineDelimiter = lineDelimiter ; this . tabWidth = IndentManipulation . getTabWidth ( options ) ; this . indentWidth = IndentManipulation . getIndentWidth ( options ) ; } public NodeInfoStore getPlaceholders ( ) { return this . placeholders ; } public RewriteEventStore getEventStore ( ) { return this . eventStore ; } public int getTabWidth ( ) { return this . tabWidth ; } public int getIndentWidth ( ) { return this . indentWidth ; } public String getLineDelimiter ( ) { return this . lineDelimiter ; } public String getFormattedResult ( ASTNode node , int initialIndentationLevel , Collection resultingMarkers ) { ExtendedFlattener flattener = new ExtendedFlattener ( this . eventStore ) ; node . accept ( flattener ) ; NodeMarker [ ] markers = flattener . getMarkers ( ) ; for ( int i = <NUM_LIT:0> ; i < markers . length ; i ++ ) { resultingMarkers . add ( markers [ i ] ) ; } String unformatted = flattener . getResult ( ) ; TextEdit edit = formatNode ( node , unformatted , initialIndentationLevel ) ; if ( edit == null ) { if ( initialIndentationLevel > <NUM_LIT:0> ) { String indentString = createIndentString ( initialIndentationLevel ) ; ReplaceEdit [ ] edits = IndentManipulation . getChangeIndentEdits ( unformatted , <NUM_LIT:0> , this . tabWidth , this . indentWidth , indentString ) ; edit = new MultiTextEdit ( ) ; edit . addChild ( new InsertEdit ( <NUM_LIT:0> , indentString ) ) ; edit . addChildren ( edits ) ; } else { return unformatted ; } } return evaluateFormatterEdit ( unformatted , edit , markers ) ; } public String createIndentString ( int indentationUnits ) { return ToolFactory . createCodeFormatter ( this . options ) . createIndentationString ( indentationUnits ) ; } public String getIndentString ( String currentLine ) { return IndentManipulation . extractIndentString ( currentLine , this . tabWidth , this . indentWidth ) ; } public String changeIndent ( String code , int codeIndentLevel , String newIndent ) { return IndentManipulation . changeIndent ( code , codeIndentLevel , this . tabWidth , this . indentWidth , newIndent , this . lineDelimiter ) ; } public int computeIndentUnits ( String line ) { return IndentManipulation . measureIndentUnits ( line , this . tabWidth , this . indentWidth ) ; } public static String evaluateFormatterEdit ( String string , TextEdit edit , Position [ ] positions ) { try { Document doc = createDocument ( string , positions ) ; edit . apply ( doc , <NUM_LIT:0> ) ; if ( positions != null ) { for ( int i = <NUM_LIT:0> ; i < positions . length ; i ++ ) { Assert . isTrue ( ! positions [ i ] . isDeleted , "<STR_LIT>" ) ; } } return doc . get ( ) ; } catch ( BadLocationException e ) { Assert . isTrue ( false , "<STR_LIT>" + e . getMessage ( ) ) ; } return null ; } public TextEdit formatString ( int kind , String string , int offset , int length , int indentationLevel ) { return ToolFactory . createCodeFormatter ( this . options ) . format ( kind , string , offset , length , indentationLevel , this . lineDelimiter ) ; } private TextEdit formatNode ( ASTNode node , String str , int indentationLevel ) { int code ; String prefix = "<STR_LIT>" ; String suffix = "<STR_LIT>" ; if ( node instanceof Statement ) { code = CodeFormatter . K_STATEMENTS ; if ( node . getNodeType ( ) == ASTNode . SWITCH_CASE ) { prefix = "<STR_LIT>" ; suffix = "<STR_LIT:}>" ; code = CodeFormatter . K_STATEMENTS ; } } else if ( node instanceof Expression && node . getNodeType ( ) != ASTNode . VARIABLE_DECLARATION_EXPRESSION ) { if ( node instanceof Annotation ) { suffix = "<STR_LIT>" ; code = CodeFormatter . K_COMPILATION_UNIT ; } else { code = CodeFormatter . K_EXPRESSION ; } } else if ( node instanceof BodyDeclaration ) { code = CodeFormatter . K_CLASS_BODY_DECLARATIONS ; } else { switch ( node . getNodeType ( ) ) { case ASTNode . ARRAY_TYPE : case ASTNode . PARAMETERIZED_TYPE : case ASTNode . PRIMITIVE_TYPE : case ASTNode . QUALIFIED_TYPE : case ASTNode . SIMPLE_TYPE : suffix = "<STR_LIT>" ; code = CodeFormatter . K_CLASS_BODY_DECLARATIONS ; break ; case ASTNode . WILDCARD_TYPE : prefix = "<STR_LIT>" ; suffix = "<STR_LIT>" ; code = CodeFormatter . K_CLASS_BODY_DECLARATIONS ; break ; case ASTNode . COMPILATION_UNIT : code = CodeFormatter . K_COMPILATION_UNIT ; break ; case ASTNode . VARIABLE_DECLARATION_EXPRESSION : case ASTNode . SINGLE_VARIABLE_DECLARATION : suffix = "<STR_LIT:;>" ; code = CodeFormatter . K_STATEMENTS ; break ; case ASTNode . VARIABLE_DECLARATION_FRAGMENT : prefix = "<STR_LIT>" ; suffix = "<STR_LIT:;>" ; code = CodeFormatter . K_STATEMENTS ; break ; case ASTNode . PACKAGE_DECLARATION : case ASTNode . IMPORT_DECLARATION : suffix = "<STR_LIT>" ; code = CodeFormatter . K_COMPILATION_UNIT ; break ; case ASTNode . JAVADOC : suffix = "<STR_LIT>" ; code = CodeFormatter . K_COMPILATION_UNIT ; break ; case ASTNode . CATCH_CLAUSE : prefix = "<STR_LIT>" ; code = CodeFormatter . K_STATEMENTS ; break ; case ASTNode . ANONYMOUS_CLASS_DECLARATION : prefix = "<STR_LIT>" ; suffix = "<STR_LIT:;>" ; code = CodeFormatter . K_STATEMENTS ; break ; case ASTNode . MEMBER_VALUE_PAIR : prefix = "<STR_LIT>" ; suffix = "<STR_LIT>" ; code = CodeFormatter . K_COMPILATION_UNIT ; break ; case ASTNode . MODIFIER : suffix = "<STR_LIT>" ; code = CodeFormatter . K_COMPILATION_UNIT ; break ; case ASTNode . TYPE_PARAMETER : prefix = "<STR_LIT>" ; suffix = "<STR_LIT>" ; code = CodeFormatter . K_COMPILATION_UNIT ; break ; case ASTNode . MEMBER_REF : case ASTNode . METHOD_REF : case ASTNode . METHOD_REF_PARAMETER : case ASTNode . TAG_ELEMENT : case ASTNode . TEXT_ELEMENT : return null ; default : return null ; } } String concatStr = prefix + str + suffix ; TextEdit edit = formatString ( code , concatStr , prefix . length ( ) , str . length ( ) , indentationLevel ) ; if ( prefix . length ( ) > <NUM_LIT:0> ) { edit = shifEdit ( edit , prefix . length ( ) ) ; } return edit ; } private static TextEdit shifEdit ( TextEdit oldEdit , int diff ) { TextEdit newEdit ; if ( oldEdit instanceof ReplaceEdit ) { ReplaceEdit edit = ( ReplaceEdit ) oldEdit ; newEdit = new ReplaceEdit ( edit . getOffset ( ) - diff , edit . getLength ( ) , edit . getText ( ) ) ; } else if ( oldEdit instanceof InsertEdit ) { InsertEdit edit = ( InsertEdit ) oldEdit ; newEdit = new InsertEdit ( edit . getOffset ( ) - diff , edit . getText ( ) ) ; } else if ( oldEdit instanceof DeleteEdit ) { DeleteEdit edit = ( DeleteEdit ) oldEdit ; newEdit = new DeleteEdit ( edit . getOffset ( ) - diff , edit . getLength ( ) ) ; } else if ( oldEdit instanceof MultiTextEdit ) { newEdit = new MultiTextEdit ( ) ; } else { return null ; } TextEdit [ ] children = oldEdit . getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { TextEdit shifted = shifEdit ( children [ i ] , diff ) ; if ( shifted != null ) { newEdit . addChild ( shifted ) ; } } return newEdit ; } private static Document createDocument ( String string , Position [ ] positions ) throws IllegalArgumentException { Document doc = new Document ( string ) ; try { if ( positions != null ) { final String POS_CATEGORY = "<STR_LIT>" ; doc . addPositionCategory ( POS_CATEGORY ) ; doc . addPositionUpdater ( new DefaultPositionUpdater ( POS_CATEGORY ) { protected boolean notDeleted ( ) { int start = this . fOffset ; int end = start + this . fLength ; if ( start < this . fPosition . offset && ( this . fPosition . offset + this . fPosition . length < end ) ) { this . fPosition . offset = end ; return false ; } return true ; } } ) ; for ( int i = <NUM_LIT:0> ; i < positions . length ; i ++ ) { try { doc . addPosition ( POS_CATEGORY , positions [ i ] ) ; } catch ( BadLocationException e ) { throw new IllegalArgumentException ( "<STR_LIT>" + positions [ i ] . offset + "<STR_LIT>" + positions [ i ] . length + "<STR_LIT>" + string . length ( ) ) ; } } } } catch ( BadPositionCategoryException cannotHappen ) { } return doc ; } public static interface Prefix { String getPrefix ( int indent ) ; } public static interface BlockContext { String [ ] getPrefixAndSuffix ( int indent , ASTNode node , RewriteEventStore events ) ; } public static class ConstPrefix implements Prefix { private String prefix ; public ConstPrefix ( String prefix ) { this . prefix = prefix ; } public String getPrefix ( int indent ) { return this . prefix ; } } private class FormattingPrefix implements Prefix { private int kind ; private String string ; private int start ; private int length ; public FormattingPrefix ( String string , String sub , int kind ) { this . start = string . indexOf ( sub ) ; this . length = sub . length ( ) ; this . string = string ; this . kind = kind ; } public String getPrefix ( int indent ) { Position pos = new Position ( this . start , this . length ) ; String str = this . string ; TextEdit res = formatString ( this . kind , str , <NUM_LIT:0> , str . length ( ) , indent ) ; if ( res != null ) { str = evaluateFormatterEdit ( str , res , new Position [ ] { pos } ) ; } return str . substring ( pos . offset + <NUM_LIT:1> , pos . offset + pos . length - <NUM_LIT:1> ) ; } } private class BlockFormattingPrefix implements BlockContext { private String prefix ; private int start ; public BlockFormattingPrefix ( String prefix , int start ) { this . start = start ; this . prefix = prefix ; } public String [ ] getPrefixAndSuffix ( int indent , ASTNode node , RewriteEventStore events ) { String nodeString = ASTRewriteFlattener . asString ( node , events ) ; String str = this . prefix + nodeString ; Position pos = new Position ( this . start , this . prefix . length ( ) + <NUM_LIT:1> - this . start ) ; TextEdit res = formatString ( CodeFormatter . K_STATEMENTS , str , <NUM_LIT:0> , str . length ( ) , indent ) ; if ( res != null ) { str = evaluateFormatterEdit ( str , res , new Position [ ] { pos } ) ; } return new String [ ] { str . substring ( pos . offset + <NUM_LIT:1> , pos . offset + pos . length - <NUM_LIT:1> ) , "<STR_LIT>" } ; } } private class BlockFormattingPrefixSuffix implements BlockContext { private String prefix ; private String suffix ; private int start ; public BlockFormattingPrefixSuffix ( String prefix , String suffix , int start ) { this . start = start ; this . suffix = suffix ; this . prefix = prefix ; } public String [ ] getPrefixAndSuffix ( int indent , ASTNode node , RewriteEventStore events ) { String nodeString = ASTRewriteFlattener . asString ( node , events ) ; int nodeStart = this . prefix . length ( ) ; int nodeEnd = nodeStart + nodeString . length ( ) - <NUM_LIT:1> ; String str = this . prefix + nodeString + this . suffix ; Position pos1 = new Position ( this . start , nodeStart + <NUM_LIT:1> - this . start ) ; Position pos2 = new Position ( nodeEnd , <NUM_LIT:2> ) ; TextEdit res = formatString ( CodeFormatter . K_STATEMENTS , str , <NUM_LIT:0> , str . length ( ) , indent ) ; if ( res != null ) { str = evaluateFormatterEdit ( str , res , new Position [ ] { pos1 , pos2 } ) ; } return new String [ ] { str . substring ( pos1 . offset + <NUM_LIT:1> , pos1 . offset + pos1 . length - <NUM_LIT:1> ) , str . substring ( pos2 . offset + <NUM_LIT:1> , pos2 . offset + pos2 . length - <NUM_LIT:1> ) } ; } } public final static Prefix NONE = new ConstPrefix ( "<STR_LIT>" ) ; public final static Prefix SPACE = new ConstPrefix ( "<STR_LIT:U+0020>" ) ; public final static Prefix ASSERT_COMMENT = new ConstPrefix ( "<STR_LIT:U+0020:U+0020>" ) ; public final Prefix VAR_INITIALIZER = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_STATEMENTS ) ; public final Prefix METHOD_BODY = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_CLASS_BODY_DECLARATIONS ) ; public final Prefix FINALLY_BLOCK = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_STATEMENTS ) ; public final Prefix CATCH_BLOCK = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_STATEMENTS ) ; public final Prefix ANNOT_MEMBER_DEFAULT = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_CLASS_BODY_DECLARATIONS ) ; public final Prefix ENUM_BODY_START = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_COMPILATION_UNIT ) ; public final Prefix ENUM_BODY_END = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_COMPILATION_UNIT ) ; public final Prefix WILDCARD_EXTENDS = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_CLASS_BODY_DECLARATIONS ) ; public final Prefix WILDCARD_SUPER = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_CLASS_BODY_DECLARATIONS ) ; public final Prefix FIRST_ENUM_CONST = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_COMPILATION_UNIT ) ; public final Prefix ANNOTATION_SEPARATION = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_COMPILATION_UNIT ) ; public final Prefix PARAM_ANNOTATION_SEPARATION = new FormattingPrefix ( "<STR_LIT>" , "<STR_LIT>" , CodeFormatter . K_CLASS_BODY_DECLARATIONS ) ; public final BlockContext IF_BLOCK_WITH_ELSE = new BlockFormattingPrefixSuffix ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:8> ) ; public final BlockContext IF_BLOCK_NO_ELSE = new BlockFormattingPrefix ( "<STR_LIT>" , <NUM_LIT:8> ) ; public final BlockContext ELSE_AFTER_STATEMENT = new BlockFormattingPrefix ( "<STR_LIT>" , <NUM_LIT:15> ) ; public final BlockContext ELSE_AFTER_BLOCK = new BlockFormattingPrefix ( "<STR_LIT>" , <NUM_LIT:11> ) ; public final BlockContext FOR_BLOCK = new BlockFormattingPrefix ( "<STR_LIT>" , <NUM_LIT:7> ) ; public final BlockContext WHILE_BLOCK = new BlockFormattingPrefix ( "<STR_LIT>" , <NUM_LIT:11> ) ; public final BlockContext DO_BLOCK = new BlockFormattingPrefixSuffix ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:1> ) ; } </s>
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . ArrayList ; import java . util . List ; import org . eclipse . jdt . core . dom . ASTNode ; public class ListRewriteEvent extends RewriteEvent { public final static int NEW = <NUM_LIT:1> ; public final static int OLD = <NUM_LIT:2> ; public final static int BOTH = NEW | OLD ; private List originalNodes ; private List listEntries ; public ListRewriteEvent ( List originalNodes ) { this . originalNodes = new ArrayList ( originalNodes ) ; } public ListRewriteEvent ( RewriteEvent [ ] children ) { this . listEntries = new ArrayList ( children . length * <NUM_LIT:2> ) ; this . originalNodes = new ArrayList ( children . length * <NUM_LIT:2> ) ; for ( int i = <NUM_LIT:0> ; i < children . length ; i ++ ) { RewriteEvent curr = children [ i ] ; this . listEntries . add ( curr ) ; if ( curr . getOriginalValue ( ) != null ) { this . originalNodes . add ( curr . getOriginalValue ( ) ) ; } } } private List getEntries ( ) { if ( this . listEntries == null ) { int nNodes = this . originalNodes . size ( ) ; this . listEntries = new ArrayList ( nNodes * <NUM_LIT:2> ) ; for ( int i = <NUM_LIT:0> ; i < nNodes ; i ++ ) { ASTNode node = ( ASTNode ) this . originalNodes . get ( i ) ; this . listEntries . add ( new NodeRewriteEvent ( node , node ) ) ; } } return this . listEntries ; } public int getChangeKind ( ) { if ( this . listEntries != null ) { for ( int i = <NUM_LIT:0> ; i < this . listEntries . size ( ) ; i ++ ) { RewriteEvent curr = ( RewriteEvent ) this . listEntries . get ( i ) ; if ( curr . getChangeKind ( ) != UNCHANGED ) { return CHILDREN_CHANGED ; } } } return UNCHANGED ; } public boolean isListRewrite ( ) { return true ; } public RewriteEvent [ ] getChildren ( ) { List entries = getEntries ( ) ; return ( RewriteEvent [ ] ) entries . toArray ( new RewriteEvent [ entries . size ( ) ] ) ; } public Object getOriginalValue ( ) { return this . originalNodes ; } public Object getNewValue ( ) { List entries = getEntries ( ) ; ArrayList res = new ArrayList ( entries . size ( ) ) ; for ( int i = <NUM_LIT:0> ; i < entries . size ( ) ; i ++ ) { RewriteEvent curr = ( RewriteEvent ) entries . get ( i ) ; Object newVal = curr . getNewValue ( ) ; if ( newVal != null ) { res . add ( newVal ) ; } } return res ; } public RewriteEvent removeEntry ( ASTNode originalEntry ) { return replaceEntry ( originalEntry , null ) ; } public RewriteEvent replaceEntry ( ASTNode entry , ASTNode newEntry ) { if ( entry == null ) { throw new IllegalArgumentException ( ) ; } List entries = getEntries ( ) ; int nEntries = entries . size ( ) ; for ( int i = <NUM_LIT:0> ; i < nEntries ; i ++ ) { NodeRewriteEvent curr = ( NodeRewriteEvent ) entries . get ( i ) ; if ( curr . getOriginalValue ( ) == entry || curr . getNewValue ( ) == entry ) { curr . setNewValue ( newEntry ) ; if ( curr . getNewValue ( ) == null && curr . getOriginalValue ( ) == null ) { entries . remove ( i ) ; return null ; } return curr ; } } return null ; } public void revertChange ( NodeRewriteEvent event ) { Object originalValue = event . getOriginalValue ( ) ; if ( originalValue == null ) { List entries = getEntries ( ) ; entries . remove ( event ) ; } else { event . setNewValue ( originalValue ) ; } } public int getIndex ( ASTNode node , int kind ) { List entries = getEntries ( ) ; for ( int i = entries . size ( ) - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { RewriteEvent curr = ( RewriteEvent ) entries . get ( i ) ; if ( ( ( kind & OLD ) != <NUM_LIT:0> ) && ( curr . getOriginalValue ( ) == node ) ) { return i ; } if ( ( ( kind & NEW ) != <NUM_LIT:0> ) && ( curr . getNewValue ( ) == node ) ) { return i ; } } return - <NUM_LIT:1> ; } public RewriteEvent insert ( ASTNode insertedNode , int insertIndex ) { NodeRewriteEvent change = new NodeRewriteEvent ( null , insertedNode ) ; if ( insertIndex != - <NUM_LIT:1> ) { getEntries ( ) . add ( insertIndex , change ) ; } else { getEntries ( ) . add ( change ) ; } return change ; } public void setNewValue ( ASTNode newValue , int insertIndex ) { NodeRewriteEvent curr = ( NodeRewriteEvent ) getEntries ( ) . get ( insertIndex ) ; curr . setNewValue ( newValue ) ; } public int getChangeKind ( int index ) { return ( ( NodeRewriteEvent ) getEntries ( ) . get ( index ) ) . getChangeKind ( ) ; } public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; buf . append ( "<STR_LIT>" ) ; RewriteEvent [ ] events = getChildren ( ) ; for ( int i = <NUM_LIT:0> ; i < events . length ; i ++ ) { if ( i != <NUM_LIT:0> ) { buf . append ( "<STR_LIT>" ) ; } buf . append ( events [ i ] ) ; } buf . append ( "<STR_LIT>" ) ; return buf . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . core . runtime . Status ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; public class TokenScanner { public static final int END_OF_FILE = <NUM_LIT> ; public static final int LEXICAL_ERROR = <NUM_LIT> ; public static final int DOCUMENT_ERROR = <NUM_LIT> ; private final Scanner scanner ; private final int endPosition ; public TokenScanner ( Scanner scanner ) { this . scanner = scanner ; this . endPosition = this . scanner . getSource ( ) . length - <NUM_LIT:1> ; } public Scanner getScanner ( ) { return this . scanner ; } public void setOffset ( int offset ) { this . scanner . resetTo ( offset , this . endPosition ) ; } public int getCurrentEndOffset ( ) { return this . scanner . getCurrentTokenEndPosition ( ) + <NUM_LIT:1> ; } public int getCurrentStartOffset ( ) { return this . scanner . getCurrentTokenStartPosition ( ) ; } public int getCurrentLength ( ) { return getCurrentEndOffset ( ) - getCurrentStartOffset ( ) ; } public int readNext ( boolean ignoreComments ) throws CoreException { int curr = <NUM_LIT:0> ; do { try { curr = this . scanner . getNextToken ( ) ; if ( curr == TerminalTokens . TokenNameEOF ) { throw new CoreException ( createError ( END_OF_FILE , "<STR_LIT>" , null ) ) ; } } catch ( InvalidInputException e ) { throw new CoreException ( createError ( LEXICAL_ERROR , e . getMessage ( ) , e ) ) ; } } while ( ignoreComments && isComment ( curr ) ) ; return curr ; } public int readNext ( int offset , boolean ignoreComments ) throws CoreException { setOffset ( offset ) ; return readNext ( ignoreComments ) ; } public int getNextStartOffset ( int offset , boolean ignoreComments ) throws CoreException { readNext ( offset , ignoreComments ) ; return getCurrentStartOffset ( ) ; } public int getNextEndOffset ( int offset , boolean ignoreComments ) throws CoreException { readNext ( offset , ignoreComments ) ; return getCurrentEndOffset ( ) ; } public void readToToken ( int tok ) throws CoreException { int curr = <NUM_LIT:0> ; do { curr = readNext ( false ) ; } while ( curr != tok ) ; } public void readToToken ( int tok , int offset ) throws CoreException { setOffset ( offset ) ; readToToken ( tok ) ; } public int getTokenStartOffset ( int token , int startOffset ) throws CoreException { readToToken ( token , startOffset ) ; return getCurrentStartOffset ( ) ; } public int getTokenEndOffset ( int token , int startOffset ) throws CoreException { readToToken ( token , startOffset ) ; return getCurrentEndOffset ( ) ; } public int getPreviousTokenEndOffset ( int token , int startOffset ) throws CoreException { setOffset ( startOffset ) ; int res = startOffset ; int curr = readNext ( false ) ; while ( curr != token ) { res = getCurrentEndOffset ( ) ; curr = readNext ( false ) ; } return res ; } public static boolean isComment ( int token ) { return token == TerminalTokens . TokenNameCOMMENT_BLOCK || token == TerminalTokens . TokenNameCOMMENT_JAVADOC || token == TerminalTokens . TokenNameCOMMENT_LINE ; } public static boolean isModifier ( int token ) { switch ( token ) { case TerminalTokens . TokenNamepublic : case TerminalTokens . TokenNameprotected : case TerminalTokens . TokenNameprivate : case TerminalTokens . TokenNamestatic : case TerminalTokens . TokenNamefinal : case TerminalTokens . TokenNameabstract : case TerminalTokens . TokenNamenative : case TerminalTokens . TokenNamevolatile : case TerminalTokens . TokenNamestrictfp : case TerminalTokens . TokenNametransient : case TerminalTokens . TokenNamesynchronized : return true ; default : return false ; } } public static IStatus createError ( int code , String message , Throwable throwable ) { return new Status ( IStatus . ERROR , JavaCore . PLUGIN_ID , code , message , throwable ) ; } } </s>
<s> package org . eclipse . jdt . internal . core . dom ; import java . util . Iterator ; import java . util . List ; import org . eclipse . jdt . core . dom . AST ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . ASTVisitor ; import org . eclipse . jdt . core . dom . AbstractTypeDeclaration ; import org . eclipse . jdt . core . dom . Annotation ; import org . eclipse . jdt . core . dom . AnnotationTypeDeclaration ; import org . eclipse . jdt . core . dom . AnnotationTypeMemberDeclaration ; import org . eclipse . jdt . core . dom . AnonymousClassDeclaration ; import org . eclipse . jdt . core . dom . ArrayAccess ; import org . eclipse . jdt . core . dom . ArrayCreation ; import org . eclipse . jdt . core . dom . ArrayInitializer ; import org . eclipse . jdt . core . dom . ArrayType ; import org . eclipse . jdt . core . dom . AssertStatement ; import org . eclipse . jdt . core . dom . Assignment ; import org . eclipse . jdt . core . dom . Block ; import org . eclipse . jdt . core . dom . BlockComment ; import org . eclipse . jdt . core . dom . BodyDeclaration ; import org . eclipse . jdt . core . dom . BooleanLiteral ; import org . eclipse . jdt . core . dom . BreakStatement ; import org . eclipse . jdt . core . dom . CastExpression ; import org . eclipse . jdt . core . dom . CatchClause ; import org . eclipse . jdt . core . dom . CharacterLiteral ; import org . eclipse . jdt . core . dom . ClassInstanceCreation ; import org . eclipse . jdt . core . dom . CompilationUnit ; import org . eclipse . jdt . core . dom . ConditionalExpression ; import org . eclipse . jdt . core . dom . ConstructorInvocation ; import org . eclipse . jdt . core . dom . ContinueStatement ; import org . eclipse . jdt . core . dom . DoStatement ; import org . eclipse . jdt . core . dom . EmptyStatement ; import org . eclipse . jdt . core . dom . EnhancedForStatement ; import org . eclipse . jdt . core . dom . EnumConstantDeclaration ; import org . eclipse . jdt . core . dom . EnumDeclaration ; import org . eclipse . jdt . core . dom . Expression ; import org . eclipse . jdt . core . dom . ExpressionStatement ; import org . eclipse . jdt . core . dom . FieldAccess ; import org . eclipse . jdt . core . dom . FieldDeclaration ; import org . eclipse . jdt . core . dom . ForStatement ; import org . eclipse . jdt . core . dom . IfStatement ; import org . eclipse . jdt . core . dom . ImportDeclaration ; import org . eclipse . jdt . core . dom . InfixExpression ; import org . eclipse . jdt . core . dom . Initializer ; import org . eclipse . jdt . core . dom . InstanceofExpression ; import org . eclipse . jdt . core . dom . Javadoc ; import org . eclipse . jdt . core . dom . LabeledStatement ; import org . eclipse . jdt . core . dom . LineComment ; import org . eclipse . jdt . core . dom . MarkerAnnotation ; import org . eclipse . jdt . core . dom . MemberRef ; import org . eclipse . jdt . core . dom . MemberValuePair ; import org . eclipse . jdt . core . dom . MethodDeclaration ; import org . eclipse . jdt . core . dom . MethodInvocation ; import org . eclipse . jdt . core . dom . MethodRef ; import org . eclipse . jdt . core . dom . MethodRefParameter ; import org . eclipse . jdt . core . dom . Modifier ; import org . eclipse . jdt . core . dom . Name ; import org . eclipse . jdt . core . dom . NormalAnnotation ; import org . eclipse . jdt . core . dom . NullLiteral ; import org . eclipse . jdt . core . dom . NumberLiteral ; import org . eclipse . jdt . core . dom . PackageDeclaration ; import org . eclipse . jdt . core . dom . ParameterizedType ; import org . eclipse . jdt . core . dom . ParenthesizedExpression ; import org . eclipse . jdt . core . dom . PostfixExpression ; import org . eclipse . jdt . core . dom . PrefixExpression ; import org . eclipse . jdt . core . dom . PrimitiveType ; import org . eclipse . jdt . core . dom . QualifiedName ; import org . eclipse . jdt . core . dom . QualifiedType ; import org . eclipse . jdt . core . dom . ReturnStatement ; import org . eclipse . jdt . core . dom . SimpleName ; import org . eclipse . jdt . core . dom . SimpleType ; import org . eclipse . jdt . core . dom . SingleMemberAnnotation ; import org . eclipse . jdt . core . dom . SingleVariableDeclaration ; import org . eclipse . jdt . core . dom . Statement ; import org . eclipse . jdt . core . dom . StringLiteral ; import org . eclipse . jdt . core . dom . SuperConstructorInvocation ; import org . eclipse . jdt . core . dom . SuperFieldAccess ; import org . eclipse . jdt . core . dom . SuperMethodInvocation ; import org . eclipse . jdt . core . dom . SwitchCase ; import org . eclipse . jdt . core . dom . SwitchStatement ; import org . eclipse . jdt . core . dom . SynchronizedStatement ; import org . eclipse . jdt . core . dom . TagElement ; import org . eclipse . jdt . core . dom . TextElement ; import org . eclipse . jdt . core . dom . ThisExpression ; import org . eclipse . jdt . core . dom . ThrowStatement ; import org . eclipse . jdt . core . dom . TryStatement ; import org . eclipse . jdt . core . dom . Type ; import org . eclipse . jdt . core . dom . TypeDeclaration ; import org . eclipse . jdt . core . dom . TypeDeclarationStatement ; import org . eclipse . jdt . core . dom . TypeLiteral ; import org . eclipse . jdt . core . dom . TypeParameter ; import org . eclipse . jdt . core . dom . VariableDeclarationExpression ; import org . eclipse . jdt . core . dom . VariableDeclarationFragment ; import org . eclipse . jdt . core . dom . VariableDeclarationStatement ; import org . eclipse . jdt . core . dom . WhileStatement ; import org . eclipse . jdt . core . dom . WildcardType ; public class NaiveASTFlattener extends ASTVisitor { private static final int JLS2 = AST . JLS2 ; protected StringBuffer buffer ; private int indent = <NUM_LIT:0> ; public NaiveASTFlattener ( ) { this . buffer = new StringBuffer ( ) ; } private Name getName ( ClassInstanceCreation node ) { return node . getName ( ) ; } public String getResult ( ) { return this . buffer . toString ( ) ; } private Type getReturnType ( MethodDeclaration node ) { return node . getReturnType ( ) ; } private Name getSuperclass ( TypeDeclaration node ) { return node . getSuperclass ( ) ; } private TypeDeclaration getTypeDeclaration ( TypeDeclarationStatement node ) { return node . getTypeDeclaration ( ) ; } void printIndent ( ) { for ( int i = <NUM_LIT:0> ; i < this . indent ; i ++ ) this . buffer . append ( "<STR_LIT:U+0020U+0020>" ) ; } void printModifiers ( int modifiers ) { if ( Modifier . isPublic ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isProtected ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isPrivate ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isStatic ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isAbstract ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isFinal ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isSynchronized ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isVolatile ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isNative ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isStrictfp ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } if ( Modifier . isTransient ( modifiers ) ) { this . buffer . append ( "<STR_LIT>" ) ; } } void printModifiers ( List ext ) { for ( Iterator it = ext . iterator ( ) ; it . hasNext ( ) ; ) { ASTNode p = ( ASTNode ) it . next ( ) ; p . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; } } public void reset ( ) { this . buffer . setLength ( <NUM_LIT:0> ) ; } private List superInterfaces ( TypeDeclaration node ) { return node . superInterfaces ( ) ; } public boolean visit ( AnnotationTypeDeclaration node ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } printIndent ( ) ; printModifiers ( node . modifiers ( ) ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; for ( Iterator it = node . bodyDeclarations ( ) . iterator ( ) ; it . hasNext ( ) ; ) { BodyDeclaration d = ( BodyDeclaration ) it . next ( ) ; d . accept ( this ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( AnnotationTypeMemberDeclaration node ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } printIndent ( ) ; printModifiers ( node . modifiers ( ) ) ; node . getType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; if ( node . getDefault ( ) != null ) { this . buffer . append ( "<STR_LIT>" ) ; node . getDefault ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( AnonymousClassDeclaration node ) { this . buffer . append ( "<STR_LIT>" ) ; this . indent ++ ; for ( Iterator it = node . bodyDeclarations ( ) . iterator ( ) ; it . hasNext ( ) ; ) { BodyDeclaration b = ( BodyDeclaration ) it . next ( ) ; b . accept ( this ) ; } this . indent -- ; printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( ArrayAccess node ) { node . getArray ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:[>" ) ; node . getIndex ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:]>" ) ; return false ; } public boolean visit ( ArrayCreation node ) { this . buffer . append ( "<STR_LIT>" ) ; ArrayType at = node . getType ( ) ; int dims = at . getDimensions ( ) ; Type elementType = at . getElementType ( ) ; elementType . accept ( this ) ; for ( Iterator it = node . dimensions ( ) . iterator ( ) ; it . hasNext ( ) ; ) { this . buffer . append ( "<STR_LIT:[>" ) ; Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; this . buffer . append ( "<STR_LIT:]>" ) ; dims -- ; } for ( int i = <NUM_LIT:0> ; i < dims ; i ++ ) { this . buffer . append ( "<STR_LIT:[]>" ) ; } if ( node . getInitializer ( ) != null ) { node . getInitializer ( ) . accept ( this ) ; } return false ; } public boolean visit ( ArrayInitializer node ) { this . buffer . append ( "<STR_LIT:{>" ) ; for ( Iterator it = node . expressions ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:}>" ) ; return false ; } public boolean visit ( ArrayType node ) { node . getComponentType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:[]>" ) ; return false ; } public boolean visit ( AssertStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getExpression ( ) . accept ( this ) ; if ( node . getMessage ( ) != null ) { this . buffer . append ( "<STR_LIT:U+0020:U+0020>" ) ; node . getMessage ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( Assignment node ) { node . getLeftHandSide ( ) . accept ( this ) ; this . buffer . append ( node . getOperator ( ) . toString ( ) ) ; node . getRightHandSide ( ) . accept ( this ) ; return false ; } public boolean visit ( Block node ) { this . buffer . append ( "<STR_LIT>" ) ; this . indent ++ ; for ( Iterator it = node . statements ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Statement s = ( Statement ) it . next ( ) ; s . accept ( this ) ; } this . indent -- ; printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( BlockComment node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( BooleanLiteral node ) { if ( node . booleanValue ( ) == true ) { this . buffer . append ( "<STR_LIT:true>" ) ; } else { this . buffer . append ( "<STR_LIT:false>" ) ; } return false ; } public boolean visit ( BreakStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; if ( node . getLabel ( ) != null ) { this . buffer . append ( "<STR_LIT:U+0020>" ) ; node . getLabel ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( CastExpression node ) { this . buffer . append ( "<STR_LIT:(>" ) ; node . getType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:)>" ) ; node . getExpression ( ) . accept ( this ) ; return false ; } public boolean visit ( CatchClause node ) { this . buffer . append ( "<STR_LIT>" ) ; node . getException ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getBody ( ) . accept ( this ) ; return false ; } public boolean visit ( CharacterLiteral node ) { this . buffer . append ( node . getEscapedValue ( ) ) ; return false ; } public boolean visit ( ClassInstanceCreation node ) { if ( node . getExpression ( ) != null ) { node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; } this . buffer . append ( "<STR_LIT>" ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { getName ( node ) . accept ( this ) ; } if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { if ( ! node . typeArguments ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:<>" ) ; for ( Iterator it = node . typeArguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:>>" ) ; } node . getType ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT:(>" ) ; for ( Iterator it = node . arguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:)>" ) ; if ( node . getAnonymousClassDeclaration ( ) != null ) { node . getAnonymousClassDeclaration ( ) . accept ( this ) ; } return false ; } public boolean visit ( CompilationUnit node ) { if ( node . getPackage ( ) != null ) { node . getPackage ( ) . accept ( this ) ; } for ( Iterator it = node . imports ( ) . iterator ( ) ; it . hasNext ( ) ; ) { ImportDeclaration d = ( ImportDeclaration ) it . next ( ) ; d . accept ( this ) ; } for ( Iterator it = node . types ( ) . iterator ( ) ; it . hasNext ( ) ; ) { AbstractTypeDeclaration d = ( AbstractTypeDeclaration ) it . next ( ) ; d . accept ( this ) ; } return false ; } public boolean visit ( ConditionalExpression node ) { node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getThenExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020:U+0020>" ) ; node . getElseExpression ( ) . accept ( this ) ; return false ; } public boolean visit ( ConstructorInvocation node ) { printIndent ( ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { if ( ! node . typeArguments ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:<>" ) ; for ( Iterator it = node . typeArguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:>>" ) ; } } this . buffer . append ( "<STR_LIT>" ) ; for ( Iterator it = node . arguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( ContinueStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; if ( node . getLabel ( ) != null ) { this . buffer . append ( "<STR_LIT:U+0020>" ) ; node . getLabel ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( DoStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getBody ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( EmptyStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( EnhancedForStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getParameter ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020:U+0020>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getBody ( ) . accept ( this ) ; return false ; } public boolean visit ( EnumConstantDeclaration node ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } printIndent ( ) ; printModifiers ( node . modifiers ( ) ) ; node . getName ( ) . accept ( this ) ; if ( ! node . arguments ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:(>" ) ; for ( Iterator it = node . arguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:)>" ) ; } if ( node . getAnonymousClassDeclaration ( ) != null ) { node . getAnonymousClassDeclaration ( ) . accept ( this ) ; } return false ; } public boolean visit ( EnumDeclaration node ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } printIndent ( ) ; printModifiers ( node . modifiers ( ) ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; if ( ! node . superInterfaceTypes ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT>" ) ; for ( Iterator it = node . superInterfaceTypes ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } } this . buffer . append ( "<STR_LIT:U+0020>" ) ; } this . buffer . append ( "<STR_LIT:{>" ) ; for ( Iterator it = node . enumConstants ( ) . iterator ( ) ; it . hasNext ( ) ; ) { EnumConstantDeclaration d = ( EnumConstantDeclaration ) it . next ( ) ; d . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } } if ( ! node . bodyDeclarations ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:;U+0020>" ) ; for ( Iterator it = node . bodyDeclarations ( ) . iterator ( ) ; it . hasNext ( ) ; ) { BodyDeclaration d = ( BodyDeclaration ) it . next ( ) ; d . accept ( this ) ; } } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( ExpressionStatement node ) { printIndent ( ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( FieldAccess node ) { node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; node . getName ( ) . accept ( this ) ; return false ; } public boolean visit ( FieldDeclaration node ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } printIndent ( ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { printModifiers ( node . getModifiers ( ) ) ; } if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { printModifiers ( node . modifiers ( ) ) ; } node . getType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; for ( Iterator it = node . fragments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { VariableDeclarationFragment f = ( VariableDeclarationFragment ) it . next ( ) ; f . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( ForStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; for ( Iterator it = node . initializers ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } this . buffer . append ( "<STR_LIT:;U+0020>" ) ; if ( node . getExpression ( ) != null ) { node . getExpression ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT:;U+0020>" ) ; for ( Iterator it = node . updaters ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } this . buffer . append ( "<STR_LIT>" ) ; node . getBody ( ) . accept ( this ) ; return false ; } public boolean visit ( IfStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getThenStatement ( ) . accept ( this ) ; if ( node . getElseStatement ( ) != null ) { this . buffer . append ( "<STR_LIT>" ) ; node . getElseStatement ( ) . accept ( this ) ; } return false ; } public boolean visit ( ImportDeclaration node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { if ( node . isStatic ( ) ) { this . buffer . append ( "<STR_LIT>" ) ; } } node . getName ( ) . accept ( this ) ; if ( node . isOnDemand ( ) ) { this . buffer . append ( "<STR_LIT>" ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( InfixExpression node ) { node . getLeftOperand ( ) . accept ( this ) ; this . buffer . append ( '<CHAR_LIT:U+0020>' ) ; this . buffer . append ( node . getOperator ( ) . toString ( ) ) ; this . buffer . append ( '<CHAR_LIT:U+0020>' ) ; node . getRightOperand ( ) . accept ( this ) ; final List extendedOperands = node . extendedOperands ( ) ; if ( extendedOperands . size ( ) != <NUM_LIT:0> ) { this . buffer . append ( '<CHAR_LIT:U+0020>' ) ; for ( Iterator it = extendedOperands . iterator ( ) ; it . hasNext ( ) ; ) { this . buffer . append ( node . getOperator ( ) . toString ( ) ) . append ( '<CHAR_LIT:U+0020>' ) ; Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; } } return false ; } public boolean visit ( Initializer node ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { printModifiers ( node . getModifiers ( ) ) ; } if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { printModifiers ( node . modifiers ( ) ) ; } node . getBody ( ) . accept ( this ) ; return false ; } public boolean visit ( InstanceofExpression node ) { node . getLeftOperand ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getRightOperand ( ) . accept ( this ) ; return false ; } public boolean visit ( Javadoc node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; for ( Iterator it = node . tags ( ) . iterator ( ) ; it . hasNext ( ) ; ) { ASTNode e = ( ASTNode ) it . next ( ) ; e . accept ( this ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( LabeledStatement node ) { printIndent ( ) ; node . getLabel ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT::U+0020>" ) ; node . getBody ( ) . accept ( this ) ; return false ; } public boolean visit ( LineComment node ) { this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( MarkerAnnotation node ) { this . buffer . append ( "<STR_LIT:@>" ) ; node . getTypeName ( ) . accept ( this ) ; return false ; } public boolean visit ( MemberRef node ) { if ( node . getQualifier ( ) != null ) { node . getQualifier ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT:#>" ) ; node . getName ( ) . accept ( this ) ; return false ; } public boolean visit ( MemberValuePair node ) { node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:=>" ) ; node . getValue ( ) . accept ( this ) ; return false ; } public boolean visit ( MethodDeclaration node ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } printIndent ( ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { printModifiers ( node . getModifiers ( ) ) ; } if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { printModifiers ( node . modifiers ( ) ) ; if ( ! node . typeParameters ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:<>" ) ; for ( Iterator it = node . typeParameters ( ) . iterator ( ) ; it . hasNext ( ) ; ) { TypeParameter t = ( TypeParameter ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:>>" ) ; } } if ( ! node . isConstructor ( ) ) { if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { getReturnType ( node ) . accept ( this ) ; } else { if ( node . getReturnType2 ( ) != null ) { node . getReturnType2 ( ) . accept ( this ) ; } else { this . buffer . append ( "<STR_LIT>" ) ; } } this . buffer . append ( "<STR_LIT:U+0020>" ) ; } node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:(>" ) ; for ( Iterator it = node . parameters ( ) . iterator ( ) ; it . hasNext ( ) ; ) { SingleVariableDeclaration v = ( SingleVariableDeclaration ) it . next ( ) ; v . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:)>" ) ; for ( int i = <NUM_LIT:0> ; i < node . getExtraDimensions ( ) ; i ++ ) { this . buffer . append ( "<STR_LIT:[]>" ) ; } if ( ! node . thrownExceptions ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT>" ) ; for ( Iterator it = node . thrownExceptions ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Name n = ( Name ) it . next ( ) ; n . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } } this . buffer . append ( "<STR_LIT:U+0020>" ) ; } if ( node . getBody ( ) == null ) { this . buffer . append ( "<STR_LIT>" ) ; } else { node . getBody ( ) . accept ( this ) ; } return false ; } public boolean visit ( MethodInvocation node ) { if ( node . getExpression ( ) != null ) { node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; } if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { if ( ! node . typeArguments ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:<>" ) ; for ( Iterator it = node . typeArguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:>>" ) ; } } node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:(>" ) ; for ( Iterator it = node . arguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:)>" ) ; return false ; } public boolean visit ( MethodRef node ) { if ( node . getQualifier ( ) != null ) { node . getQualifier ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT:#>" ) ; node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:(>" ) ; for ( Iterator it = node . parameters ( ) . iterator ( ) ; it . hasNext ( ) ; ) { MethodRefParameter e = ( MethodRefParameter ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:)>" ) ; return false ; } public boolean visit ( MethodRefParameter node ) { node . getType ( ) . accept ( this ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { if ( node . isVarargs ( ) ) { this . buffer . append ( "<STR_LIT:...>" ) ; } } if ( node . getName ( ) != null ) { this . buffer . append ( "<STR_LIT:U+0020>" ) ; node . getName ( ) . accept ( this ) ; } return false ; } public boolean visit ( Modifier node ) { this . buffer . append ( node . getKeyword ( ) . toString ( ) ) ; return false ; } public boolean visit ( NormalAnnotation node ) { this . buffer . append ( "<STR_LIT:@>" ) ; node . getTypeName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:(>" ) ; for ( Iterator it = node . values ( ) . iterator ( ) ; it . hasNext ( ) ; ) { MemberValuePair p = ( MemberValuePair ) it . next ( ) ; p . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:)>" ) ; return false ; } public boolean visit ( NullLiteral node ) { this . buffer . append ( "<STR_LIT:null>" ) ; return false ; } public boolean visit ( NumberLiteral node ) { this . buffer . append ( node . getToken ( ) ) ; return false ; } public boolean visit ( PackageDeclaration node ) { if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } for ( Iterator it = node . annotations ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Annotation p = ( Annotation ) it . next ( ) ; p . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; } } printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( ParameterizedType node ) { node . getType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:<>" ) ; for ( Iterator it = node . typeArguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:>>" ) ; return false ; } public boolean visit ( ParenthesizedExpression node ) { this . buffer . append ( "<STR_LIT:(>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:)>" ) ; return false ; } public boolean visit ( PostfixExpression node ) { node . getOperand ( ) . accept ( this ) ; this . buffer . append ( node . getOperator ( ) . toString ( ) ) ; return false ; } public boolean visit ( PrefixExpression node ) { this . buffer . append ( node . getOperator ( ) . toString ( ) ) ; node . getOperand ( ) . accept ( this ) ; return false ; } public boolean visit ( PrimitiveType node ) { this . buffer . append ( node . getPrimitiveTypeCode ( ) . toString ( ) ) ; return false ; } public boolean visit ( QualifiedName node ) { node . getQualifier ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; node . getName ( ) . accept ( this ) ; return false ; } public boolean visit ( QualifiedType node ) { node . getQualifier ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; node . getName ( ) . accept ( this ) ; return false ; } public boolean visit ( ReturnStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; if ( node . getExpression ( ) != null ) { this . buffer . append ( "<STR_LIT:U+0020>" ) ; node . getExpression ( ) . accept ( this ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( SimpleName node ) { this . buffer . append ( node . getIdentifier ( ) ) ; return false ; } public boolean visit ( SimpleType node ) { return true ; } public boolean visit ( SingleMemberAnnotation node ) { this . buffer . append ( "<STR_LIT:@>" ) ; node . getTypeName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:(>" ) ; node . getValue ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:)>" ) ; return false ; } public boolean visit ( SingleVariableDeclaration node ) { printIndent ( ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { printModifiers ( node . getModifiers ( ) ) ; } if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { printModifiers ( node . modifiers ( ) ) ; } node . getType ( ) . accept ( this ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { if ( node . isVarargs ( ) ) { this . buffer . append ( "<STR_LIT:...>" ) ; } } this . buffer . append ( "<STR_LIT:U+0020>" ) ; node . getName ( ) . accept ( this ) ; for ( int i = <NUM_LIT:0> ; i < node . getExtraDimensions ( ) ; i ++ ) { this . buffer . append ( "<STR_LIT:[]>" ) ; } if ( node . getInitializer ( ) != null ) { this . buffer . append ( "<STR_LIT:=>" ) ; node . getInitializer ( ) . accept ( this ) ; } return false ; } public boolean visit ( StringLiteral node ) { this . buffer . append ( node . getEscapedValue ( ) ) ; return false ; } public boolean visit ( SuperConstructorInvocation node ) { printIndent ( ) ; if ( node . getExpression ( ) != null ) { node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; } if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { if ( ! node . typeArguments ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:<>" ) ; for ( Iterator it = node . typeArguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:>>" ) ; } } this . buffer . append ( "<STR_LIT>" ) ; for ( Iterator it = node . arguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( SuperFieldAccess node ) { if ( node . getQualifier ( ) != null ) { node . getQualifier ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; } this . buffer . append ( "<STR_LIT>" ) ; node . getName ( ) . accept ( this ) ; return false ; } public boolean visit ( SuperMethodInvocation node ) { if ( node . getQualifier ( ) != null ) { node . getQualifier ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; } this . buffer . append ( "<STR_LIT>" ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { if ( ! node . typeArguments ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:<>" ) ; for ( Iterator it = node . typeArguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:>>" ) ; } } node . getName ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:(>" ) ; for ( Iterator it = node . arguments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Expression e = ( Expression ) it . next ( ) ; e . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:)>" ) ; return false ; } public boolean visit ( SwitchCase node ) { if ( node . isDefault ( ) ) { this . buffer . append ( "<STR_LIT>" ) ; } else { this . buffer . append ( "<STR_LIT>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; } this . indent ++ ; return false ; } public boolean visit ( SwitchStatement node ) { this . buffer . append ( "<STR_LIT>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; this . buffer . append ( "<STR_LIT>" ) ; this . indent ++ ; for ( Iterator it = node . statements ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Statement s = ( Statement ) it . next ( ) ; s . accept ( this ) ; this . indent -- ; } this . indent -- ; printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( SynchronizedStatement node ) { this . buffer . append ( "<STR_LIT>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getBody ( ) . accept ( this ) ; return false ; } public boolean visit ( TagElement node ) { if ( node . isNested ( ) ) { this . buffer . append ( "<STR_LIT:{>" ) ; } else { this . buffer . append ( "<STR_LIT>" ) ; } boolean previousRequiresWhiteSpace = false ; if ( node . getTagName ( ) != null ) { this . buffer . append ( node . getTagName ( ) ) ; previousRequiresWhiteSpace = true ; } boolean previousRequiresNewLine = false ; for ( Iterator it = node . fragments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { ASTNode e = ( ASTNode ) it . next ( ) ; boolean currentIncludesWhiteSpace = ( e instanceof TextElement ) ; if ( previousRequiresNewLine && currentIncludesWhiteSpace ) { this . buffer . append ( "<STR_LIT>" ) ; } previousRequiresNewLine = currentIncludesWhiteSpace ; if ( previousRequiresWhiteSpace && ! currentIncludesWhiteSpace ) { this . buffer . append ( "<STR_LIT:U+0020>" ) ; } e . accept ( this ) ; previousRequiresWhiteSpace = ! currentIncludesWhiteSpace && ! ( e instanceof TagElement ) ; } if ( node . isNested ( ) ) { this . buffer . append ( "<STR_LIT:}>" ) ; } return false ; } public boolean visit ( TextElement node ) { this . buffer . append ( node . getText ( ) ) ; return false ; } public boolean visit ( ThisExpression node ) { if ( node . getQualifier ( ) != null ) { node . getQualifier ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.>" ) ; } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( ThrowStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( TryStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getBody ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; for ( Iterator it = node . catchClauses ( ) . iterator ( ) ; it . hasNext ( ) ; ) { CatchClause cc = ( CatchClause ) it . next ( ) ; cc . accept ( this ) ; } if ( node . getFinally ( ) != null ) { this . buffer . append ( "<STR_LIT>" ) ; node . getFinally ( ) . accept ( this ) ; } return false ; } public boolean visit ( TypeDeclaration node ) { if ( node . getJavadoc ( ) != null ) { node . getJavadoc ( ) . accept ( this ) ; } if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { printModifiers ( node . getModifiers ( ) ) ; } if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { printModifiers ( node . modifiers ( ) ) ; } this . buffer . append ( node . isInterface ( ) ? "<STR_LIT>" : "<STR_LIT>" ) ; node . getName ( ) . accept ( this ) ; if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { if ( ! node . typeParameters ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT:<>" ) ; for ( Iterator it = node . typeParameters ( ) . iterator ( ) ; it . hasNext ( ) ; ) { TypeParameter t = ( TypeParameter ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002C>" ) ; } } this . buffer . append ( "<STR_LIT:>>" ) ; } } this . buffer . append ( "<STR_LIT:U+0020>" ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { if ( getSuperclass ( node ) != null ) { this . buffer . append ( "<STR_LIT>" ) ; getSuperclass ( node ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; } if ( ! superInterfaces ( node ) . isEmpty ( ) ) { this . buffer . append ( node . isInterface ( ) ? "<STR_LIT>" : "<STR_LIT>" ) ; for ( Iterator it = superInterfaces ( node ) . iterator ( ) ; it . hasNext ( ) ; ) { Name n = ( Name ) it . next ( ) ; n . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } } this . buffer . append ( "<STR_LIT:U+0020>" ) ; } } if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { if ( node . getSuperclassType ( ) != null ) { this . buffer . append ( "<STR_LIT>" ) ; node . getSuperclassType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; } if ( ! node . superInterfaceTypes ( ) . isEmpty ( ) ) { this . buffer . append ( node . isInterface ( ) ? "<STR_LIT>" : "<STR_LIT>" ) ; for ( Iterator it = node . superInterfaceTypes ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } } this . buffer . append ( "<STR_LIT:U+0020>" ) ; } } this . buffer . append ( "<STR_LIT>" ) ; this . indent ++ ; for ( Iterator it = node . bodyDeclarations ( ) . iterator ( ) ; it . hasNext ( ) ; ) { BodyDeclaration d = ( BodyDeclaration ) it . next ( ) ; d . accept ( this ) ; } this . indent -- ; printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( TypeDeclarationStatement node ) { if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { getTypeDeclaration ( node ) . accept ( this ) ; } if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { node . getDeclaration ( ) . accept ( this ) ; } return false ; } public boolean visit ( TypeLiteral node ) { node . getType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:.class>" ) ; return false ; } public boolean visit ( TypeParameter node ) { node . getName ( ) . accept ( this ) ; if ( ! node . typeBounds ( ) . isEmpty ( ) ) { this . buffer . append ( "<STR_LIT>" ) ; for ( Iterator it = node . typeBounds ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Type t = ( Type ) it . next ( ) ; t . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT>" ) ; } } } return false ; } public boolean visit ( VariableDeclarationExpression node ) { if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { printModifiers ( node . getModifiers ( ) ) ; } if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { printModifiers ( node . modifiers ( ) ) ; } node . getType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; for ( Iterator it = node . fragments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { VariableDeclarationFragment f = ( VariableDeclarationFragment ) it . next ( ) ; f . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } } return false ; } public boolean visit ( VariableDeclarationFragment node ) { node . getName ( ) . accept ( this ) ; for ( int i = <NUM_LIT:0> ; i < node . getExtraDimensions ( ) ; i ++ ) { this . buffer . append ( "<STR_LIT:[]>" ) ; } if ( node . getInitializer ( ) != null ) { this . buffer . append ( "<STR_LIT:=>" ) ; node . getInitializer ( ) . accept ( this ) ; } return false ; } public boolean visit ( VariableDeclarationStatement node ) { printIndent ( ) ; if ( node . getAST ( ) . apiLevel ( ) == JLS2 ) { printModifiers ( node . getModifiers ( ) ) ; } if ( node . getAST ( ) . apiLevel ( ) >= AST . JLS3 ) { printModifiers ( node . modifiers ( ) ) ; } node . getType ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT:U+0020>" ) ; for ( Iterator it = node . fragments ( ) . iterator ( ) ; it . hasNext ( ) ; ) { VariableDeclarationFragment f = ( VariableDeclarationFragment ) it . next ( ) ; f . accept ( this ) ; if ( it . hasNext ( ) ) { this . buffer . append ( "<STR_LIT:U+002CU+0020>" ) ; } } this . buffer . append ( "<STR_LIT>" ) ; return false ; } public boolean visit ( WhileStatement node ) { printIndent ( ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getExpression ( ) . accept ( this ) ; this . buffer . append ( "<STR_LIT>" ) ; node . getBody ( ) . accept ( this ) ; return false ; } public boolean visit ( WildcardType node ) { this . buffer . append ( "<STR_LIT:?>" ) ; Type bound = node . getBound ( ) ; if ( bound != null ) { if ( node . isUpperBound ( ) ) { this . buffer . append ( "<STR_LIT>" ) ; } else { this . buffer . append ( "<STR_LIT>" ) ; } bound . accept ( this ) ; } return false ; } } </s>
<s> package org . eclipse . jdt . internal . core . index ; import org . eclipse . jdt . core . search . * ; import org . eclipse . jdt . internal . core . util . * ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObject ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; import org . eclipse . jdt . internal . compiler . util . SimpleSet ; public class MemoryIndex { public int NUM_CHANGES = <NUM_LIT:100> ; SimpleLookupTable docsToReferences ; SimpleWordSet allWords ; String lastDocumentName ; HashtableOfObject lastReferenceTable ; MemoryIndex ( ) { this . docsToReferences = new SimpleLookupTable ( <NUM_LIT:7> ) ; this . allWords = new SimpleWordSet ( <NUM_LIT:7> ) ; } void addDocumentNames ( String substring , SimpleSet results ) { Object [ ] paths = this . docsToReferences . keyTable ; Object [ ] referenceTables = this . docsToReferences . valueTable ; if ( substring == null ) { for ( int i = <NUM_LIT:0> , l = referenceTables . length ; i < l ; i ++ ) if ( referenceTables [ i ] != null ) results . add ( paths [ i ] ) ; } else { for ( int i = <NUM_LIT:0> , l = referenceTables . length ; i < l ; i ++ ) if ( referenceTables [ i ] != null && ( ( String ) paths [ i ] ) . startsWith ( substring , <NUM_LIT:0> ) ) results . add ( paths [ i ] ) ; } } void addIndexEntry ( char [ ] category , char [ ] key , String documentName ) { HashtableOfObject referenceTable ; if ( documentName . equals ( this . lastDocumentName ) ) referenceTable = this . lastReferenceTable ; else { referenceTable = ( HashtableOfObject ) this . docsToReferences . get ( documentName ) ; if ( referenceTable == null ) this . docsToReferences . put ( documentName , referenceTable = new HashtableOfObject ( <NUM_LIT:3> ) ) ; this . lastDocumentName = documentName ; this . lastReferenceTable = referenceTable ; } SimpleWordSet existingWords = ( SimpleWordSet ) referenceTable . get ( category ) ; if ( existingWords == null ) referenceTable . put ( category , existingWords = new SimpleWordSet ( <NUM_LIT:1> ) ) ; existingWords . add ( this . allWords . add ( key ) ) ; } HashtableOfObject addQueryResults ( char [ ] [ ] categories , char [ ] key , int matchRule , HashtableOfObject results ) { Object [ ] paths = this . docsToReferences . keyTable ; Object [ ] referenceTables = this . docsToReferences . valueTable ; if ( matchRule == ( SearchPattern . R_EXACT_MATCH | SearchPattern . R_CASE_SENSITIVE ) && key != null ) { nextPath : for ( int i = <NUM_LIT:0> , l = referenceTables . length ; i < l ; i ++ ) { HashtableOfObject categoryToWords = ( HashtableOfObject ) referenceTables [ i ] ; if ( categoryToWords != null ) { for ( int j = <NUM_LIT:0> , m = categories . length ; j < m ; j ++ ) { SimpleWordSet wordSet = ( SimpleWordSet ) categoryToWords . get ( categories [ j ] ) ; if ( wordSet != null && wordSet . includes ( key ) ) { if ( results == null ) results = new HashtableOfObject ( <NUM_LIT> ) ; EntryResult result = ( EntryResult ) results . get ( key ) ; if ( result == null ) results . put ( key , result = new EntryResult ( key , null ) ) ; result . addDocumentName ( ( String ) paths [ i ] ) ; continue nextPath ; } } } } } else { for ( int i = <NUM_LIT:0> , l = referenceTables . length ; i < l ; i ++ ) { HashtableOfObject categoryToWords = ( HashtableOfObject ) referenceTables [ i ] ; if ( categoryToWords != null ) { for ( int j = <NUM_LIT:0> , m = categories . length ; j < m ; j ++ ) { SimpleWordSet wordSet = ( SimpleWordSet ) categoryToWords . get ( categories [ j ] ) ; if ( wordSet != null ) { char [ ] [ ] words = wordSet . words ; for ( int k = <NUM_LIT:0> , n = words . length ; k < n ; k ++ ) { char [ ] word = words [ k ] ; if ( word != null && Index . isMatch ( key , word , matchRule ) ) { if ( results == null ) results = new HashtableOfObject ( <NUM_LIT> ) ; EntryResult result = ( EntryResult ) results . get ( word ) ; if ( result == null ) results . put ( word , result = new EntryResult ( word , null ) ) ; result . addDocumentName ( ( String ) paths [ i ] ) ; } } } } } } } return results ; } boolean hasChanged ( ) { return this . docsToReferences . elementSize > <NUM_LIT:0> ; } void remove ( String documentName ) { if ( documentName . equals ( this . lastDocumentName ) ) { this . lastDocumentName = null ; this . lastReferenceTable = null ; } this . docsToReferences . put ( documentName , null ) ; } boolean shouldMerge ( ) { return this . docsToReferences . elementSize >= this . NUM_CHANGES ; } } </s>
<s> package org . eclipse . jdt . internal . core . index ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . util . SimpleSet ; public class EntryResult { private char [ ] word ; private Object [ ] documentTables ; private SimpleSet documentNames ; public EntryResult ( char [ ] word , Object table ) { this . word = word ; if ( table != null ) this . documentTables = new Object [ ] { table } ; } public void addDocumentName ( String documentName ) { if ( this . documentNames == null ) this . documentNames = new SimpleSet ( <NUM_LIT:3> ) ; this . documentNames . add ( documentName ) ; } public void addDocumentTable ( Object table ) { if ( this . documentTables != null ) { int length = this . documentTables . length ; System . arraycopy ( this . documentTables , <NUM_LIT:0> , this . documentTables = new Object [ length + <NUM_LIT:1> ] , <NUM_LIT:0> , length ) ; this . documentTables [ length ] = table ; } else { this . documentTables = new Object [ ] { table } ; } } public char [ ] getWord ( ) { return this . word ; } public String [ ] getDocumentNames ( Index index ) throws java . io . IOException { if ( this . documentTables != null ) { int length = this . documentTables . length ; if ( length == <NUM_LIT:1> && this . documentNames == null ) { Object offset = this . documentTables [ <NUM_LIT:0> ] ; int [ ] numbers = index . diskIndex . readDocumentNumbers ( offset ) ; String [ ] names = new String [ numbers . length ] ; for ( int i = <NUM_LIT:0> , l = numbers . length ; i < l ; i ++ ) names [ i ] = index . diskIndex . readDocumentName ( numbers [ i ] ) ; return names ; } for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { Object offset = this . documentTables [ i ] ; int [ ] numbers = index . diskIndex . readDocumentNumbers ( offset ) ; for ( int j = <NUM_LIT:0> , k = numbers . length ; j < k ; j ++ ) addDocumentName ( index . diskIndex . readDocumentName ( numbers [ j ] ) ) ; } } if ( this . documentNames == null ) return CharOperation . NO_STRINGS ; String [ ] names = new String [ this . documentNames . elementSize ] ; int count = <NUM_LIT:0> ; Object [ ] values = this . documentNames . values ; for ( int i = <NUM_LIT:0> , l = values . length ; i < l ; i ++ ) if ( values [ i ] != null ) names [ count ++ ] = ( String ) values [ i ] ; return names ; } public boolean isEmpty ( ) { return this . documentTables == null && this . documentNames == null ; } } </s>
<s> package org . eclipse . jdt . internal . core . index ; import java . io . * ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . search . * ; import org . eclipse . jdt . internal . core . util . * ; import org . eclipse . jdt . internal . compiler . util . HashtableOfIntValues ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObject ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; import org . eclipse . jdt . internal . compiler . util . SimpleSet ; import org . eclipse . jdt . internal . compiler . util . SimpleSetOfCharArray ; public class DiskIndex { File indexFile ; private int headerInfoOffset ; private int numberOfChunks ; private int sizeOfLastChunk ; private int [ ] chunkOffsets ; private int documentReferenceSize ; private int startOfCategoryTables ; private HashtableOfIntValues categoryOffsets , categoryEnds ; private int cacheUserCount ; private String [ ] [ ] cachedChunks ; private HashtableOfObject categoryTables ; private char [ ] cachedCategoryName ; private static final int DEFAULT_BUFFER_SIZE = <NUM_LIT> ; private static int BUFFER_READ_SIZE = DEFAULT_BUFFER_SIZE ; private static final int BUFFER_WRITE_SIZE = DEFAULT_BUFFER_SIZE ; private byte [ ] streamBuffer ; private int bufferIndex , bufferEnd ; private int streamEnd ; char separator = Index . DEFAULT_SEPARATOR ; public static final String SIGNATURE = "<STR_LIT>" ; private static final char [ ] SIGNATURE_CHARS = SIGNATURE . toCharArray ( ) ; public static boolean DEBUG = false ; private static final int RE_INDEXED = - <NUM_LIT:1> ; private static final int DELETED = - <NUM_LIT:2> ; private static final int CHUNK_SIZE = <NUM_LIT:100> ; private static final SimpleSetOfCharArray INTERNED_CATEGORY_NAMES = new SimpleSetOfCharArray ( <NUM_LIT:20> ) ; static class IntList { int size ; int [ ] elements ; IntList ( int [ ] elements ) { this . elements = elements ; this . size = elements . length ; } void add ( int newElement ) { if ( this . size == this . elements . length ) { int newSize = this . size * <NUM_LIT:3> ; if ( newSize < <NUM_LIT:7> ) newSize = <NUM_LIT:7> ; System . arraycopy ( this . elements , <NUM_LIT:0> , this . elements = new int [ newSize ] , <NUM_LIT:0> , this . size ) ; } this . elements [ this . size ++ ] = newElement ; } int [ ] asArray ( ) { int [ ] result = new int [ this . size ] ; System . arraycopy ( this . elements , <NUM_LIT:0> , result , <NUM_LIT:0> , this . size ) ; return result ; } } DiskIndex ( String fileName ) { if ( fileName == null ) throw new java . lang . IllegalArgumentException ( ) ; this . indexFile = new File ( fileName ) ; this . headerInfoOffset = - <NUM_LIT:1> ; this . numberOfChunks = - <NUM_LIT:1> ; this . sizeOfLastChunk = - <NUM_LIT:1> ; this . chunkOffsets = null ; this . documentReferenceSize = - <NUM_LIT:1> ; this . cacheUserCount = - <NUM_LIT:1> ; this . cachedChunks = null ; this . categoryTables = null ; this . cachedCategoryName = null ; this . categoryOffsets = null ; this . categoryEnds = null ; } SimpleSet addDocumentNames ( String substring , MemoryIndex memoryIndex ) throws IOException { String [ ] docNames = readAllDocumentNames ( ) ; SimpleSet results = new SimpleSet ( docNames . length ) ; if ( substring == null ) { if ( memoryIndex == null ) { for ( int i = <NUM_LIT:0> , l = docNames . length ; i < l ; i ++ ) results . add ( docNames [ i ] ) ; } else { SimpleLookupTable docsToRefs = memoryIndex . docsToReferences ; for ( int i = <NUM_LIT:0> , l = docNames . length ; i < l ; i ++ ) { String docName = docNames [ i ] ; if ( ! docsToRefs . containsKey ( docName ) ) results . add ( docName ) ; } } } else { if ( memoryIndex == null ) { for ( int i = <NUM_LIT:0> , l = docNames . length ; i < l ; i ++ ) if ( docNames [ i ] . startsWith ( substring , <NUM_LIT:0> ) ) results . add ( docNames [ i ] ) ; } else { SimpleLookupTable docsToRefs = memoryIndex . docsToReferences ; for ( int i = <NUM_LIT:0> , l = docNames . length ; i < l ; i ++ ) { String docName = docNames [ i ] ; if ( docName . startsWith ( substring , <NUM_LIT:0> ) && ! docsToRefs . containsKey ( docName ) ) results . add ( docName ) ; } } } return results ; } private HashtableOfObject addQueryResult ( HashtableOfObject results , char [ ] word , Object docs , MemoryIndex memoryIndex , boolean prevResults ) throws IOException { if ( results == null ) results = new HashtableOfObject ( <NUM_LIT> ) ; EntryResult result = prevResults ? ( EntryResult ) results . get ( word ) : null ; if ( memoryIndex == null ) { if ( result == null ) results . putUnsafely ( word , new EntryResult ( word , docs ) ) ; else result . addDocumentTable ( docs ) ; } else { SimpleLookupTable docsToRefs = memoryIndex . docsToReferences ; if ( result == null ) result = new EntryResult ( word , null ) ; int [ ] docNumbers = readDocumentNumbers ( docs ) ; for ( int i = <NUM_LIT:0> , l = docNumbers . length ; i < l ; i ++ ) { String docName = readDocumentName ( docNumbers [ i ] ) ; if ( ! docsToRefs . containsKey ( docName ) ) result . addDocumentName ( docName ) ; } if ( ! result . isEmpty ( ) ) results . put ( word , result ) ; } return results ; } HashtableOfObject addQueryResults ( char [ ] [ ] categories , char [ ] key , int matchRule , MemoryIndex memoryIndex ) throws IOException { if ( this . categoryOffsets == null ) return null ; HashtableOfObject results = null ; boolean prevResults = false ; if ( key == null ) { for ( int i = <NUM_LIT:0> , l = categories . length ; i < l ; i ++ ) { HashtableOfObject wordsToDocNumbers = readCategoryTable ( categories [ i ] , true ) ; if ( wordsToDocNumbers != null ) { char [ ] [ ] words = wordsToDocNumbers . keyTable ; Object [ ] values = wordsToDocNumbers . valueTable ; if ( results == null ) results = new HashtableOfObject ( wordsToDocNumbers . elementSize ) ; for ( int j = <NUM_LIT:0> , m = words . length ; j < m ; j ++ ) if ( words [ j ] != null ) results = addQueryResult ( results , words [ j ] , values [ j ] , memoryIndex , prevResults ) ; } prevResults = results != null ; } if ( results != null && this . cachedChunks == null ) cacheDocumentNames ( ) ; } else { switch ( matchRule ) { case SearchPattern . R_EXACT_MATCH | SearchPattern . R_CASE_SENSITIVE : for ( int i = <NUM_LIT:0> , l = categories . length ; i < l ; i ++ ) { HashtableOfObject wordsToDocNumbers = readCategoryTable ( categories [ i ] , false ) ; Object value ; if ( wordsToDocNumbers != null && ( value = wordsToDocNumbers . get ( key ) ) != null ) results = addQueryResult ( results , key , value , memoryIndex , prevResults ) ; prevResults = results != null ; } break ; case SearchPattern . R_PREFIX_MATCH | SearchPattern . R_CASE_SENSITIVE : for ( int i = <NUM_LIT:0> , l = categories . length ; i < l ; i ++ ) { HashtableOfObject wordsToDocNumbers = readCategoryTable ( categories [ i ] , false ) ; if ( wordsToDocNumbers != null ) { char [ ] [ ] words = wordsToDocNumbers . keyTable ; Object [ ] values = wordsToDocNumbers . valueTable ; for ( int j = <NUM_LIT:0> , m = words . length ; j < m ; j ++ ) { char [ ] word = words [ j ] ; if ( word != null && key [ <NUM_LIT:0> ] == word [ <NUM_LIT:0> ] && CharOperation . prefixEquals ( key , word ) ) results = addQueryResult ( results , word , values [ j ] , memoryIndex , prevResults ) ; } } prevResults = results != null ; } break ; default : for ( int i = <NUM_LIT:0> , l = categories . length ; i < l ; i ++ ) { HashtableOfObject wordsToDocNumbers = readCategoryTable ( categories [ i ] , false ) ; if ( wordsToDocNumbers != null ) { char [ ] [ ] words = wordsToDocNumbers . keyTable ; Object [ ] values = wordsToDocNumbers . valueTable ; for ( int j = <NUM_LIT:0> , m = words . length ; j < m ; j ++ ) { char [ ] word = words [ j ] ; if ( word != null && Index . isMatch ( key , word , matchRule ) ) results = addQueryResult ( results , word , values [ j ] , memoryIndex , prevResults ) ; } } prevResults = results != null ; } } } if ( results == null ) return null ; return results ; } private void cacheDocumentNames ( ) throws IOException { this . cachedChunks = new String [ this . numberOfChunks ] [ ] ; FileInputStream stream = new FileInputStream ( this . indexFile ) ; try { if ( this . numberOfChunks > <NUM_LIT:5> ) BUFFER_READ_SIZE <<= <NUM_LIT:1> ; int offset = this . chunkOffsets [ <NUM_LIT:0> ] ; stream . skip ( offset ) ; this . streamBuffer = new byte [ BUFFER_READ_SIZE ] ; this . bufferIndex = <NUM_LIT:0> ; this . bufferEnd = stream . read ( this . streamBuffer , <NUM_LIT:0> , this . streamBuffer . length ) ; for ( int i = <NUM_LIT:0> ; i < this . numberOfChunks ; i ++ ) { int size = i == this . numberOfChunks - <NUM_LIT:1> ? this . sizeOfLastChunk : CHUNK_SIZE ; readChunk ( this . cachedChunks [ i ] = new String [ size ] , stream , <NUM_LIT:0> , size ) ; } } catch ( IOException e ) { this . cachedChunks = null ; throw e ; } finally { stream . close ( ) ; this . streamBuffer = null ; BUFFER_READ_SIZE = DEFAULT_BUFFER_SIZE ; } } private String [ ] computeDocumentNames ( String [ ] onDiskNames , int [ ] positions , SimpleLookupTable indexedDocuments , MemoryIndex memoryIndex ) { int onDiskLength = onDiskNames . length ; Object [ ] docNames = memoryIndex . docsToReferences . keyTable ; Object [ ] referenceTables = memoryIndex . docsToReferences . valueTable ; if ( onDiskLength == <NUM_LIT:0> ) { for ( int i = <NUM_LIT:0> , l = referenceTables . length ; i < l ; i ++ ) if ( referenceTables [ i ] != null ) indexedDocuments . put ( docNames [ i ] , null ) ; String [ ] newDocNames = new String [ indexedDocuments . elementSize ] ; int count = <NUM_LIT:0> ; Object [ ] added = indexedDocuments . keyTable ; for ( int i = <NUM_LIT:0> , l = added . length ; i < l ; i ++ ) if ( added [ i ] != null ) newDocNames [ count ++ ] = ( String ) added [ i ] ; Util . sort ( newDocNames ) ; for ( int i = <NUM_LIT:0> , l = newDocNames . length ; i < l ; i ++ ) indexedDocuments . put ( newDocNames [ i ] , new Integer ( i ) ) ; return newDocNames ; } for ( int i = <NUM_LIT:0> ; i < onDiskLength ; i ++ ) positions [ i ] = i ; int numDeletedDocNames = <NUM_LIT:0> ; int numReindexedDocNames = <NUM_LIT:0> ; nextPath : for ( int i = <NUM_LIT:0> , l = docNames . length ; i < l ; i ++ ) { String docName = ( String ) docNames [ i ] ; if ( docName != null ) { for ( int j = <NUM_LIT:0> ; j < onDiskLength ; j ++ ) { if ( docName . equals ( onDiskNames [ j ] ) ) { if ( referenceTables [ i ] == null ) { positions [ j ] = DELETED ; numDeletedDocNames ++ ; } else { positions [ j ] = RE_INDEXED ; numReindexedDocNames ++ ; } continue nextPath ; } } if ( referenceTables [ i ] != null ) indexedDocuments . put ( docName , null ) ; } } String [ ] newDocNames = onDiskNames ; if ( numDeletedDocNames > <NUM_LIT:0> || indexedDocuments . elementSize > <NUM_LIT:0> ) { newDocNames = new String [ onDiskLength + indexedDocuments . elementSize - numDeletedDocNames ] ; int count = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < onDiskLength ; i ++ ) if ( positions [ i ] >= RE_INDEXED ) newDocNames [ count ++ ] = onDiskNames [ i ] ; Object [ ] added = indexedDocuments . keyTable ; for ( int i = <NUM_LIT:0> , l = added . length ; i < l ; i ++ ) if ( added [ i ] != null ) newDocNames [ count ++ ] = ( String ) added [ i ] ; Util . sort ( newDocNames ) ; for ( int i = <NUM_LIT:0> , l = newDocNames . length ; i < l ; i ++ ) if ( indexedDocuments . containsKey ( newDocNames [ i ] ) ) indexedDocuments . put ( newDocNames [ i ] , new Integer ( i ) ) ; } int count = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < onDiskLength ; ) { switch ( positions [ i ] ) { case DELETED : i ++ ; break ; case RE_INDEXED : String newName = newDocNames [ ++ count ] ; if ( newName . equals ( onDiskNames [ i ] ) ) { indexedDocuments . put ( newName , new Integer ( count ) ) ; i ++ ; } break ; default : if ( newDocNames [ ++ count ] . equals ( onDiskNames [ i ] ) ) positions [ i ++ ] = count ; } } return newDocNames ; } private void copyQueryResults ( HashtableOfObject categoryToWords , int newPosition ) { char [ ] [ ] categoryNames = categoryToWords . keyTable ; Object [ ] wordSets = categoryToWords . valueTable ; for ( int i = <NUM_LIT:0> , l = categoryNames . length ; i < l ; i ++ ) { char [ ] categoryName = categoryNames [ i ] ; if ( categoryName != null ) { SimpleWordSet wordSet = ( SimpleWordSet ) wordSets [ i ] ; HashtableOfObject wordsToDocs = ( HashtableOfObject ) this . categoryTables . get ( categoryName ) ; if ( wordsToDocs == null ) this . categoryTables . put ( categoryName , wordsToDocs = new HashtableOfObject ( wordSet . elementSize ) ) ; char [ ] [ ] words = wordSet . words ; for ( int j = <NUM_LIT:0> , m = words . length ; j < m ; j ++ ) { char [ ] word = words [ j ] ; if ( word != null ) { Object o = wordsToDocs . get ( word ) ; if ( o == null ) { wordsToDocs . putUnsafely ( word , new int [ ] { newPosition } ) ; } else if ( o instanceof IntList ) { ( ( IntList ) o ) . add ( newPosition ) ; } else { IntList list = new IntList ( ( int [ ] ) o ) ; list . add ( newPosition ) ; wordsToDocs . put ( word , list ) ; } } } } } } void initialize ( boolean reuseExistingFile ) throws IOException { if ( this . indexFile . exists ( ) ) { if ( reuseExistingFile ) { FileInputStream stream = new FileInputStream ( this . indexFile ) ; this . streamBuffer = new byte [ BUFFER_READ_SIZE ] ; this . bufferIndex = <NUM_LIT:0> ; this . bufferEnd = stream . read ( this . streamBuffer , <NUM_LIT:0> , <NUM_LIT> ) ; try { char [ ] signature = readStreamChars ( stream ) ; if ( ! CharOperation . equals ( signature , SIGNATURE_CHARS ) ) { throw new IOException ( Messages . exception_wrongFormat ) ; } this . headerInfoOffset = readStreamInt ( stream ) ; if ( this . headerInfoOffset > <NUM_LIT:0> ) { stream . skip ( this . headerInfoOffset - this . bufferEnd ) ; this . bufferIndex = <NUM_LIT:0> ; this . bufferEnd = stream . read ( this . streamBuffer , <NUM_LIT:0> , this . streamBuffer . length ) ; readHeaderInfo ( stream ) ; } } finally { stream . close ( ) ; } return ; } if ( ! this . indexFile . delete ( ) ) { if ( DEBUG ) System . out . println ( "<STR_LIT>" + this . indexFile ) ; throw new IOException ( "<STR_LIT>" + this . indexFile ) ; } } if ( this . indexFile . createNewFile ( ) ) { FileOutputStream stream = new FileOutputStream ( this . indexFile , false ) ; try { this . streamBuffer = new byte [ BUFFER_READ_SIZE ] ; this . bufferIndex = <NUM_LIT:0> ; writeStreamChars ( stream , SIGNATURE_CHARS ) ; writeStreamInt ( stream , - <NUM_LIT:1> ) ; if ( this . bufferIndex > <NUM_LIT:0> ) { stream . write ( this . streamBuffer , <NUM_LIT:0> , this . bufferIndex ) ; this . bufferIndex = <NUM_LIT:0> ; } } finally { stream . close ( ) ; } } else { if ( DEBUG ) System . out . println ( "<STR_LIT>" + this . indexFile ) ; throw new IOException ( "<STR_LIT>" + this . indexFile ) ; } } private void initializeFrom ( DiskIndex diskIndex , File newIndexFile ) throws IOException { if ( newIndexFile . exists ( ) && ! newIndexFile . delete ( ) ) { if ( DEBUG ) System . out . println ( "<STR_LIT>" + this . indexFile ) ; } else if ( ! newIndexFile . createNewFile ( ) ) { if ( DEBUG ) System . out . println ( "<STR_LIT>" + this . indexFile ) ; throw new IOException ( "<STR_LIT>" + this . indexFile ) ; } int size = diskIndex . categoryOffsets == null ? <NUM_LIT:8> : diskIndex . categoryOffsets . elementSize ; this . categoryOffsets = new HashtableOfIntValues ( size ) ; this . categoryEnds = new HashtableOfIntValues ( size ) ; this . categoryTables = new HashtableOfObject ( size ) ; this . separator = diskIndex . separator ; } private void mergeCategories ( DiskIndex onDisk , int [ ] positions , FileOutputStream stream ) throws IOException { char [ ] [ ] oldNames = onDisk . categoryOffsets . keyTable ; for ( int i = <NUM_LIT:0> , l = oldNames . length ; i < l ; i ++ ) { char [ ] oldName = oldNames [ i ] ; if ( oldName != null && ! this . categoryTables . containsKey ( oldName ) ) this . categoryTables . put ( oldName , null ) ; } char [ ] [ ] categoryNames = this . categoryTables . keyTable ; for ( int i = <NUM_LIT:0> , l = categoryNames . length ; i < l ; i ++ ) if ( categoryNames [ i ] != null ) mergeCategory ( categoryNames [ i ] , onDisk , positions , stream ) ; this . categoryTables = null ; } private void mergeCategory ( char [ ] categoryName , DiskIndex onDisk , int [ ] positions , FileOutputStream stream ) throws IOException { HashtableOfObject wordsToDocs = ( HashtableOfObject ) this . categoryTables . get ( categoryName ) ; if ( wordsToDocs == null ) wordsToDocs = new HashtableOfObject ( <NUM_LIT:3> ) ; HashtableOfObject oldWordsToDocs = onDisk . readCategoryTable ( categoryName , true ) ; if ( oldWordsToDocs != null ) { char [ ] [ ] oldWords = oldWordsToDocs . keyTable ; Object [ ] oldArrayOffsets = oldWordsToDocs . valueTable ; nextWord : for ( int i = <NUM_LIT:0> , l = oldWords . length ; i < l ; i ++ ) { char [ ] oldWord = oldWords [ i ] ; if ( oldWord != null ) { int [ ] oldDocNumbers = ( int [ ] ) oldArrayOffsets [ i ] ; int length = oldDocNumbers . length ; int [ ] mappedNumbers = new int [ length ] ; int count = <NUM_LIT:0> ; for ( int j = <NUM_LIT:0> ; j < length ; j ++ ) { int pos = positions [ oldDocNumbers [ j ] ] ; if ( pos > RE_INDEXED ) mappedNumbers [ count ++ ] = pos ; } if ( count < length ) { if ( count == <NUM_LIT:0> ) continue nextWord ; System . arraycopy ( mappedNumbers , <NUM_LIT:0> , mappedNumbers = new int [ count ] , <NUM_LIT:0> , count ) ; } Object o = wordsToDocs . get ( oldWord ) ; if ( o == null ) { wordsToDocs . putUnsafely ( oldWord , mappedNumbers ) ; } else { IntList list = null ; if ( o instanceof IntList ) { list = ( IntList ) o ; } else { list = new IntList ( ( int [ ] ) o ) ; wordsToDocs . put ( oldWord , list ) ; } for ( int j = <NUM_LIT:0> ; j < count ; j ++ ) list . add ( mappedNumbers [ j ] ) ; } } } onDisk . categoryTables . put ( categoryName , null ) ; } writeCategoryTable ( categoryName , wordsToDocs , stream ) ; } DiskIndex mergeWith ( MemoryIndex memoryIndex ) throws IOException { String [ ] docNames = readAllDocumentNames ( ) ; int previousLength = docNames . length ; int [ ] positions = new int [ previousLength ] ; SimpleLookupTable indexedDocuments = new SimpleLookupTable ( <NUM_LIT:3> ) ; docNames = computeDocumentNames ( docNames , positions , indexedDocuments , memoryIndex ) ; if ( docNames . length == <NUM_LIT:0> ) { if ( previousLength == <NUM_LIT:0> ) return this ; DiskIndex newDiskIndex = new DiskIndex ( this . indexFile . getPath ( ) ) ; newDiskIndex . initialize ( false ) ; return newDiskIndex ; } DiskIndex newDiskIndex = new DiskIndex ( this . indexFile . getPath ( ) + "<STR_LIT>" ) ; try { newDiskIndex . initializeFrom ( this , newDiskIndex . indexFile ) ; FileOutputStream stream = new FileOutputStream ( newDiskIndex . indexFile , false ) ; int offsetToHeader = - <NUM_LIT:1> ; try { newDiskIndex . writeAllDocumentNames ( docNames , stream ) ; docNames = null ; if ( indexedDocuments . elementSize > <NUM_LIT:0> ) { Object [ ] names = indexedDocuments . keyTable ; Object [ ] integerPositions = indexedDocuments . valueTable ; for ( int i = <NUM_LIT:0> , l = names . length ; i < l ; i ++ ) if ( names [ i ] != null ) newDiskIndex . copyQueryResults ( ( HashtableOfObject ) memoryIndex . docsToReferences . get ( names [ i ] ) , ( ( Integer ) integerPositions [ i ] ) . intValue ( ) ) ; } indexedDocuments = null ; if ( previousLength == <NUM_LIT:0> ) newDiskIndex . writeCategories ( stream ) ; else newDiskIndex . mergeCategories ( this , positions , stream ) ; offsetToHeader = newDiskIndex . streamEnd ; newDiskIndex . writeHeaderInfo ( stream ) ; positions = null ; } finally { stream . close ( ) ; this . streamBuffer = null ; } newDiskIndex . writeOffsetToHeader ( offsetToHeader ) ; if ( this . indexFile . exists ( ) && ! this . indexFile . delete ( ) ) { if ( DEBUG ) System . out . println ( "<STR_LIT>" + this . indexFile ) ; throw new IOException ( "<STR_LIT>" + this . indexFile ) ; } if ( ! newDiskIndex . indexFile . renameTo ( this . indexFile ) ) { if ( DEBUG ) System . out . println ( "<STR_LIT>" + this . indexFile ) ; throw new IOException ( "<STR_LIT>" + this . indexFile ) ; } } catch ( IOException e ) { if ( newDiskIndex . indexFile . exists ( ) && ! newDiskIndex . indexFile . delete ( ) ) if ( DEBUG ) System . out . println ( "<STR_LIT>" + newDiskIndex . indexFile ) ; throw e ; } newDiskIndex . indexFile = this . indexFile ; return newDiskIndex ; } private synchronized String [ ] readAllDocumentNames ( ) throws IOException { if ( this . numberOfChunks <= <NUM_LIT:0> ) return CharOperation . NO_STRINGS ; FileInputStream stream = new FileInputStream ( this . indexFile ) ; try { int offset = this . chunkOffsets [ <NUM_LIT:0> ] ; stream . skip ( offset ) ; this . streamBuffer = new byte [ BUFFER_READ_SIZE ] ; this . bufferIndex = <NUM_LIT:0> ; this . bufferEnd = stream . read ( this . streamBuffer , <NUM_LIT:0> , this . streamBuffer . length ) ; int lastIndex = this . numberOfChunks - <NUM_LIT:1> ; String [ ] docNames = new String [ lastIndex * CHUNK_SIZE + this . sizeOfLastChunk ] ; for ( int i = <NUM_LIT:0> ; i < this . numberOfChunks ; i ++ ) readChunk ( docNames , stream , i * CHUNK_SIZE , i < lastIndex ? CHUNK_SIZE : this . sizeOfLastChunk ) ; return docNames ; } finally { stream . close ( ) ; this . streamBuffer = null ; } } private synchronized HashtableOfObject readCategoryTable ( char [ ] categoryName , boolean readDocNumbers ) throws IOException { int offset = this . categoryOffsets . get ( categoryName ) ; if ( offset == HashtableOfIntValues . NO_VALUE ) { return null ; } if ( this . categoryTables == null ) { this . categoryTables = new HashtableOfObject ( <NUM_LIT:3> ) ; } else { HashtableOfObject cachedTable = ( HashtableOfObject ) this . categoryTables . get ( categoryName ) ; if ( cachedTable != null ) { if ( readDocNumbers ) { Object [ ] arrayOffsets = cachedTable . valueTable ; for ( int i = <NUM_LIT:0> , l = arrayOffsets . length ; i < l ; i ++ ) if ( arrayOffsets [ i ] instanceof Integer ) arrayOffsets [ i ] = readDocumentNumbers ( arrayOffsets [ i ] ) ; } return cachedTable ; } } FileInputStream stream = new FileInputStream ( this . indexFile ) ; HashtableOfObject categoryTable = null ; char [ ] [ ] matchingWords = null ; int count = <NUM_LIT:0> ; int firstOffset = - <NUM_LIT:1> ; this . streamBuffer = new byte [ BUFFER_READ_SIZE ] ; try { stream . skip ( offset ) ; this . bufferIndex = <NUM_LIT:0> ; this . bufferEnd = stream . read ( this . streamBuffer , <NUM_LIT:0> , this . streamBuffer . length ) ; int size = readStreamInt ( stream ) ; try { if ( size < <NUM_LIT:0> ) { System . err . println ( "<STR_LIT>" ) ; System . err . println ( "<STR_LIT>" + this . indexFile ) ; System . err . println ( "<STR_LIT>" + offset ) ; System . err . println ( "<STR_LIT>" + size ) ; System . err . println ( "<STR_LIT>" ) ; } categoryTable = new HashtableOfObject ( size ) ; } catch ( OutOfMemoryError oom ) { oom . printStackTrace ( ) ; System . err . println ( "<STR_LIT>" ) ; System . err . println ( "<STR_LIT>" + this . indexFile ) ; System . err . println ( "<STR_LIT>" + offset ) ; System . err . println ( "<STR_LIT>" + size ) ; System . err . println ( "<STR_LIT>" ) ; throw oom ; } int largeArraySize = <NUM_LIT> ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { char [ ] word = readStreamChars ( stream ) ; int arrayOffset = readStreamInt ( stream ) ; if ( arrayOffset <= <NUM_LIT:0> ) { categoryTable . putUnsafely ( word , new int [ ] { - arrayOffset } ) ; } else if ( arrayOffset < largeArraySize ) { categoryTable . putUnsafely ( word , readStreamDocumentArray ( stream , arrayOffset ) ) ; } else { arrayOffset = readStreamInt ( stream ) ; if ( readDocNumbers ) { if ( matchingWords == null ) matchingWords = new char [ size ] [ ] ; if ( count == <NUM_LIT:0> ) firstOffset = arrayOffset ; matchingWords [ count ++ ] = word ; } categoryTable . putUnsafely ( word , new Integer ( arrayOffset ) ) ; } } this . categoryTables . put ( INTERNED_CATEGORY_NAMES . get ( categoryName ) , categoryTable ) ; this . cachedCategoryName = categoryTable . elementSize < <NUM_LIT> ? categoryName : null ; } catch ( IOException ioe ) { this . streamBuffer = null ; throw ioe ; } finally { stream . close ( ) ; } if ( matchingWords != null && count > <NUM_LIT:0> ) { stream = new FileInputStream ( this . indexFile ) ; try { stream . skip ( firstOffset ) ; this . bufferIndex = <NUM_LIT:0> ; this . bufferEnd = stream . read ( this . streamBuffer , <NUM_LIT:0> , this . streamBuffer . length ) ; for ( int i = <NUM_LIT:0> ; i < count ; i ++ ) { categoryTable . put ( matchingWords [ i ] , readStreamDocumentArray ( stream , readStreamInt ( stream ) ) ) ; } } catch ( IOException ioe ) { this . streamBuffer = null ; throw ioe ; } finally { stream . close ( ) ; } } this . streamBuffer = null ; return categoryTable ; } private void readChunk ( String [ ] docNames , FileInputStream stream , int index , int size ) throws IOException { String current = new String ( readStreamChars ( stream ) ) ; docNames [ index ++ ] = current ; for ( int i = <NUM_LIT:1> ; i < size ; i ++ ) { if ( stream != null && this . bufferIndex + <NUM_LIT:2> >= this . bufferEnd ) readStreamBuffer ( stream ) ; int start = this . streamBuffer [ this . bufferIndex ++ ] & <NUM_LIT> ; int end = this . streamBuffer [ this . bufferIndex ++ ] & <NUM_LIT> ; String next = new String ( readStreamChars ( stream ) ) ; if ( start > <NUM_LIT:0> ) { if ( end > <NUM_LIT:0> ) { int length = current . length ( ) ; next = current . substring ( <NUM_LIT:0> , start ) + next + current . substring ( length - end , length ) ; } else { next = current . substring ( <NUM_LIT:0> , start ) + next ; } } else if ( end > <NUM_LIT:0> ) { int length = current . length ( ) ; next = next + current . substring ( length - end , length ) ; } docNames [ index ++ ] = next ; current = next ; } } synchronized String readDocumentName ( int docNumber ) throws IOException { if ( this . cachedChunks == null ) this . cachedChunks = new String [ this . numberOfChunks ] [ ] ; int chunkNumber = docNumber / CHUNK_SIZE ; String [ ] chunk = this . cachedChunks [ chunkNumber ] ; if ( chunk == null ) { boolean isLastChunk = chunkNumber == this . numberOfChunks - <NUM_LIT:1> ; int start = this . chunkOffsets [ chunkNumber ] ; int numberOfBytes = ( isLastChunk ? this . startOfCategoryTables : this . chunkOffsets [ chunkNumber + <NUM_LIT:1> ] ) - start ; if ( numberOfBytes < <NUM_LIT:0> ) throw new IllegalArgumentException ( ) ; this . streamBuffer = new byte [ numberOfBytes ] ; this . bufferIndex = <NUM_LIT:0> ; FileInputStream file = new FileInputStream ( this . indexFile ) ; try { file . skip ( start ) ; if ( file . read ( this . streamBuffer , <NUM_LIT:0> , numberOfBytes ) != numberOfBytes ) throw new IOException ( ) ; } catch ( IOException ioe ) { this . streamBuffer = null ; throw ioe ; } finally { file . close ( ) ; } int numberOfNames = isLastChunk ? this . sizeOfLastChunk : CHUNK_SIZE ; chunk = new String [ numberOfNames ] ; try { readChunk ( chunk , null , <NUM_LIT:0> , numberOfNames ) ; } catch ( IOException ioe ) { this . streamBuffer = null ; throw ioe ; } this . cachedChunks [ chunkNumber ] = chunk ; } this . streamBuffer = null ; return chunk [ docNumber - ( chunkNumber * CHUNK_SIZE ) ] ; } synchronized int [ ] readDocumentNumbers ( Object arrayOffset ) throws IOException { if ( arrayOffset instanceof int [ ] ) return ( int [ ] ) arrayOffset ; FileInputStream stream = new FileInputStream ( this . indexFile ) ; try { int offset = ( ( Integer ) arrayOffset ) . intValue ( ) ; stream . skip ( offset ) ; this . streamBuffer = new byte [ BUFFER_READ_SIZE ] ; this . bufferIndex = <NUM_LIT:0> ; this . bufferEnd = stream . read ( this . streamBuffer , <NUM_LIT:0> , this . streamBuffer . length ) ; return readStreamDocumentArray ( stream , readStreamInt ( stream ) ) ; } finally { stream . close ( ) ; this . streamBuffer = null ; } } private void readHeaderInfo ( FileInputStream stream ) throws IOException { this . numberOfChunks = readStreamInt ( stream ) ; this . sizeOfLastChunk = this . streamBuffer [ this . bufferIndex ++ ] & <NUM_LIT> ; this . documentReferenceSize = this . streamBuffer [ this . bufferIndex ++ ] & <NUM_LIT> ; this . separator = ( char ) ( this . streamBuffer [ this . bufferIndex ++ ] & <NUM_LIT> ) ; this . chunkOffsets = new int [ this . numberOfChunks ] ; for ( int i = <NUM_LIT:0> ; i < this . numberOfChunks ; i ++ ) this . chunkOffsets [ i ] = readStreamInt ( stream ) ; this . startOfCategoryTables = readStreamInt ( stream ) ; int size = readStreamInt ( stream ) ; this . categoryOffsets = new HashtableOfIntValues ( size ) ; this . categoryEnds = new HashtableOfIntValues ( size ) ; char [ ] previousCategory = null ; int offset = - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < size ; i ++ ) { char [ ] categoryName = INTERNED_CATEGORY_NAMES . get ( readStreamChars ( stream ) ) ; offset = readStreamInt ( stream ) ; this . categoryOffsets . put ( categoryName , offset ) ; if ( previousCategory != null ) { this . categoryEnds . put ( previousCategory , offset ) ; } previousCategory = categoryName ; } if ( previousCategory != null ) { this . categoryEnds . put ( previousCategory , this . headerInfoOffset ) ; } this . categoryTables = new HashtableOfObject ( <NUM_LIT:3> ) ; } synchronized void startQuery ( ) { this . cacheUserCount ++ ; } synchronized void stopQuery ( ) { if ( -- this . cacheUserCount < <NUM_LIT:0> ) { this . cacheUserCount = - <NUM_LIT:1> ; this . cachedChunks = null ; if ( this . categoryTables != null ) { if ( this . cachedCategoryName == null ) { this . categoryTables = null ; } else if ( this . categoryTables . elementSize > <NUM_LIT:1> ) { HashtableOfObject newTables = new HashtableOfObject ( <NUM_LIT:3> ) ; newTables . put ( this . cachedCategoryName , this . categoryTables . get ( this . cachedCategoryName ) ) ; this . categoryTables = newTables ; } } } } private void readStreamBuffer ( FileInputStream stream ) throws IOException { if ( this . bufferEnd < this . streamBuffer . length ) return ; int bytesInBuffer = this . bufferEnd - this . bufferIndex ; if ( bytesInBuffer > <NUM_LIT:0> ) System . arraycopy ( this . streamBuffer , this . bufferIndex , this . streamBuffer , <NUM_LIT:0> , bytesInBuffer ) ; this . bufferEnd = bytesInBuffer + stream . read ( this . streamBuffer , bytesInBuffer , this . bufferIndex ) ; this . bufferIndex = <NUM_LIT:0> ; } private char [ ] readStreamChars ( FileInputStream stream ) throws IOException { if ( stream != null && this . bufferIndex + <NUM_LIT:2> >= this . bufferEnd ) readStreamBuffer ( stream ) ; int length = ( this . streamBuffer [ this . bufferIndex ++ ] & <NUM_LIT> ) << <NUM_LIT:8> ; length += this . streamBuffer [ this . bufferIndex ++ ] & <NUM_LIT> ; char [ ] word = new char [ length ] ; int i = <NUM_LIT:0> ; while ( i < length ) { int charsInBuffer = i + ( ( this . bufferEnd - this . bufferIndex ) / <NUM_LIT:3> ) ; if ( charsInBuffer > length || this . bufferEnd != this . streamBuffer . length || stream == null ) charsInBuffer = length ; while ( i < charsInBuffer ) { byte b = this . streamBuffer [ this . bufferIndex ++ ] ; switch ( b & <NUM_LIT> ) { case <NUM_LIT:0x00> : case <NUM_LIT> : case <NUM_LIT> : case <NUM_LIT> : case <NUM_LIT> : case <NUM_LIT> : case <NUM_LIT> : case <NUM_LIT> : word [ i ++ ] = ( char ) b ; break ; case <NUM_LIT> : case <NUM_LIT> : char next = ( char ) this . streamBuffer [ this . bufferIndex ++ ] ; if ( ( next & <NUM_LIT> ) != <NUM_LIT> ) { throw new UTFDataFormatException ( ) ; } char ch = ( char ) ( ( b & <NUM_LIT> ) << <NUM_LIT:6> ) ; ch |= next & <NUM_LIT> ; word [ i ++ ] = ch ; break ; case <NUM_LIT> : char first = ( char ) this . streamBuffer [ this . bufferIndex ++ ] ; char second = ( char ) this . streamBuffer [ this . bufferIndex ++ ] ; if ( ( first & second & <NUM_LIT> ) != <NUM_LIT> ) { throw new UTFDataFormatException ( ) ; } ch = ( char ) ( ( b & <NUM_LIT> ) << <NUM_LIT:12> ) ; ch |= ( ( first & <NUM_LIT> ) << <NUM_LIT:6> ) ; ch |= second & <NUM_LIT> ; word [ i ++ ] = ch ; break ; default : throw new UTFDataFormatException ( ) ; } } if ( i < length && stream != null ) readStreamBuffer ( stream ) ; } return word ; } private int [ ] readStreamDocumentArray ( FileInputStream stream , int arraySize ) throws IOException { int [ ] indexes = new int [ arraySize ] ; if ( arraySize == <NUM_LIT:0> ) return indexes ; int i = <NUM_LIT:0> ; switch ( this . documentReferenceSize ) { case <NUM_LIT:1> : while ( i < arraySize ) { int bytesInBuffer = i + this . bufferEnd - this . bufferIndex ; if ( bytesInBuffer > arraySize ) bytesInBuffer = arraySize ; while ( i < bytesInBuffer ) { indexes [ i ++ ] = this . streamBuffer [ this . bufferIndex ++ ] & <NUM_LIT> ; } if ( i < arraySize && stream != null ) readStreamBuffer ( stream ) ; } break ; case <NUM_LIT:2> : while ( i < arraySize ) { int shortsInBuffer = i + ( ( this . bufferEnd - this . bufferIndex ) / <NUM_LIT:2> ) ; if ( shortsInBuffer > arraySize ) shortsInBuffer = arraySize ; while ( i < shortsInBuffer ) { int val = ( this . streamBuffer [ this . bufferIndex ++ ] & <NUM_LIT> ) << <NUM_LIT:8> ; indexes [ i ++ ] = val + ( this . streamBuffer [ this . bufferIndex ++ ] & <NUM_LIT> ) ; } if ( i < arraySize && stream != null ) readStreamBuffer ( stream ) ; } break ; default : while ( i < arraySize ) { indexes [ i ++ ] = readStreamInt ( stream ) ; } break ; } return indexes ; } private int readStreamInt ( FileInputStream stream ) throws IOException { if ( this . bufferIndex + <NUM_LIT:4> >= this . bufferEnd ) { readStreamBuffer ( stream ) ; } int val = ( this . streamBuffer [ this . bufferIndex ++ ] & <NUM_LIT> ) << <NUM_LIT:24> ; val += ( this . streamBuffer [ this . bufferIndex ++ ] & <NUM_LIT> ) << <NUM_LIT:16> ; val += ( this . streamBuffer [ this . bufferIndex ++ ] & <NUM_LIT> ) << <NUM_LIT:8> ; return val + ( this . streamBuffer [ this . bufferIndex ++ ] & <NUM_LIT> ) ; } private void writeAllDocumentNames ( String [ ] sortedDocNames , FileOutputStream stream ) throws IOException { if ( sortedDocNames . length == <NUM_LIT:0> ) throw new IllegalArgumentException ( ) ; this . streamBuffer = new byte [ BUFFER_WRITE_SIZE ] ; this . bufferIndex = <NUM_LIT:0> ; this . streamEnd = <NUM_LIT:0> ; writeStreamChars ( stream , SIGNATURE_CHARS ) ; this . headerInfoOffset = this . streamEnd ; writeStreamInt ( stream , - <NUM_LIT:1> ) ; int size = sortedDocNames . length ; this . numberOfChunks = ( size / CHUNK_SIZE ) + <NUM_LIT:1> ; this . sizeOfLastChunk = size % CHUNK_SIZE ; if ( this . sizeOfLastChunk == <NUM_LIT:0> ) { this . numberOfChunks -- ; this . sizeOfLastChunk = CHUNK_SIZE ; } this . documentReferenceSize = size <= <NUM_LIT> ? <NUM_LIT:1> : ( size <= <NUM_LIT> ? <NUM_LIT:2> : <NUM_LIT:4> ) ; this . chunkOffsets = new int [ this . numberOfChunks ] ; int lastIndex = this . numberOfChunks - <NUM_LIT:1> ; for ( int i = <NUM_LIT:0> ; i < this . numberOfChunks ; i ++ ) { this . chunkOffsets [ i ] = this . streamEnd ; int chunkSize = i == lastIndex ? this . sizeOfLastChunk : CHUNK_SIZE ; int chunkIndex = i * CHUNK_SIZE ; String current = sortedDocNames [ chunkIndex ] ; writeStreamChars ( stream , current . toCharArray ( ) ) ; for ( int j = <NUM_LIT:1> ; j < chunkSize ; j ++ ) { String next = sortedDocNames [ chunkIndex + j ] ; int len1 = current . length ( ) ; int len2 = next . length ( ) ; int max = len1 < len2 ? len1 : len2 ; int start = <NUM_LIT:0> ; while ( current . charAt ( start ) == next . charAt ( start ) ) { start ++ ; if ( max == start ) break ; } if ( start > <NUM_LIT:255> ) start = <NUM_LIT:255> ; int end = <NUM_LIT:0> ; while ( current . charAt ( -- len1 ) == next . charAt ( -- len2 ) ) { end ++ ; if ( len2 == start ) break ; if ( len1 == <NUM_LIT:0> ) break ; } if ( end > <NUM_LIT:255> ) end = <NUM_LIT:255> ; if ( ( this . bufferIndex + <NUM_LIT:2> ) >= BUFFER_WRITE_SIZE ) { stream . write ( this . streamBuffer , <NUM_LIT:0> , this . bufferIndex ) ; this . bufferIndex = <NUM_LIT:0> ; } this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) start ; this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) end ; this . streamEnd += <NUM_LIT:2> ; int last = next . length ( ) - end ; writeStreamChars ( stream , ( start < last ? CharOperation . subarray ( next . toCharArray ( ) , start , last ) : CharOperation . NO_CHAR ) ) ; current = next ; } } this . startOfCategoryTables = this . streamEnd + <NUM_LIT:1> ; } private void writeCategories ( FileOutputStream stream ) throws IOException { char [ ] [ ] categoryNames = this . categoryTables . keyTable ; Object [ ] tables = this . categoryTables . valueTable ; for ( int i = <NUM_LIT:0> , l = categoryNames . length ; i < l ; i ++ ) if ( categoryNames [ i ] != null ) writeCategoryTable ( categoryNames [ i ] , ( HashtableOfObject ) tables [ i ] , stream ) ; this . categoryTables = null ; } private void writeCategoryTable ( char [ ] categoryName , HashtableOfObject wordsToDocs , FileOutputStream stream ) throws IOException { int largeArraySize = <NUM_LIT> ; Object [ ] values = wordsToDocs . valueTable ; for ( int i = <NUM_LIT:0> , l = values . length ; i < l ; i ++ ) { Object o = values [ i ] ; if ( o != null ) { if ( o instanceof IntList ) o = values [ i ] = ( ( IntList ) values [ i ] ) . asArray ( ) ; int [ ] documentNumbers = ( int [ ] ) o ; if ( documentNumbers . length >= largeArraySize ) { values [ i ] = new Integer ( this . streamEnd ) ; writeDocumentNumbers ( documentNumbers , stream ) ; } } } this . categoryOffsets . put ( categoryName , this . streamEnd ) ; this . categoryTables . put ( categoryName , null ) ; writeStreamInt ( stream , wordsToDocs . elementSize ) ; char [ ] [ ] words = wordsToDocs . keyTable ; for ( int i = <NUM_LIT:0> , l = words . length ; i < l ; i ++ ) { Object o = values [ i ] ; if ( o != null ) { writeStreamChars ( stream , words [ i ] ) ; if ( o instanceof int [ ] ) { int [ ] documentNumbers = ( int [ ] ) o ; if ( documentNumbers . length == <NUM_LIT:1> ) writeStreamInt ( stream , - documentNumbers [ <NUM_LIT:0> ] ) ; else writeDocumentNumbers ( documentNumbers , stream ) ; } else { writeStreamInt ( stream , largeArraySize ) ; writeStreamInt ( stream , ( ( Integer ) o ) . intValue ( ) ) ; } } } } private void writeDocumentNumbers ( int [ ] documentNumbers , FileOutputStream stream ) throws IOException { int length = documentNumbers . length ; writeStreamInt ( stream , length ) ; Util . sort ( documentNumbers ) ; int start = <NUM_LIT:0> ; switch ( this . documentReferenceSize ) { case <NUM_LIT:1> : while ( ( this . bufferIndex + length - start ) >= BUFFER_WRITE_SIZE ) { int bytesLeft = BUFFER_WRITE_SIZE - this . bufferIndex ; for ( int i = <NUM_LIT:0> ; i < bytesLeft ; i ++ ) { this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) documentNumbers [ start ++ ] ; } stream . write ( this . streamBuffer , <NUM_LIT:0> , this . bufferIndex ) ; this . bufferIndex = <NUM_LIT:0> ; } while ( start < length ) { this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) documentNumbers [ start ++ ] ; } this . streamEnd += length ; break ; case <NUM_LIT:2> : while ( ( this . bufferIndex + ( ( length - start ) * <NUM_LIT:2> ) ) >= BUFFER_WRITE_SIZE ) { int shortsLeft = ( BUFFER_WRITE_SIZE - this . bufferIndex ) / <NUM_LIT:2> ; for ( int i = <NUM_LIT:0> ; i < shortsLeft ; i ++ ) { this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) ( documentNumbers [ start ] > > <NUM_LIT:8> ) ; this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) documentNumbers [ start ++ ] ; } stream . write ( this . streamBuffer , <NUM_LIT:0> , this . bufferIndex ) ; this . bufferIndex = <NUM_LIT:0> ; } while ( start < length ) { this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) ( documentNumbers [ start ] > > <NUM_LIT:8> ) ; this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) documentNumbers [ start ++ ] ; } this . streamEnd += length * <NUM_LIT:2> ; break ; default : while ( start < length ) { writeStreamInt ( stream , documentNumbers [ start ++ ] ) ; } break ; } } private void writeHeaderInfo ( FileOutputStream stream ) throws IOException { writeStreamInt ( stream , this . numberOfChunks ) ; if ( ( this . bufferIndex + <NUM_LIT:3> ) >= BUFFER_WRITE_SIZE ) { stream . write ( this . streamBuffer , <NUM_LIT:0> , this . bufferIndex ) ; this . bufferIndex = <NUM_LIT:0> ; } this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) this . sizeOfLastChunk ; this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) this . documentReferenceSize ; this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) this . separator ; this . streamEnd += <NUM_LIT:3> ; for ( int i = <NUM_LIT:0> ; i < this . numberOfChunks ; i ++ ) { writeStreamInt ( stream , this . chunkOffsets [ i ] ) ; } writeStreamInt ( stream , this . startOfCategoryTables ) ; writeStreamInt ( stream , this . categoryOffsets . elementSize ) ; char [ ] [ ] categoryNames = this . categoryOffsets . keyTable ; int [ ] offsets = this . categoryOffsets . valueTable ; for ( int i = <NUM_LIT:0> , l = categoryNames . length ; i < l ; i ++ ) { if ( categoryNames [ i ] != null ) { writeStreamChars ( stream , categoryNames [ i ] ) ; writeStreamInt ( stream , offsets [ i ] ) ; } } if ( this . bufferIndex > <NUM_LIT:0> ) { stream . write ( this . streamBuffer , <NUM_LIT:0> , this . bufferIndex ) ; this . bufferIndex = <NUM_LIT:0> ; } } private void writeOffsetToHeader ( int offsetToHeader ) throws IOException { if ( offsetToHeader > <NUM_LIT:0> ) { RandomAccessFile file = new RandomAccessFile ( this . indexFile , "<STR_LIT>" ) ; try { file . seek ( this . headerInfoOffset ) ; file . writeInt ( offsetToHeader ) ; this . headerInfoOffset = offsetToHeader ; } finally { file . close ( ) ; } } } private void writeStreamChars ( FileOutputStream stream , char [ ] array ) throws IOException { if ( ( this . bufferIndex + <NUM_LIT:2> ) >= BUFFER_WRITE_SIZE ) { stream . write ( this . streamBuffer , <NUM_LIT:0> , this . bufferIndex ) ; this . bufferIndex = <NUM_LIT:0> ; } int length = array . length ; this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) ( ( length > > > <NUM_LIT:8> ) & <NUM_LIT> ) ; this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) ( length & <NUM_LIT> ) ; this . streamEnd += <NUM_LIT:2> ; int totalBytesNeeded = length * <NUM_LIT:3> ; if ( totalBytesNeeded <= BUFFER_WRITE_SIZE ) { if ( this . bufferIndex + totalBytesNeeded > BUFFER_WRITE_SIZE ) { stream . write ( this . streamBuffer , <NUM_LIT:0> , this . bufferIndex ) ; this . bufferIndex = <NUM_LIT:0> ; } writeStreamChars ( stream , array , <NUM_LIT:0> , length ) ; } else { int charsPerWrite = BUFFER_WRITE_SIZE / <NUM_LIT:3> ; int start = <NUM_LIT:0> ; while ( start < length ) { stream . write ( this . streamBuffer , <NUM_LIT:0> , this . bufferIndex ) ; this . bufferIndex = <NUM_LIT:0> ; int charsLeftToWrite = length - start ; int end = start + ( charsPerWrite < charsLeftToWrite ? charsPerWrite : charsLeftToWrite ) ; writeStreamChars ( stream , array , start , end ) ; start = end ; } } } private void writeStreamChars ( FileOutputStream stream , char [ ] array , int start , int end ) throws IOException { int oldIndex = this . bufferIndex ; while ( start < end ) { int ch = array [ start ++ ] ; if ( ( ch & <NUM_LIT> ) == ch ) { this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) ch ; } else if ( ( ch & <NUM_LIT> ) == ch ) { byte b = ( byte ) ( ch > > <NUM_LIT:6> ) ; b &= <NUM_LIT> ; b |= <NUM_LIT> ; this . streamBuffer [ this . bufferIndex ++ ] = b ; b = ( byte ) ( ch & <NUM_LIT> ) ; b |= <NUM_LIT> ; this . streamBuffer [ this . bufferIndex ++ ] = b ; } else { byte b = ( byte ) ( ch > > <NUM_LIT:12> ) ; b &= <NUM_LIT> ; b |= <NUM_LIT> ; this . streamBuffer [ this . bufferIndex ++ ] = b ; b = ( byte ) ( ch > > <NUM_LIT:6> ) ; b &= <NUM_LIT> ; b |= <NUM_LIT> ; this . streamBuffer [ this . bufferIndex ++ ] = b ; b = ( byte ) ( ch & <NUM_LIT> ) ; b |= <NUM_LIT> ; this . streamBuffer [ this . bufferIndex ++ ] = b ; } } this . streamEnd += this . bufferIndex - oldIndex ; } private void writeStreamInt ( FileOutputStream stream , int val ) throws IOException { if ( ( this . bufferIndex + <NUM_LIT:4> ) >= BUFFER_WRITE_SIZE ) { stream . write ( this . streamBuffer , <NUM_LIT:0> , this . bufferIndex ) ; this . bufferIndex = <NUM_LIT:0> ; } this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) ( val > > <NUM_LIT:24> ) ; this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) ( val > > <NUM_LIT:16> ) ; this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) ( val > > <NUM_LIT:8> ) ; this . streamBuffer [ this . bufferIndex ++ ] = ( byte ) val ; this . streamEnd += <NUM_LIT:4> ; } } </s>
<s> package org . eclipse . jdt . internal . core . index ; import java . io . * ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . search . * ; import org . eclipse . jdt . internal . compiler . util . HashtableOfObject ; import org . eclipse . jdt . internal . compiler . util . SimpleSet ; import org . eclipse . jdt . internal . core . search . indexing . ReadWriteMonitor ; public class Index { public String containerPath ; public ReadWriteMonitor monitor ; static final char DEFAULT_SEPARATOR = '<CHAR_LIT:/>' ; public char separator = DEFAULT_SEPARATOR ; static final char JAR_SEPARATOR = IJavaSearchScope . JAR_FILE_ENTRY_SEPARATOR . charAt ( <NUM_LIT:0> ) ; protected DiskIndex diskIndex ; protected MemoryIndex memoryIndex ; static final int MATCH_RULE_INDEX_MASK = SearchPattern . R_EXACT_MATCH | SearchPattern . R_PREFIX_MATCH | SearchPattern . R_PATTERN_MATCH | SearchPattern . R_REGEXP_MATCH | SearchPattern . R_CASE_SENSITIVE | SearchPattern . R_CAMELCASE_MATCH | SearchPattern . R_CAMELCASE_SAME_PART_COUNT_MATCH ; public static boolean isMatch ( char [ ] pattern , char [ ] word , int matchRule ) { if ( pattern == null ) return true ; int patternLength = pattern . length ; int wordLength = word . length ; if ( patternLength == <NUM_LIT:0> ) return matchRule != SearchPattern . R_EXACT_MATCH ; if ( wordLength == <NUM_LIT:0> ) return ( matchRule & SearchPattern . R_PATTERN_MATCH ) != <NUM_LIT:0> && patternLength == <NUM_LIT:1> && pattern [ <NUM_LIT:0> ] == '<CHAR_LIT>' ; switch ( matchRule & MATCH_RULE_INDEX_MASK ) { case SearchPattern . R_EXACT_MATCH : return patternLength == wordLength && CharOperation . equals ( pattern , word , false ) ; case SearchPattern . R_PREFIX_MATCH : return patternLength <= wordLength && CharOperation . prefixEquals ( pattern , word , false ) ; case SearchPattern . R_PATTERN_MATCH : return CharOperation . match ( pattern , word , false ) ; case SearchPattern . R_CAMELCASE_MATCH : case SearchPattern . R_CAMELCASE_SAME_PART_COUNT_MATCH : if ( CharOperation . camelCaseMatch ( pattern , word , false ) ) { return true ; } return patternLength <= wordLength && CharOperation . prefixEquals ( pattern , word , false ) ; case SearchPattern . R_EXACT_MATCH | SearchPattern . R_CASE_SENSITIVE : return pattern [ <NUM_LIT:0> ] == word [ <NUM_LIT:0> ] && patternLength == wordLength && CharOperation . equals ( pattern , word ) ; case SearchPattern . R_PREFIX_MATCH | SearchPattern . R_CASE_SENSITIVE : return pattern [ <NUM_LIT:0> ] == word [ <NUM_LIT:0> ] && patternLength <= wordLength && CharOperation . prefixEquals ( pattern , word ) ; case SearchPattern . R_PATTERN_MATCH | SearchPattern . R_CASE_SENSITIVE : return CharOperation . match ( pattern , word , true ) ; case SearchPattern . R_CAMELCASE_MATCH | SearchPattern . R_CASE_SENSITIVE : case SearchPattern . R_CAMELCASE_SAME_PART_COUNT_MATCH | SearchPattern . R_CASE_SENSITIVE : return ( pattern [ <NUM_LIT:0> ] == word [ <NUM_LIT:0> ] && CharOperation . camelCaseMatch ( pattern , word , false ) ) ; } return false ; } public Index ( String fileName , String containerPath , boolean reuseExistingFile ) throws IOException { this . containerPath = containerPath ; this . monitor = new ReadWriteMonitor ( ) ; this . memoryIndex = new MemoryIndex ( ) ; this . diskIndex = new DiskIndex ( fileName ) ; this . diskIndex . initialize ( reuseExistingFile ) ; if ( reuseExistingFile ) this . separator = this . diskIndex . separator ; } public void addIndexEntry ( char [ ] category , char [ ] key , String containerRelativePath ) { this . memoryIndex . addIndexEntry ( category , key , containerRelativePath ) ; } public String containerRelativePath ( String documentPath ) { int index = documentPath . indexOf ( IJavaSearchScope . JAR_FILE_ENTRY_SEPARATOR ) ; if ( index == - <NUM_LIT:1> ) { index = this . containerPath . length ( ) ; if ( documentPath . length ( ) <= index ) throw new IllegalArgumentException ( "<STR_LIT>" + documentPath + "<STR_LIT>" + this . containerPath ) ; } return documentPath . substring ( index + <NUM_LIT:1> ) ; } public File getIndexFile ( ) { return this . diskIndex == null ? null : this . diskIndex . indexFile ; } public boolean hasChanged ( ) { return this . memoryIndex . hasChanged ( ) ; } public EntryResult [ ] query ( char [ ] [ ] categories , char [ ] key , int matchRule ) throws IOException { if ( this . memoryIndex . shouldMerge ( ) && this . monitor . exitReadEnterWrite ( ) ) { try { save ( ) ; } finally { this . monitor . exitWriteEnterRead ( ) ; } } HashtableOfObject results ; int rule = matchRule & MATCH_RULE_INDEX_MASK ; if ( this . memoryIndex . hasChanged ( ) ) { results = this . diskIndex . addQueryResults ( categories , key , rule , this . memoryIndex ) ; results = this . memoryIndex . addQueryResults ( categories , key , rule , results ) ; } else { results = this . diskIndex . addQueryResults ( categories , key , rule , null ) ; } if ( results == null ) return null ; EntryResult [ ] entryResults = new EntryResult [ results . elementSize ] ; int count = <NUM_LIT:0> ; Object [ ] values = results . valueTable ; for ( int i = <NUM_LIT:0> , l = values . length ; i < l ; i ++ ) { EntryResult result = ( EntryResult ) values [ i ] ; if ( result != null ) entryResults [ count ++ ] = result ; } return entryResults ; } public String [ ] queryDocumentNames ( String substring ) throws IOException { SimpleSet results ; if ( this . memoryIndex . hasChanged ( ) ) { results = this . diskIndex . addDocumentNames ( substring , this . memoryIndex ) ; this . memoryIndex . addDocumentNames ( substring , results ) ; } else { results = this . diskIndex . addDocumentNames ( substring , null ) ; } if ( results . elementSize == <NUM_LIT:0> ) return null ; String [ ] documentNames = new String [ results . elementSize ] ; int count = <NUM_LIT:0> ; Object [ ] paths = results . values ; for ( int i = <NUM_LIT:0> , l = paths . length ; i < l ; i ++ ) if ( paths [ i ] != null ) documentNames [ count ++ ] = ( String ) paths [ i ] ; return documentNames ; } public void remove ( String containerRelativePath ) { this . memoryIndex . remove ( containerRelativePath ) ; } public void reset ( ) throws IOException { this . memoryIndex = new MemoryIndex ( ) ; this . diskIndex = new DiskIndex ( this . diskIndex . indexFile . getCanonicalPath ( ) ) ; this . diskIndex . initialize ( false ) ; } public void save ( ) throws IOException { if ( ! hasChanged ( ) ) return ; int numberOfChanges = this . memoryIndex . docsToReferences . elementSize ; this . diskIndex . separator = this . separator ; this . diskIndex = this . diskIndex . mergeWith ( this . memoryIndex ) ; this . memoryIndex = new MemoryIndex ( ) ; if ( numberOfChanges > <NUM_LIT:1000> ) System . gc ( ) ; } public void startQuery ( ) { if ( this . diskIndex != null ) this . diskIndex . startQuery ( ) ; } public void stopQuery ( ) { if ( this . diskIndex != null ) this . diskIndex . stopQuery ( ) ; } public String toString ( ) { return "<STR_LIT>" + this . containerPath ; } public boolean isIndexForJar ( ) { return this . separator == JAR_SEPARATOR ; } } </s>
<s> package org . eclipse . jdt . internal . core . search ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . search . * ; public class JavaSearchTypeNameMatch extends TypeNameMatch { private IType type ; private int modifiers = - <NUM_LIT:1> ; private int accessibility = IAccessRule . K_ACCESSIBLE ; public JavaSearchTypeNameMatch ( IType type , int modifiers ) { this . type = type ; this . modifiers = modifiers ; } public boolean equals ( Object obj ) { if ( obj == this ) return true ; if ( obj instanceof TypeNameMatch ) { TypeNameMatch match = ( TypeNameMatch ) obj ; if ( this . type == null ) { return match . getType ( ) == null && match . getModifiers ( ) == this . modifiers ; } return this . type . equals ( match . getType ( ) ) && match . getModifiers ( ) == this . modifiers ; } return false ; } public int getAccessibility ( ) { return this . accessibility ; } public int getModifiers ( ) { return this . modifiers ; } public IType getType ( ) { return this . type ; } public int hashCode ( ) { if ( this . type == null ) return this . modifiers ; return this . type . hashCode ( ) ; } public void setAccessibility ( int accessibility ) { this . accessibility = accessibility ; } public void setModifiers ( int modifiers ) { this . modifiers = modifiers ; } public void setType ( IType type ) { this . type = type ; } public String toString ( ) { if ( this . type == null ) return super . toString ( ) ; return this . type . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . core . search ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; public final class StringOperation { private final static int [ ] EMPTY_REGIONS = new int [ <NUM_LIT:0> ] ; public static final int [ ] getCamelCaseMatchingRegions ( String pattern , int patternStart , int patternEnd , String name , int nameStart , int nameEnd , boolean samePartCount ) { if ( name == null ) return null ; if ( pattern == null ) { return EMPTY_REGIONS ; } if ( patternEnd < <NUM_LIT:0> ) patternEnd = pattern . length ( ) ; if ( nameEnd < <NUM_LIT:0> ) nameEnd = name . length ( ) ; if ( patternEnd <= patternStart ) { return nameEnd <= nameStart ? new int [ ] { patternStart , patternEnd - patternStart } : null ; } if ( nameEnd <= nameStart ) return null ; if ( name . charAt ( nameStart ) != pattern . charAt ( patternStart ) ) { return null ; } char patternChar , nameChar ; int iPattern = patternStart ; int iName = nameStart ; int parts = <NUM_LIT:1> ; for ( int i = patternStart + <NUM_LIT:1> ; i < patternEnd ; i ++ ) { final char ch = pattern . charAt ( i ) ; if ( ch < ScannerHelper . MAX_OBVIOUS ) { if ( ( ScannerHelper . OBVIOUS_IDENT_CHAR_NATURES [ ch ] & ( ScannerHelper . C_UPPER_LETTER | ScannerHelper . C_DIGIT ) ) != <NUM_LIT:0> ) { parts ++ ; } } else if ( Character . isJavaIdentifierPart ( ch ) && ( Character . isUpperCase ( ch ) || Character . isDigit ( ch ) ) ) { parts ++ ; } } int [ ] segments = null ; int count = <NUM_LIT:0> ; int segmentStart = iName ; while ( true ) { iPattern ++ ; iName ++ ; if ( iPattern == patternEnd ) { if ( ! samePartCount || iName == nameEnd ) { if ( segments == null ) { segments = new int [ <NUM_LIT:2> ] ; } segments [ count ++ ] = segmentStart ; segments [ count ++ ] = iName - segmentStart ; if ( count < segments . length ) { System . arraycopy ( segments , <NUM_LIT:0> , segments = new int [ count ] , <NUM_LIT:0> , count ) ; } return segments ; } int segmentEnd = iName ; while ( true ) { if ( iName == nameEnd ) { if ( segments == null ) { segments = new int [ <NUM_LIT:2> ] ; } segments [ count ++ ] = segmentStart ; segments [ count ++ ] = segmentEnd - segmentStart ; if ( count < segments . length ) { System . arraycopy ( segments , <NUM_LIT:0> , segments = new int [ count ] , <NUM_LIT:0> , count ) ; } return segments ; } nameChar = name . charAt ( iName ) ; if ( nameChar < ScannerHelper . MAX_OBVIOUS ) { if ( ( ScannerHelper . OBVIOUS_IDENT_CHAR_NATURES [ nameChar ] & ScannerHelper . C_UPPER_LETTER ) != <NUM_LIT:0> ) { return null ; } } else if ( ! Character . isJavaIdentifierPart ( nameChar ) || Character . isUpperCase ( nameChar ) ) { return null ; } iName ++ ; } } if ( iName == nameEnd ) { return null ; } if ( ( patternChar = pattern . charAt ( iPattern ) ) == name . charAt ( iName ) ) { continue ; } int segmentEnd = iName ; if ( patternChar < ScannerHelper . MAX_OBVIOUS ) { if ( ( ScannerHelper . OBVIOUS_IDENT_CHAR_NATURES [ patternChar ] & ( ScannerHelper . C_UPPER_LETTER | ScannerHelper . C_DIGIT ) ) == <NUM_LIT:0> ) { return null ; } } else if ( Character . isJavaIdentifierPart ( patternChar ) && ! Character . isUpperCase ( patternChar ) && ! Character . isDigit ( patternChar ) ) { return null ; } while ( true ) { if ( iName == nameEnd ) { return null ; } nameChar = name . charAt ( iName ) ; if ( nameChar < ScannerHelper . MAX_OBVIOUS ) { int charNature = ScannerHelper . OBVIOUS_IDENT_CHAR_NATURES [ nameChar ] ; if ( ( charNature & ( ScannerHelper . C_LOWER_LETTER | ScannerHelper . C_SPECIAL ) ) != <NUM_LIT:0> ) { iName ++ ; } else if ( ( charNature & ScannerHelper . C_DIGIT ) != <NUM_LIT:0> ) { if ( patternChar == nameChar ) break ; iName ++ ; } else if ( patternChar != nameChar ) { return null ; } else { break ; } } else if ( Character . isJavaIdentifierPart ( nameChar ) && ! Character . isUpperCase ( nameChar ) ) { iName ++ ; } else if ( Character . isDigit ( nameChar ) ) { if ( patternChar == nameChar ) break ; iName ++ ; } else if ( patternChar != nameChar ) { return null ; } else { break ; } } if ( segments == null ) { segments = new int [ parts * <NUM_LIT:2> ] ; } segments [ count ++ ] = segmentStart ; segments [ count ++ ] = segmentEnd - segmentStart ; segmentStart = iName ; } } public static final int [ ] getPatternMatchingRegions ( String pattern , int patternStart , int patternEnd , String name , int nameStart , int nameEnd , boolean isCaseSensitive ) { if ( name == null ) return null ; if ( pattern == null ) { return EMPTY_REGIONS ; } int iPattern = patternStart ; int iName = nameStart ; if ( patternEnd < <NUM_LIT:0> ) patternEnd = pattern . length ( ) ; if ( nameEnd < <NUM_LIT:0> ) nameEnd = name . length ( ) ; int questions = <NUM_LIT:0> ; int stars = <NUM_LIT:0> ; int parts = <NUM_LIT:0> ; char previous = <NUM_LIT:0> ; for ( int i = patternStart ; i < patternEnd ; i ++ ) { char ch = pattern . charAt ( i ) ; switch ( ch ) { case '<CHAR_LIT>' : questions ++ ; break ; case '<CHAR_LIT>' : stars ++ ; break ; default : switch ( previous ) { case <NUM_LIT:0> : case '<CHAR_LIT>' : case '<CHAR_LIT>' : parts ++ ; break ; } } previous = ch ; } if ( parts == <NUM_LIT:0> ) { if ( questions <= ( nameEnd - nameStart ) ) return EMPTY_REGIONS ; return null ; } int [ ] segments = new int [ parts * <NUM_LIT:2> ] ; int count = <NUM_LIT:0> ; int start = iName ; char patternChar = <NUM_LIT:0> ; previous = <NUM_LIT:0> ; while ( ( iPattern < patternEnd ) && ( patternChar = pattern . charAt ( iPattern ) ) != '<CHAR_LIT>' ) { if ( iName == nameEnd ) return null ; if ( patternChar == '<CHAR_LIT>' ) { switch ( previous ) { case <NUM_LIT:0> : case '<CHAR_LIT>' : break ; default : segments [ count ++ ] = start ; segments [ count ++ ] = iPattern - start ; break ; } } else { if ( isCaseSensitive ) { if ( patternChar != name . charAt ( iName ) ) { return null ; } } else if ( ScannerHelper . toLowerCase ( patternChar ) != ScannerHelper . toLowerCase ( name . charAt ( iName ) ) ) { return null ; } switch ( previous ) { case <NUM_LIT:0> : case '<CHAR_LIT>' : start = iPattern ; break ; } } iName ++ ; iPattern ++ ; previous = patternChar ; } int segmentStart ; if ( patternChar == '<CHAR_LIT>' ) { if ( iPattern > <NUM_LIT:0> && previous != '<CHAR_LIT>' ) { segments [ count ++ ] = start ; segments [ count ++ ] = iName - start ; start = iName ; } segmentStart = ++ iPattern ; } else { if ( iName == nameEnd ) { if ( count == ( parts * <NUM_LIT:2> ) ) return segments ; int end = patternEnd ; if ( previous == '<CHAR_LIT>' ) { while ( pattern . charAt ( -- end - <NUM_LIT:1> ) == '<CHAR_LIT>' ) { if ( end == start ) { return new int [ ] { patternStart , patternEnd - patternStart } ; } } } return new int [ ] { start , end - start } ; } return null ; } int prefixStart = iName ; int previousCount = count ; previous = patternChar ; char previousSegment = patternChar ; checkSegment : while ( iName < nameEnd ) { if ( iPattern == patternEnd ) { iPattern = segmentStart ; iName = ++ prefixStart ; previous = previousSegment ; continue checkSegment ; } if ( ( patternChar = pattern . charAt ( iPattern ) ) == '<CHAR_LIT>' ) { segmentStart = ++ iPattern ; if ( segmentStart == patternEnd ) { if ( count < ( parts * <NUM_LIT:2> ) ) { segments [ count ++ ] = start ; segments [ count ++ ] = iName - start ; } return segments ; } switch ( previous ) { case '<CHAR_LIT>' : case '<CHAR_LIT>' : break ; default : segments [ count ++ ] = start ; segments [ count ++ ] = iName - start ; break ; } prefixStart = iName ; start = prefixStart ; previous = patternChar ; previousSegment = patternChar ; continue checkSegment ; } previousCount = count ; if ( patternChar == '<CHAR_LIT>' ) { switch ( previous ) { case '<CHAR_LIT>' : case '<CHAR_LIT>' : break ; default : segments [ count ++ ] = start ; segments [ count ++ ] = iName - start ; break ; } } else { boolean mismatch ; if ( isCaseSensitive ) { mismatch = name . charAt ( iName ) != patternChar ; } else { mismatch = ScannerHelper . toLowerCase ( name . charAt ( iName ) ) != ScannerHelper . toLowerCase ( patternChar ) ; } if ( mismatch ) { iPattern = segmentStart ; iName = ++ prefixStart ; start = prefixStart ; count = previousCount ; previous = previousSegment ; continue checkSegment ; } switch ( previous ) { case '<CHAR_LIT>' : start = iName ; break ; } } iName ++ ; iPattern ++ ; previous = patternChar ; } if ( ( segmentStart == patternEnd ) || ( iName == nameEnd && iPattern == patternEnd ) || ( iPattern == patternEnd - <NUM_LIT:1> && pattern . charAt ( iPattern ) == '<CHAR_LIT>' ) ) { if ( count < ( parts * <NUM_LIT:2> ) ) { segments [ count ++ ] = start ; segments [ count ++ ] = iName - start ; } return segments ; } return null ; } } </s>
<s> package org . eclipse . jdt . internal . core . search ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . search . IJavaSearchScope ; import org . eclipse . jdt . core . search . SearchDocument ; import org . eclipse . jdt . core . search . SearchParticipant ; import org . eclipse . jdt . internal . core . search . processing . JobManager ; import org . eclipse . jdt . internal . core . util . Util ; public class JavaSearchDocument extends SearchDocument { private IFile file ; protected byte [ ] byteContents ; protected char [ ] charContents ; public JavaSearchDocument ( String documentPath , SearchParticipant participant ) { super ( documentPath , participant ) ; } public JavaSearchDocument ( java . util . zip . ZipEntry zipEntry , IPath zipFilePath , byte [ ] contents , SearchParticipant participant ) { super ( zipFilePath + IJavaSearchScope . JAR_FILE_ENTRY_SEPARATOR + zipEntry . getName ( ) , participant ) ; this . byteContents = contents ; } public byte [ ] getByteContents ( ) { if ( this . byteContents != null ) return this . byteContents ; try { return Util . getResourceContentsAsByteArray ( getFile ( ) ) ; } catch ( JavaModelException e ) { if ( BasicSearchEngine . VERBOSE || JobManager . VERBOSE ) { e . printStackTrace ( ) ; } return null ; } } public char [ ] getCharContents ( ) { if ( this . charContents != null ) return this . charContents ; try { return Util . getResourceContentsAsCharArray ( getFile ( ) ) ; } catch ( JavaModelException e ) { if ( BasicSearchEngine . VERBOSE || JobManager . VERBOSE ) { e . printStackTrace ( ) ; } return null ; } } public String getEncoding ( ) { IFile resource = getFile ( ) ; if ( resource != null ) { try { return resource . getCharset ( ) ; } catch ( CoreException ce ) { try { return ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getDefaultCharset ( ) ; } catch ( CoreException e ) { } } } return null ; } private IFile getFile ( ) { if ( this . file == null ) this . file = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getFile ( new Path ( getPath ( ) ) ) ; return this . file ; } public String toString ( ) { return "<STR_LIT>" + getPath ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . core . search ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Set ; import org . eclipse . core . resources . IFolder ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . IClasspathEntry ; import org . eclipse . jdt . core . IJavaElement ; import org . eclipse . jdt . core . IJavaElementDelta ; import org . eclipse . jdt . core . IJavaProject ; import org . eclipse . jdt . core . IPackageFragmentRoot ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . internal . compiler . env . AccessRuleSet ; import org . eclipse . jdt . internal . core . DeltaProcessor ; import org . eclipse . jdt . internal . core . ExternalFoldersManager ; import org . eclipse . jdt . internal . core . JavaModel ; import org . eclipse . jdt . internal . core . JavaModelManager ; import org . eclipse . jdt . internal . core . JavaProject ; import org . eclipse . jdt . internal . core . util . Util ; public class JavaWorkspaceScope extends AbstractJavaSearchScope { private IPath [ ] enclosingPaths = null ; public JavaWorkspaceScope ( ) { } public boolean encloses ( IJavaElement element ) { return true ; } public boolean encloses ( String resourcePathString ) { return true ; } public IPath [ ] enclosingProjectsAndJars ( ) { IPath [ ] result = this . enclosingPaths ; if ( result != null ) { return result ; } long start = BasicSearchEngine . VERBOSE ? System . currentTimeMillis ( ) : - <NUM_LIT:1> ; try { IJavaProject [ ] projects = JavaModelManager . getJavaModelManager ( ) . getJavaModel ( ) . getJavaProjects ( ) ; Set paths = new HashSet ( projects . length * <NUM_LIT:2> ) ; for ( int i = <NUM_LIT:0> , length = projects . length ; i < length ; i ++ ) { JavaProject javaProject = ( JavaProject ) projects [ i ] ; IPath projectPath = javaProject . getProject ( ) . getFullPath ( ) ; paths . add ( projectPath ) ; IClasspathEntry [ ] entries = javaProject . getResolvedClasspath ( ) ; for ( int j = <NUM_LIT:0> , eLength = entries . length ; j < eLength ; j ++ ) { IClasspathEntry entry = entries [ j ] ; if ( entry . getEntryKind ( ) == IClasspathEntry . CPE_LIBRARY ) { IPath path = entry . getPath ( ) ; Object target = JavaModel . getTarget ( path , false ) ; if ( target instanceof IFolder ) path = ( ( IFolder ) target ) . getFullPath ( ) ; paths . add ( entry . getPath ( ) ) ; } } } result = new IPath [ paths . size ( ) ] ; paths . toArray ( result ) ; return this . enclosingPaths = result ; } catch ( JavaModelException e ) { Util . log ( e , "<STR_LIT>" ) ; return new IPath [ <NUM_LIT:0> ] ; } finally { if ( BasicSearchEngine . VERBOSE ) { long time = System . currentTimeMillis ( ) - start ; int length = result == null ? <NUM_LIT:0> : result . length ; Util . verbose ( "<STR_LIT>" + length + "<STR_LIT>" + time + "<STR_LIT>" ) ; } } } public boolean equals ( Object o ) { return o == this ; } public AccessRuleSet getAccessRuleSet ( String relativePath , String containerPath ) { return null ; } public int hashCode ( ) { return JavaWorkspaceScope . class . hashCode ( ) ; } public IPackageFragmentRoot packageFragmentRoot ( String resourcePathString , int jarSeparatorIndex , String jarPath ) { HashMap rootInfos = JavaModelManager . getDeltaState ( ) . roots ; DeltaProcessor . RootInfo rootInfo = null ; if ( jarPath != null ) { IPath path = new Path ( jarPath ) ; rootInfo = ( DeltaProcessor . RootInfo ) rootInfos . get ( path ) ; } else { IPath path = new Path ( resourcePathString ) ; if ( ExternalFoldersManager . isInternalPathForExternalFolder ( path ) ) { IResource resource = JavaModel . getWorkspaceTarget ( path . uptoSegment ( <NUM_LIT:2> ) ) ; if ( resource != null ) rootInfo = ( DeltaProcessor . RootInfo ) rootInfos . get ( resource . getLocation ( ) ) ; } else { rootInfo = ( DeltaProcessor . RootInfo ) rootInfos . get ( path ) ; while ( rootInfo == null && path . segmentCount ( ) > <NUM_LIT:0> ) { path = path . removeLastSegments ( <NUM_LIT:1> ) ; rootInfo = ( DeltaProcessor . RootInfo ) rootInfos . get ( path ) ; } } } if ( rootInfo == null ) return null ; return rootInfo . getPackageFragmentRoot ( null ) ; } public void processDelta ( IJavaElementDelta delta , int eventType ) { if ( this . enclosingPaths == null ) return ; IJavaElement element = delta . getElement ( ) ; switch ( element . getElementType ( ) ) { case IJavaElement . JAVA_MODEL : IJavaElementDelta [ ] children = delta . getAffectedChildren ( ) ; for ( int i = <NUM_LIT:0> , length = children . length ; i < length ; i ++ ) { IJavaElementDelta child = children [ i ] ; processDelta ( child , eventType ) ; } break ; case IJavaElement . JAVA_PROJECT : int kind = delta . getKind ( ) ; switch ( kind ) { case IJavaElementDelta . ADDED : case IJavaElementDelta . REMOVED : this . enclosingPaths = null ; break ; case IJavaElementDelta . CHANGED : int flags = delta . getFlags ( ) ; if ( ( flags & IJavaElementDelta . F_CLOSED ) != <NUM_LIT:0> || ( flags & IJavaElementDelta . F_OPENED ) != <NUM_LIT:0> ) { this . enclosingPaths = null ; } else { children = delta . getAffectedChildren ( ) ; for ( int i = <NUM_LIT:0> , length = children . length ; i < length ; i ++ ) { IJavaElementDelta child = children [ i ] ; processDelta ( child , eventType ) ; } } break ; } break ; case IJavaElement . PACKAGE_FRAGMENT_ROOT : kind = delta . getKind ( ) ; switch ( kind ) { case IJavaElementDelta . ADDED : case IJavaElementDelta . REMOVED : this . enclosingPaths = null ; break ; case IJavaElementDelta . CHANGED : int flags = delta . getFlags ( ) ; if ( ( flags & IJavaElementDelta . F_ADDED_TO_CLASSPATH ) > <NUM_LIT:0> || ( flags & IJavaElementDelta . F_REMOVED_FROM_CLASSPATH ) > <NUM_LIT:0> ) { this . enclosingPaths = null ; } break ; } break ; } } public String toString ( ) { StringBuffer result = new StringBuffer ( "<STR_LIT>" ) ; IPath [ ] paths = enclosingProjectsAndJars ( ) ; int length = paths == null ? <NUM_LIT:0> : paths . length ; if ( length == <NUM_LIT:0> ) { result . append ( "<STR_LIT>" ) ; } else { result . append ( "<STR_LIT:[>" ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { result . append ( "<STR_LIT>" ) ; result . append ( paths [ i ] ) ; } result . append ( "<STR_LIT>" ) ; } return result . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . core . search ; import org . eclipse . jdt . core . IPackageFragmentRoot ; import org . eclipse . jdt . internal . compiler . env . AccessRuleSet ; public abstract class AbstractJavaSearchScope extends AbstractSearchScope { abstract public AccessRuleSet getAccessRuleSet ( String relativePath , String containerPath ) ; abstract public IPackageFragmentRoot packageFragmentRoot ( String resourcePathString , int jarSeparatorIndex , String jarPath ) ; } </s>
<s> package org . eclipse . jdt . internal . core . search . indexing ; import java . io . IOException ; import java . net . URI ; import java . util . HashSet ; import org . eclipse . core . filesystem . EFS ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . IResourceProxy ; import org . eclipse . core . resources . IResourceProxyVisitor ; import org . eclipse . core . resources . IWorkspaceRoot ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . IClasspathEntry ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . internal . compiler . SourceElementParser ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; import org . eclipse . jdt . internal . core . ClasspathEntry ; import org . eclipse . jdt . internal . core . JavaProject ; import org . eclipse . jdt . internal . core . index . Index ; import org . eclipse . jdt . internal . core . search . processing . JobManager ; import org . eclipse . jdt . internal . core . util . Util ; public class IndexAllProject extends IndexRequest { IProject project ; public IndexAllProject ( IProject project , IndexManager manager ) { super ( project . getFullPath ( ) , manager ) ; this . project = project ; } public boolean equals ( Object o ) { if ( o instanceof IndexAllProject ) return this . project . equals ( ( ( IndexAllProject ) o ) . project ) ; return false ; } public boolean execute ( IProgressMonitor progressMonitor ) { if ( this . isCancelled || progressMonitor != null && progressMonitor . isCanceled ( ) ) return true ; if ( ! this . project . isAccessible ( ) ) return true ; ReadWriteMonitor monitor = null ; try { JavaProject javaProject = ( JavaProject ) JavaCore . create ( this . project ) ; IClasspathEntry [ ] entries = javaProject . getRawClasspath ( ) ; int length = entries . length ; IClasspathEntry [ ] sourceEntries = new IClasspathEntry [ length ] ; int sourceEntriesNumber = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IClasspathEntry entry = entries [ i ] ; if ( entry . getEntryKind ( ) == IClasspathEntry . CPE_SOURCE ) sourceEntries [ sourceEntriesNumber ++ ] = entry ; } if ( sourceEntriesNumber == <NUM_LIT:0> ) { IPath projectPath = javaProject . getPath ( ) ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { IClasspathEntry entry = entries [ i ] ; if ( entry . getEntryKind ( ) == IClasspathEntry . CPE_LIBRARY && entry . getPath ( ) . equals ( projectPath ) ) { this . manager . indexLibrary ( projectPath , this . project ) ; return true ; } } Index index = this . manager . getIndexForUpdate ( this . containerPath , true , true ) ; if ( index != null ) this . manager . saveIndex ( index ) ; return true ; } if ( sourceEntriesNumber != length ) System . arraycopy ( sourceEntries , <NUM_LIT:0> , sourceEntries = new IClasspathEntry [ sourceEntriesNumber ] , <NUM_LIT:0> , sourceEntriesNumber ) ; Index index = this . manager . getIndexForUpdate ( this . containerPath , true , true ) ; if ( index == null ) return true ; monitor = index . monitor ; if ( monitor == null ) return true ; monitor . enterRead ( ) ; String [ ] paths = index . queryDocumentNames ( "<STR_LIT>" ) ; int max = paths == null ? <NUM_LIT:0> : paths . length ; final SimpleLookupTable indexedFileNames = new SimpleLookupTable ( max == <NUM_LIT:0> ? <NUM_LIT> : max + <NUM_LIT:11> ) ; final String OK = "<STR_LIT:OK>" ; final String DELETED = "<STR_LIT>" ; if ( paths != null ) { for ( int i = <NUM_LIT:0> ; i < max ; i ++ ) indexedFileNames . put ( paths [ i ] , DELETED ) ; } final long indexLastModified = max == <NUM_LIT:0> ? <NUM_LIT> : index . getIndexFile ( ) . lastModified ( ) ; IWorkspaceRoot root = this . project . getWorkspace ( ) . getRoot ( ) ; for ( int i = <NUM_LIT:0> ; i < sourceEntriesNumber ; i ++ ) { if ( this . isCancelled ) return false ; IClasspathEntry entry = sourceEntries [ i ] ; IResource sourceFolder = root . findMember ( entry . getPath ( ) ) ; if ( sourceFolder != null ) { final HashSet outputs = new HashSet ( ) ; if ( sourceFolder . getType ( ) == IResource . PROJECT ) { outputs . add ( javaProject . getOutputLocation ( ) ) ; for ( int j = <NUM_LIT:0> ; j < sourceEntriesNumber ; j ++ ) { IPath output = sourceEntries [ j ] . getOutputLocation ( ) ; if ( output != null ) { outputs . add ( output ) ; } } } final boolean hasOutputs = ! outputs . isEmpty ( ) ; final char [ ] [ ] inclusionPatterns = ( ( ClasspathEntry ) entry ) . fullInclusionPatternChars ( ) ; final char [ ] [ ] exclusionPatterns = ( ( ClasspathEntry ) entry ) . fullExclusionPatternChars ( ) ; if ( max == <NUM_LIT:0> ) { sourceFolder . accept ( new IResourceProxyVisitor ( ) { public boolean visit ( IResourceProxy proxy ) { if ( IndexAllProject . this . isCancelled ) return false ; switch ( proxy . getType ( ) ) { case IResource . FILE : if ( org . eclipse . jdt . internal . core . util . Util . isJavaLikeFileName ( proxy . getName ( ) ) ) { IFile file = ( IFile ) proxy . requestResource ( ) ; if ( exclusionPatterns != null || inclusionPatterns != null ) if ( Util . isExcluded ( file , inclusionPatterns , exclusionPatterns ) ) return false ; indexedFileNames . put ( Util . relativePath ( file . getFullPath ( ) , <NUM_LIT:1> ) , file ) ; } return false ; case IResource . FOLDER : if ( exclusionPatterns != null && inclusionPatterns == null ) { if ( Util . isExcluded ( proxy . requestFullPath ( ) , inclusionPatterns , exclusionPatterns , true ) ) return false ; } if ( hasOutputs && outputs . contains ( proxy . requestFullPath ( ) ) ) return false ; } return true ; } } , IResource . NONE ) ; } else { sourceFolder . accept ( new IResourceProxyVisitor ( ) { public boolean visit ( IResourceProxy proxy ) throws CoreException { if ( IndexAllProject . this . isCancelled ) return false ; switch ( proxy . getType ( ) ) { case IResource . FILE : if ( org . eclipse . jdt . internal . core . util . Util . isJavaLikeFileName ( proxy . getName ( ) ) ) { IFile file = ( IFile ) proxy . requestResource ( ) ; URI location = file . getLocationURI ( ) ; if ( location == null ) return false ; if ( exclusionPatterns != null || inclusionPatterns != null ) if ( Util . isExcluded ( file , inclusionPatterns , exclusionPatterns ) ) return false ; String relativePathString = Util . relativePath ( file . getFullPath ( ) , <NUM_LIT:1> ) ; indexedFileNames . put ( relativePathString , indexedFileNames . get ( relativePathString ) == null || indexLastModified < EFS . getStore ( location ) . fetchInfo ( ) . getLastModified ( ) ? ( Object ) file : ( Object ) OK ) ; } return false ; case IResource . FOLDER : if ( exclusionPatterns != null || inclusionPatterns != null ) if ( Util . isExcluded ( proxy . requestResource ( ) , inclusionPatterns , exclusionPatterns ) ) return false ; if ( hasOutputs && outputs . contains ( proxy . requestFullPath ( ) ) ) return false ; } return true ; } } , IResource . NONE ) ; } } } SourceElementParser parser = this . manager . getSourceElementParser ( javaProject , null ) ; Object [ ] names = indexedFileNames . keyTable ; Object [ ] values = indexedFileNames . valueTable ; for ( int i = <NUM_LIT:0> , namesLength = names . length ; i < namesLength ; i ++ ) { String name = ( String ) names [ i ] ; if ( name != null ) { if ( this . isCancelled ) return false ; Object value = values [ i ] ; if ( value != OK ) { if ( value == DELETED ) this . manager . remove ( name , this . containerPath ) ; else this . manager . addSource ( ( IFile ) value , this . containerPath , parser ) ; } } } this . manager . request ( new SaveIndex ( this . containerPath , this . manager ) ) ; } catch ( CoreException e ) { if ( JobManager . VERBOSE ) { Util . verbose ( "<STR_LIT>" + this . project + "<STR_LIT>" , System . err ) ; e . printStackTrace ( ) ; } this . manager . removeIndex ( this . containerPath ) ; return false ; } catch ( IOException e ) { if ( JobManager . VERBOSE ) { Util . verbose ( "<STR_LIT>" + this . project + "<STR_LIT>" , System . err ) ; e . printStackTrace ( ) ; } this . manager . removeIndex ( this . containerPath ) ; return false ; } finally { if ( monitor != null ) monitor . exitRead ( ) ; } return true ; } public int hashCode ( ) { return this . project . hashCode ( ) ; } protected Integer updatedIndexState ( ) { return IndexManager . REBUILDING_STATE ; } public String toString ( ) { return "<STR_LIT>" + this . project . getFullPath ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . core . search . indexing ; import java . io . * ; import java . util . * ; import java . util . zip . CRC32 ; import org . codehaus . jdt . groovy . integration . LanguageSupportFactory ; import org . eclipse . core . resources . * ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . OperationCanceledException ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . search . * ; import org . eclipse . jdt . internal . compiler . ISourceElementRequestor ; import org . eclipse . jdt . internal . compiler . SourceElementParser ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . problem . DefaultProblemFactory ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; import org . eclipse . jdt . internal . compiler . util . SimpleSet ; import org . eclipse . jdt . internal . core . * ; import org . eclipse . jdt . internal . core . index . * ; import org . eclipse . jdt . internal . core . search . BasicSearchEngine ; import org . eclipse . jdt . internal . core . search . PatternSearchJob ; import org . eclipse . jdt . internal . core . search . processing . IJob ; import org . eclipse . jdt . internal . core . search . processing . JobManager ; import org . eclipse . jdt . internal . core . util . Messages ; import org . eclipse . jdt . internal . core . util . Util ; public class IndexManager extends JobManager implements IIndexConstants { public SimpleLookupTable indexLocations = new SimpleLookupTable ( ) ; private SimpleLookupTable indexes = new SimpleLookupTable ( ) ; private boolean needToSave = false ; private IPath javaPluginLocation = null ; private SimpleLookupTable indexStates = null ; private File savedIndexNamesFile = new File ( getSavedIndexesDirectory ( ) , "<STR_LIT>" ) ; private File participantIndexNamesFile = new File ( getSavedIndexesDirectory ( ) , "<STR_LIT>" ) ; private boolean javaLikeNamesChanged = true ; public static final Integer SAVED_STATE = new Integer ( <NUM_LIT:0> ) ; public static final Integer UPDATING_STATE = new Integer ( <NUM_LIT:1> ) ; public static final Integer UNKNOWN_STATE = new Integer ( <NUM_LIT:2> ) ; public static final Integer REBUILDING_STATE = new Integer ( <NUM_LIT:3> ) ; private SimpleLookupTable participantsContainers = null ; private boolean participantUpdated = false ; public static boolean DEBUG = false ; public synchronized void aboutToUpdateIndex ( IPath containerPath , Integer newIndexState ) { IPath indexLocation = computeIndexLocation ( containerPath ) ; Object state = getIndexStates ( ) . get ( indexLocation ) ; Integer currentIndexState = state == null ? UNKNOWN_STATE : ( Integer ) state ; if ( currentIndexState . equals ( REBUILDING_STATE ) ) return ; int compare = newIndexState . compareTo ( currentIndexState ) ; if ( compare > <NUM_LIT:0> ) { updateIndexState ( indexLocation , newIndexState ) ; } else if ( compare < <NUM_LIT:0> && this . indexes . get ( indexLocation ) == null ) { rebuildIndex ( indexLocation , containerPath ) ; } } public void addBinary ( IFile resource , IPath containerPath ) { if ( JavaCore . getPlugin ( ) == null ) return ; SearchParticipant participant = SearchEngine . getDefaultSearchParticipant ( ) ; SearchDocument document = participant . getDocument ( resource . getFullPath ( ) . toString ( ) ) ; IPath indexLocation = computeIndexLocation ( containerPath ) ; scheduleDocumentIndexing ( document , containerPath , indexLocation , participant ) ; } public void addSource ( IFile resource , IPath containerPath , SourceElementParser parser ) { if ( JavaCore . getPlugin ( ) == null ) return ; SearchParticipant participant = SearchEngine . getDefaultSearchParticipant ( ) ; SearchDocument document = participant . getDocument ( resource . getFullPath ( ) . toString ( ) ) ; document . setParser ( parser ) ; IPath indexLocation = computeIndexLocation ( containerPath ) ; scheduleDocumentIndexing ( document , containerPath , indexLocation , participant ) ; } public void cleanUpIndexes ( ) { SimpleSet knownPaths = new SimpleSet ( ) ; IJavaSearchScope scope = BasicSearchEngine . createWorkspaceScope ( ) ; PatternSearchJob job = new PatternSearchJob ( null , SearchEngine . getDefaultSearchParticipant ( ) , scope , null ) ; Index [ ] selectedIndexes = job . getIndexes ( null ) ; for ( int i = <NUM_LIT:0> , l = selectedIndexes . length ; i < l ; i ++ ) { String path = selectedIndexes [ i ] . getIndexFile ( ) . getAbsolutePath ( ) ; knownPaths . add ( path ) ; } if ( this . indexStates != null ) { Object [ ] keys = this . indexStates . keyTable ; IPath [ ] locations = new IPath [ this . indexStates . elementSize ] ; int count = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> , l = keys . length ; i < l ; i ++ ) { IPath key = ( IPath ) keys [ i ] ; if ( key != null && ! knownPaths . includes ( key . toOSString ( ) ) ) locations [ count ++ ] = key ; } if ( count > <NUM_LIT:0> ) removeIndexesState ( locations ) ; } deleteIndexFiles ( knownPaths ) ; } public IPath computeIndexLocation ( IPath containerPath ) { IPath indexLocation = ( IPath ) this . indexLocations . get ( containerPath ) ; if ( indexLocation == null ) { String pathString = containerPath . toOSString ( ) ; CRC32 checksumCalculator = new CRC32 ( ) ; checksumCalculator . update ( pathString . getBytes ( ) ) ; String fileName = Long . toString ( checksumCalculator . getValue ( ) ) + "<STR_LIT>" ; if ( VERBOSE ) Util . verbose ( "<STR_LIT>" + pathString + "<STR_LIT>" + fileName ) ; indexLocation = ( IPath ) getIndexStates ( ) . getKey ( getJavaPluginWorkingLocation ( ) . append ( fileName ) ) ; this . indexLocations . put ( containerPath , indexLocation ) ; } return indexLocation ; } public void deleteIndexFiles ( ) { if ( DEBUG ) Util . verbose ( "<STR_LIT>" ) ; this . savedIndexNamesFile . delete ( ) ; deleteIndexFiles ( null ) ; } private void deleteIndexFiles ( SimpleSet pathsToKeep ) { File [ ] indexesFiles = getSavedIndexesDirectory ( ) . listFiles ( ) ; if ( indexesFiles == null ) return ; for ( int i = <NUM_LIT:0> , l = indexesFiles . length ; i < l ; i ++ ) { String fileName = indexesFiles [ i ] . getAbsolutePath ( ) ; if ( pathsToKeep != null && pathsToKeep . includes ( fileName ) ) continue ; String suffix = "<STR_LIT>" ; if ( fileName . regionMatches ( true , fileName . length ( ) - suffix . length ( ) , suffix , <NUM_LIT:0> , suffix . length ( ) ) ) { if ( VERBOSE || DEBUG ) Util . verbose ( "<STR_LIT>" + indexesFiles [ i ] ) ; indexesFiles [ i ] . delete ( ) ; } } } public void ensureIndexExists ( IPath indexLocation , IPath containerPath ) { SimpleLookupTable states = getIndexStates ( ) ; Object state = states . get ( indexLocation ) ; if ( state == null ) { updateIndexState ( indexLocation , REBUILDING_STATE ) ; getIndex ( containerPath , indexLocation , true , true ) ; } } public SourceElementParser getSourceElementParser ( IJavaProject project , ISourceElementRequestor requestor ) { Map options = project . getOptions ( true ) ; options . put ( JavaCore . COMPILER_TASK_TAGS , "<STR_LIT>" ) ; SourceElementParser parser = LanguageSupportFactory . getIndexingParser ( requestor , new DefaultProblemFactory ( Locale . getDefault ( ) ) , new CompilerOptions ( options ) , true , true , false ) ; parser . reportOnlyOneSyntaxError = true ; parser . javadocParser . checkDocComment = true ; parser . javadocParser . reportProblems = false ; return parser ; } public synchronized Index getIndex ( IPath indexLocation ) { return ( Index ) this . indexes . get ( indexLocation ) ; } public synchronized Index getIndex ( IPath containerPath , boolean reuseExistingFile , boolean createIfMissing ) { IPath indexLocation = computeIndexLocation ( containerPath ) ; return getIndex ( containerPath , indexLocation , reuseExistingFile , createIfMissing ) ; } public synchronized Index getIndex ( IPath containerPath , IPath indexLocation , boolean reuseExistingFile , boolean createIfMissing ) { Index index = getIndex ( indexLocation ) ; if ( index == null ) { Object state = getIndexStates ( ) . get ( indexLocation ) ; Integer currentIndexState = state == null ? UNKNOWN_STATE : ( Integer ) state ; if ( currentIndexState == UNKNOWN_STATE ) { rebuildIndex ( indexLocation , containerPath ) ; return null ; } String containerPathString = containerPath . getDevice ( ) == null ? containerPath . toString ( ) : containerPath . toOSString ( ) ; String indexLocationString = indexLocation . toOSString ( ) ; if ( reuseExistingFile ) { File indexFile = new File ( indexLocationString ) ; if ( indexFile . exists ( ) ) { try { index = new Index ( indexLocationString , containerPathString , true ) ; this . indexes . put ( indexLocation , index ) ; return index ; } catch ( IOException e ) { if ( currentIndexState != REBUILDING_STATE ) { if ( VERBOSE ) Util . verbose ( "<STR_LIT>" + indexLocationString + "<STR_LIT>" + containerPathString ) ; rebuildIndex ( indexLocation , containerPath ) ; return null ; } } } if ( currentIndexState == SAVED_STATE ) { rebuildIndex ( indexLocation , containerPath ) ; return null ; } } if ( createIfMissing ) { try { if ( VERBOSE ) Util . verbose ( "<STR_LIT>" + indexLocationString + "<STR_LIT>" + containerPathString ) ; index = new Index ( indexLocationString , containerPathString , false ) ; this . indexes . put ( indexLocation , index ) ; return index ; } catch ( IOException e ) { if ( VERBOSE ) Util . verbose ( "<STR_LIT>" + indexLocationString + "<STR_LIT>" + containerPathString ) ; return null ; } } } return index ; } public Index [ ] getIndexes ( IPath [ ] locations , IProgressMonitor progressMonitor ) { int length = locations . length ; Index [ ] locatedIndexes = new Index [ length ] ; int count = <NUM_LIT:0> ; if ( this . javaLikeNamesChanged ) { this . javaLikeNamesChanged = hasJavaLikeNamesChanged ( ) ; } for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( progressMonitor != null && progressMonitor . isCanceled ( ) ) { throw new OperationCanceledException ( ) ; } IPath indexLocation = locations [ i ] ; Index index = getIndex ( indexLocation ) ; if ( index == null ) { IPath containerPath = ( IPath ) this . indexLocations . keyForValue ( indexLocation ) ; if ( containerPath != null ) { index = getIndex ( containerPath , indexLocation , true , false ) ; if ( index != null && this . javaLikeNamesChanged && ! index . isIndexForJar ( ) ) { File indexFile = index . getIndexFile ( ) ; if ( indexFile . exists ( ) ) { if ( DEBUG ) Util . verbose ( "<STR_LIT>" + containerPath ) ; indexFile . delete ( ) ; } this . indexes . put ( indexLocation , null ) ; rebuildIndex ( indexLocation , containerPath ) ; index = null ; } } else { if ( ! getJavaPluginWorkingLocation ( ) . isPrefixOf ( indexLocation ) ) { if ( indexLocation . toFile ( ) . exists ( ) ) { try { IPath container = getParticipantsContainer ( indexLocation ) ; if ( container != null ) { index = new Index ( indexLocation . toOSString ( ) , container . toOSString ( ) , true ) ; this . indexes . put ( indexLocation , index ) ; } } catch ( IOException e ) { } } } } } if ( index != null ) locatedIndexes [ count ++ ] = index ; } if ( this . javaLikeNamesChanged ) { writeJavaLikeNamesFile ( ) ; this . javaLikeNamesChanged = false ; } if ( count < length ) { System . arraycopy ( locatedIndexes , <NUM_LIT:0> , locatedIndexes = new Index [ count ] , <NUM_LIT:0> , count ) ; } return locatedIndexes ; } public synchronized Index getIndexForUpdate ( IPath containerPath , boolean reuseExistingFile , boolean createIfMissing ) { IPath indexLocation = computeIndexLocation ( containerPath ) ; if ( getIndexStates ( ) . get ( indexLocation ) == REBUILDING_STATE ) return getIndex ( containerPath , indexLocation , reuseExistingFile , createIfMissing ) ; return null ; } private SimpleLookupTable getIndexStates ( ) { if ( this . indexStates != null ) return this . indexStates ; this . indexStates = new SimpleLookupTable ( ) ; IPath indexesDirectoryPath = getJavaPluginWorkingLocation ( ) ; char [ ] [ ] savedNames = readIndexState ( indexesDirectoryPath . toOSString ( ) ) ; if ( savedNames != null ) { for ( int i = <NUM_LIT:1> , l = savedNames . length ; i < l ; i ++ ) { char [ ] savedName = savedNames [ i ] ; if ( savedName . length > <NUM_LIT:0> ) { IPath indexLocation = indexesDirectoryPath . append ( new String ( savedName ) ) ; if ( VERBOSE ) Util . verbose ( "<STR_LIT>" + indexLocation ) ; this . indexStates . put ( indexLocation , SAVED_STATE ) ; } } } else { writeJavaLikeNamesFile ( ) ; this . javaLikeNamesChanged = false ; deleteIndexFiles ( ) ; } return this . indexStates ; } private IPath getParticipantsContainer ( IPath indexLocation ) { if ( this . participantsContainers == null ) { readParticipantsIndexNamesFile ( ) ; } return ( IPath ) this . participantsContainers . get ( indexLocation ) ; } private IPath getJavaPluginWorkingLocation ( ) { if ( this . javaPluginLocation != null ) return this . javaPluginLocation ; IPath stateLocation = JavaCore . getPlugin ( ) . getStateLocation ( ) ; return this . javaPluginLocation = stateLocation ; } private File getSavedIndexesDirectory ( ) { return new File ( getJavaPluginWorkingLocation ( ) . toOSString ( ) ) ; } private boolean hasJavaLikeNamesChanged ( ) { char [ ] [ ] currentNames = Util . getJavaLikeExtensions ( ) ; int current = currentNames . length ; char [ ] [ ] prevNames = readJavaLikeNamesFile ( ) ; if ( prevNames == null ) { if ( VERBOSE && current != <NUM_LIT:1> ) Util . verbose ( "<STR_LIT>" , System . err ) ; return ( current != <NUM_LIT:1> ) ; } int prev = prevNames . length ; if ( current != prev ) { if ( VERBOSE ) Util . verbose ( "<STR_LIT>" , System . err ) ; return true ; } if ( current > <NUM_LIT:1> ) { System . arraycopy ( currentNames , <NUM_LIT:0> , currentNames = new char [ current ] [ ] , <NUM_LIT:0> , current ) ; Util . sort ( currentNames ) ; } for ( int i = <NUM_LIT:0> ; i < current ; i ++ ) { if ( ! CharOperation . equals ( currentNames [ i ] , prevNames [ i ] ) ) { if ( VERBOSE ) Util . verbose ( "<STR_LIT>" , System . err ) ; return true ; } } return false ; } public void indexDocument ( SearchDocument searchDocument , SearchParticipant searchParticipant , Index index , IPath indexLocation ) { try { searchDocument . setIndex ( index ) ; searchParticipant . indexDocument ( searchDocument , indexLocation ) ; } finally { searchDocument . setIndex ( null ) ; } } public void indexAll ( IProject project ) { if ( JavaCore . getPlugin ( ) == null ) return ; try { JavaModel model = JavaModelManager . getJavaModelManager ( ) . getJavaModel ( ) ; JavaProject javaProject = ( JavaProject ) model . getJavaProject ( project ) ; IClasspathEntry [ ] entries = javaProject . getResolvedClasspath ( ) ; for ( int i = <NUM_LIT:0> ; i < entries . length ; i ++ ) { IClasspathEntry entry = entries [ i ] ; if ( entry . getEntryKind ( ) == IClasspathEntry . CPE_LIBRARY ) indexLibrary ( entry . getPath ( ) , project ) ; } } catch ( JavaModelException e ) { } IndexRequest request = new IndexAllProject ( project , this ) ; if ( ! isJobWaiting ( request ) ) request ( request ) ; } public void indexLibrary ( IPath path , IProject requestingProject ) { if ( JavaCore . getPlugin ( ) == null ) return ; Object target = JavaModel . getTarget ( path , true ) ; IndexRequest request = null ; if ( target instanceof IFile ) { request = new AddJarFileToIndex ( ( IFile ) target , this ) ; } else if ( target instanceof File ) { request = new AddJarFileToIndex ( path , this ) ; } else if ( target instanceof IContainer ) { request = new IndexBinaryFolder ( ( IContainer ) target , this ) ; } else { return ; } if ( ! isJobWaiting ( request ) ) request ( request ) ; } public void indexSourceFolder ( JavaProject javaProject , IPath sourceFolder , char [ ] [ ] inclusionPatterns , char [ ] [ ] exclusionPatterns ) { IProject project = javaProject . getProject ( ) ; if ( this . jobEnd > this . jobStart ) { IndexRequest request = new IndexAllProject ( project , this ) ; if ( isJobWaiting ( request ) ) return ; } request ( new AddFolderToIndex ( sourceFolder , project , inclusionPatterns , exclusionPatterns , this ) ) ; } public synchronized void jobWasCancelled ( IPath containerPath ) { IPath indexLocation = computeIndexLocation ( containerPath ) ; Index index = getIndex ( indexLocation ) ; if ( index != null ) { index . monitor = null ; this . indexes . removeKey ( indexLocation ) ; } updateIndexState ( indexLocation , UNKNOWN_STATE ) ; } protected synchronized void moveToNextJob ( ) { this . needToSave = true ; super . moveToNextJob ( ) ; } protected void notifyIdle ( long idlingTime ) { if ( idlingTime > <NUM_LIT:1000> && this . needToSave ) saveIndexes ( ) ; } public String processName ( ) { return Messages . process_name ; } private char [ ] [ ] readJavaLikeNamesFile ( ) { try { String pathName = getJavaPluginWorkingLocation ( ) . toOSString ( ) ; File javaLikeNamesFile = new File ( pathName , "<STR_LIT>" ) ; if ( ! javaLikeNamesFile . exists ( ) ) return null ; char [ ] javaLikeNames = org . eclipse . jdt . internal . compiler . util . Util . getFileCharContent ( javaLikeNamesFile , null ) ; if ( javaLikeNames . length > <NUM_LIT:0> ) { char [ ] [ ] names = CharOperation . splitOn ( '<STR_LIT:\n>' , javaLikeNames ) ; return names ; } } catch ( IOException ignored ) { if ( VERBOSE ) Util . verbose ( "<STR_LIT>" ) ; } return null ; } private void rebuildIndex ( IPath indexLocation , IPath containerPath ) { Object target = JavaModel . getTarget ( containerPath , true ) ; if ( target == null ) return ; if ( VERBOSE ) Util . verbose ( "<STR_LIT>" + indexLocation + "<STR_LIT>" + containerPath ) ; updateIndexState ( indexLocation , REBUILDING_STATE ) ; IndexRequest request = null ; if ( target instanceof IProject ) { IProject p = ( IProject ) target ; if ( JavaProject . hasJavaNature ( p ) ) request = new IndexAllProject ( p , this ) ; } else if ( target instanceof IFolder ) { request = new IndexBinaryFolder ( ( IFolder ) target , this ) ; } else if ( target instanceof IFile ) { request = new AddJarFileToIndex ( ( IFile ) target , this ) ; } else if ( target instanceof File ) { request = new AddJarFileToIndex ( containerPath , this ) ; } if ( request != null ) request ( request ) ; } public synchronized Index recreateIndex ( IPath containerPath ) { String containerPathString = containerPath . getDevice ( ) == null ? containerPath . toString ( ) : containerPath . toOSString ( ) ; try { IPath indexLocation = computeIndexLocation ( containerPath ) ; Index index = getIndex ( indexLocation ) ; ReadWriteMonitor monitor = index == null ? null : index . monitor ; if ( VERBOSE ) Util . verbose ( "<STR_LIT>" + indexLocation + "<STR_LIT>" + containerPathString ) ; index = new Index ( indexLocation . toOSString ( ) , containerPathString , false ) ; this . indexes . put ( indexLocation , index ) ; index . monitor = monitor ; return index ; } catch ( IOException e ) { if ( VERBOSE ) { Util . verbose ( "<STR_LIT>" + containerPathString ) ; e . printStackTrace ( ) ; } return null ; } } public void remove ( String containerRelativePath , IPath indexedContainer ) { request ( new RemoveFromIndex ( containerRelativePath , indexedContainer , this ) ) ; } public synchronized void removeIndex ( IPath containerPath ) { if ( VERBOSE || DEBUG ) Util . verbose ( "<STR_LIT>" + containerPath ) ; IPath indexLocation = computeIndexLocation ( containerPath ) ; Index index = getIndex ( indexLocation ) ; File indexFile = null ; if ( index != null ) { index . monitor = null ; indexFile = index . getIndexFile ( ) ; } if ( indexFile == null ) indexFile = new File ( indexLocation . toOSString ( ) ) ; if ( indexFile . exists ( ) ) { if ( DEBUG ) Util . verbose ( "<STR_LIT>" + indexFile ) ; indexFile . delete ( ) ; } this . indexes . removeKey ( indexLocation ) ; updateIndexState ( indexLocation , null ) ; } public synchronized void removeIndexPath ( IPath path ) { if ( VERBOSE || DEBUG ) Util . verbose ( "<STR_LIT>" + path ) ; Object [ ] keyTable = this . indexes . keyTable ; Object [ ] valueTable = this . indexes . valueTable ; IPath [ ] locations = null ; int max = this . indexes . elementSize ; int count = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> , l = keyTable . length ; i < l ; i ++ ) { IPath indexLocation = ( IPath ) keyTable [ i ] ; if ( indexLocation == null ) continue ; if ( path . isPrefixOf ( indexLocation ) ) { Index index = ( Index ) valueTable [ i ] ; index . monitor = null ; if ( locations == null ) locations = new IPath [ max ] ; locations [ count ++ ] = indexLocation ; File indexFile = index . getIndexFile ( ) ; if ( indexFile . exists ( ) ) { if ( DEBUG ) Util . verbose ( "<STR_LIT>" + indexFile ) ; indexFile . delete ( ) ; } } else { max -- ; } } if ( locations != null ) { for ( int i = <NUM_LIT:0> ; i < count ; i ++ ) this . indexes . removeKey ( locations [ i ] ) ; removeIndexesState ( locations ) ; if ( this . participantsContainers != null && this . participantsContainers . get ( path . toOSString ( ) ) != null ) { this . participantsContainers . removeKey ( path . toOSString ( ) ) ; writeParticipantsIndexNamesFile ( ) ; } } } public synchronized void removeIndexFamily ( IPath path ) { ArrayList toRemove = null ; Object [ ] containerPaths = this . indexLocations . keyTable ; for ( int i = <NUM_LIT:0> , length = containerPaths . length ; i < length ; i ++ ) { IPath containerPath = ( IPath ) containerPaths [ i ] ; if ( containerPath == null ) continue ; if ( path . isPrefixOf ( containerPath ) ) { if ( toRemove == null ) toRemove = new ArrayList ( ) ; toRemove . add ( containerPath ) ; } } if ( toRemove != null ) for ( int i = <NUM_LIT:0> , length = toRemove . size ( ) ; i < length ; i ++ ) removeIndex ( ( IPath ) toRemove . get ( i ) ) ; } public void removeSourceFolderFromIndex ( JavaProject javaProject , IPath sourceFolder , char [ ] [ ] inclusionPatterns , char [ ] [ ] exclusionPatterns ) { IProject project = javaProject . getProject ( ) ; if ( this . jobEnd > this . jobStart ) { IndexRequest request = new IndexAllProject ( project , this ) ; if ( isJobWaiting ( request ) ) return ; } request ( new RemoveFolderFromIndex ( sourceFolder , inclusionPatterns , exclusionPatterns , project , this ) ) ; } public synchronized void reset ( ) { super . reset ( ) ; if ( this . indexes != null ) { this . indexes = new SimpleLookupTable ( ) ; this . indexStates = null ; } this . indexLocations = new SimpleLookupTable ( ) ; this . javaPluginLocation = null ; } public synchronized boolean resetIndex ( IPath containerPath ) { String containerPathString = containerPath . getDevice ( ) == null ? containerPath . toString ( ) : containerPath . toOSString ( ) ; try { IPath indexLocation = computeIndexLocation ( containerPath ) ; Index index = getIndex ( indexLocation ) ; if ( VERBOSE ) { Util . verbose ( "<STR_LIT>" + indexLocation + "<STR_LIT>" + containerPathString ) ; } if ( index == null ) { return recreateIndex ( containerPath ) != null ; } index . reset ( ) ; return true ; } catch ( IOException e ) { if ( VERBOSE ) { Util . verbose ( "<STR_LIT>" + containerPathString ) ; e . printStackTrace ( ) ; } return false ; } } public void saveIndex ( Index index ) throws IOException { if ( index . hasChanged ( ) ) { if ( VERBOSE ) Util . verbose ( "<STR_LIT>" + index . getIndexFile ( ) ) ; index . save ( ) ; } synchronized ( this ) { IPath containerPath = new Path ( index . containerPath ) ; if ( this . jobEnd > this . jobStart ) { for ( int i = this . jobEnd ; i > this . jobStart ; i -- ) { IJob job = this . awaitingJobs [ i ] ; if ( job instanceof IndexRequest ) if ( ( ( IndexRequest ) job ) . containerPath . equals ( containerPath ) ) return ; } } IPath indexLocation = computeIndexLocation ( containerPath ) ; updateIndexState ( indexLocation , SAVED_STATE ) ; } } public void saveIndexes ( ) { ArrayList toSave = new ArrayList ( ) ; synchronized ( this ) { Object [ ] valueTable = this . indexes . valueTable ; for ( int i = <NUM_LIT:0> , l = valueTable . length ; i < l ; i ++ ) { Index index = ( Index ) valueTable [ i ] ; if ( index != null ) toSave . add ( index ) ; } } boolean allSaved = true ; for ( int i = <NUM_LIT:0> , length = toSave . size ( ) ; i < length ; i ++ ) { Index index = ( Index ) toSave . get ( i ) ; ReadWriteMonitor monitor = index . monitor ; if ( monitor == null ) continue ; try { monitor . enterRead ( ) ; if ( index . hasChanged ( ) ) { if ( monitor . exitReadEnterWrite ( ) ) { try { saveIndex ( index ) ; } catch ( IOException e ) { if ( VERBOSE ) { Util . verbose ( "<STR_LIT>" , System . err ) ; e . printStackTrace ( ) ; } allSaved = false ; } finally { monitor . exitWriteEnterRead ( ) ; } } else { allSaved = false ; } } } finally { monitor . exitRead ( ) ; } } if ( this . participantsContainers != null && this . participantUpdated ) { writeParticipantsIndexNamesFile ( ) ; this . participantUpdated = false ; } this . needToSave = ! allSaved ; } public void scheduleDocumentIndexing ( final SearchDocument searchDocument , IPath container , final IPath indexLocation , final SearchParticipant searchParticipant ) { request ( new IndexRequest ( container , this ) { public boolean execute ( IProgressMonitor progressMonitor ) { if ( this . isCancelled || progressMonitor != null && progressMonitor . isCanceled ( ) ) return true ; Index index = getIndex ( this . containerPath , indexLocation , true , true ) ; if ( index == null ) return true ; ReadWriteMonitor monitor = index . monitor ; if ( monitor == null ) return true ; try { monitor . enterWrite ( ) ; indexDocument ( searchDocument , searchParticipant , index , indexLocation ) ; } finally { monitor . exitWrite ( ) ; } return true ; } public String toString ( ) { return "<STR_LIT>" + searchDocument . getPath ( ) ; } } ) ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( <NUM_LIT:10> ) ; buffer . append ( super . toString ( ) ) ; buffer . append ( "<STR_LIT>" ) ; int count = <NUM_LIT:0> ; Object [ ] valueTable = this . indexes . valueTable ; for ( int i = <NUM_LIT:0> , l = valueTable . length ; i < l ; i ++ ) { Index index = ( Index ) valueTable [ i ] ; if ( index != null ) buffer . append ( ++ count ) . append ( "<STR_LIT:U+0020-U+0020>" ) . append ( index . toString ( ) ) . append ( '<STR_LIT:\n>' ) ; } return buffer . toString ( ) ; } private char [ ] [ ] readIndexState ( String dirOSString ) { try { char [ ] savedIndexNames = org . eclipse . jdt . internal . compiler . util . Util . getFileCharContent ( this . savedIndexNamesFile , null ) ; if ( savedIndexNames . length > <NUM_LIT:0> ) { char [ ] [ ] names = CharOperation . splitOn ( '<STR_LIT:\n>' , savedIndexNames ) ; if ( names . length > <NUM_LIT:1> ) { String savedSignature = DiskIndex . SIGNATURE + "<STR_LIT:+>" + dirOSString ; if ( savedSignature . equals ( new String ( names [ <NUM_LIT:0> ] ) ) ) return names ; } } } catch ( IOException ignored ) { if ( VERBOSE ) Util . verbose ( "<STR_LIT>" ) ; } return null ; } private void readParticipantsIndexNamesFile ( ) { SimpleLookupTable containers = new SimpleLookupTable ( <NUM_LIT:3> ) ; try { char [ ] participantIndexNames = org . eclipse . jdt . internal . compiler . util . Util . getFileCharContent ( this . participantIndexNamesFile , null ) ; if ( participantIndexNames . length > <NUM_LIT:0> ) { char [ ] [ ] names = CharOperation . splitOn ( '<STR_LIT:\n>' , participantIndexNames ) ; if ( names . length >= <NUM_LIT:3> ) { if ( DiskIndex . SIGNATURE . equals ( new String ( names [ <NUM_LIT:0> ] ) ) ) { for ( int i = <NUM_LIT:1> , l = names . length - <NUM_LIT:1> ; i < l ; i += <NUM_LIT:2> ) { containers . put ( new Path ( new String ( names [ i ] ) ) , new Path ( new String ( names [ i + <NUM_LIT:1> ] ) ) ) ; } } } } } catch ( IOException ignored ) { if ( VERBOSE ) Util . verbose ( "<STR_LIT>" ) ; } this . participantsContainers = containers ; return ; } private synchronized void removeIndexesState ( IPath [ ] locations ) { getIndexStates ( ) ; int length = locations . length ; boolean changed = false ; for ( int i = <NUM_LIT:0> ; i < length ; i ++ ) { if ( locations [ i ] == null ) continue ; if ( ( this . indexStates . removeKey ( locations [ i ] ) != null ) ) { changed = true ; if ( VERBOSE ) { Util . verbose ( "<STR_LIT>" + locations [ i ] ) ; } } } if ( ! changed ) return ; writeSavedIndexNamesFile ( ) ; } private synchronized void updateIndexState ( IPath indexLocation , Integer indexState ) { if ( indexLocation . isEmpty ( ) ) throw new IllegalArgumentException ( ) ; getIndexStates ( ) ; if ( indexState != null ) { if ( indexState . equals ( this . indexStates . get ( indexLocation ) ) ) return ; this . indexStates . put ( indexLocation , indexState ) ; } else { if ( ! this . indexStates . containsKey ( indexLocation ) ) return ; this . indexStates . removeKey ( indexLocation ) ; } writeSavedIndexNamesFile ( ) ; if ( VERBOSE ) { if ( indexState == null ) { Util . verbose ( "<STR_LIT>" + indexLocation ) ; } else { String state = "<STR_LIT:?>" ; if ( indexState == SAVED_STATE ) state = "<STR_LIT>" ; else if ( indexState == UPDATING_STATE ) state = "<STR_LIT>" ; else if ( indexState == UNKNOWN_STATE ) state = "<STR_LIT>" ; else if ( indexState == REBUILDING_STATE ) state = "<STR_LIT>" ; Util . verbose ( "<STR_LIT>" + state + "<STR_LIT>" + indexLocation ) ; } } } public void updateParticipant ( IPath indexLocation , IPath containerPath ) { if ( this . participantsContainers == null ) { readParticipantsIndexNamesFile ( ) ; } if ( this . participantsContainers . get ( indexLocation ) == null ) { this . participantsContainers . put ( indexLocation , containerPath ) ; this . participantUpdated = true ; } } private void writeJavaLikeNamesFile ( ) { BufferedWriter writer = null ; String pathName = getJavaPluginWorkingLocation ( ) . toOSString ( ) ; try { char [ ] [ ] currentNames = Util . getJavaLikeExtensions ( ) ; int length = currentNames . length ; if ( length > <NUM_LIT:1> ) { System . arraycopy ( currentNames , <NUM_LIT:0> , currentNames = new char [ length ] [ ] , <NUM_LIT:0> , length ) ; Util . sort ( currentNames ) ; } File javaLikeNamesFile = new File ( pathName , "<STR_LIT>" ) ; writer = new BufferedWriter ( new FileWriter ( javaLikeNamesFile ) ) ; for ( int i = <NUM_LIT:0> ; i < length - <NUM_LIT:1> ; i ++ ) { writer . write ( currentNames [ i ] ) ; writer . write ( '<STR_LIT:\n>' ) ; } if ( length > <NUM_LIT:0> ) writer . write ( currentNames [ length - <NUM_LIT:1> ] ) ; } catch ( IOException ignored ) { if ( VERBOSE ) Util . verbose ( "<STR_LIT>" , System . err ) ; } finally { if ( writer != null ) { try { writer . close ( ) ; } catch ( IOException e ) { } } } } private void writeParticipantsIndexNamesFile ( ) { BufferedWriter writer = null ; try { writer = new BufferedWriter ( new FileWriter ( this . participantIndexNamesFile ) ) ; writer . write ( DiskIndex . SIGNATURE ) ; writer . write ( '<STR_LIT:\n>' ) ; Object [ ] indexFiles = this . participantsContainers . keyTable ; Object [ ] containers = this . participantsContainers . valueTable ; for ( int i = <NUM_LIT:0> , l = indexFiles . length ; i < l ; i ++ ) { IPath indexFile = ( IPath ) indexFiles [ i ] ; if ( indexFile != null ) { writer . write ( indexFile . toOSString ( ) ) ; writer . write ( '<STR_LIT:\n>' ) ; writer . write ( ( ( IPath ) containers [ i ] ) . toOSString ( ) ) ; writer . write ( '<STR_LIT:\n>' ) ; } } } catch ( IOException ignored ) { if ( VERBOSE ) Util . verbose ( "<STR_LIT>" , System . err ) ; } finally { if ( writer != null ) { try { writer . close ( ) ; } catch ( IOException e ) { } } } } private void writeSavedIndexNamesFile ( ) { BufferedWriter writer = null ; try { writer = new BufferedWriter ( new FileWriter ( this . savedIndexNamesFile ) ) ; writer . write ( DiskIndex . SIGNATURE ) ; writer . write ( '<CHAR_LIT>' ) ; writer . write ( getJavaPluginWorkingLocation ( ) . toOSString ( ) ) ; writer . write ( '<STR_LIT:\n>' ) ; Object [ ] keys = this . indexStates . keyTable ; Object [ ] states = this . indexStates . valueTable ; for ( int i = <NUM_LIT:0> , l = states . length ; i < l ; i ++ ) { IPath key = ( IPath ) keys [ i ] ; if ( key != null && ! key . isEmpty ( ) && states [ i ] == SAVED_STATE ) { writer . write ( key . lastSegment ( ) ) ; writer . write ( '<STR_LIT:\n>' ) ; } } } catch ( IOException ignored ) { if ( VERBOSE ) Util . verbose ( "<STR_LIT>" , System . err ) ; } finally { if ( writer != null ) { try { writer . close ( ) ; } catch ( IOException e ) { } } } } } </s>
<s> package org . eclipse . jdt . internal . core . search . indexing ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . search . SearchDocument ; import org . eclipse . jdt . internal . compiler . ExtraFlags ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileReader ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFormatException ; import org . eclipse . jdt . internal . compiler . classfmt . FieldInfo ; import org . eclipse . jdt . internal . compiler . classfmt . MethodInfo ; import org . eclipse . jdt . internal . compiler . env . ClassSignature ; import org . eclipse . jdt . internal . compiler . env . EnumConstantSignature ; import org . eclipse . jdt . internal . compiler . env . IBinaryAnnotation ; import org . eclipse . jdt . internal . compiler . env . IBinaryElementValuePair ; import org . eclipse . jdt . internal . compiler . lookup . TagBits ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . util . Util ; public class BinaryIndexer extends AbstractIndexer implements SuffixConstants { private static final char [ ] BYTE = "<STR_LIT>" . toCharArray ( ) ; private static final char [ ] CHAR = "<STR_LIT>" . toCharArray ( ) ; private static final char [ ] DOUBLE = "<STR_LIT:double>" . toCharArray ( ) ; private static final char [ ] FLOAT = "<STR_LIT:float>" . toCharArray ( ) ; private static final char [ ] INT = "<STR_LIT:int>" . toCharArray ( ) ; private static final char [ ] LONG = "<STR_LIT:long>" . toCharArray ( ) ; private static final char [ ] SHORT = "<STR_LIT>" . toCharArray ( ) ; private static final char [ ] BOOLEAN = "<STR_LIT:boolean>" . toCharArray ( ) ; private static final char [ ] VOID = "<STR_LIT>" . toCharArray ( ) ; private static final char [ ] INIT = "<STR_LIT>" . toCharArray ( ) ; public BinaryIndexer ( SearchDocument document ) { super ( document ) ; } private void addBinaryStandardAnnotations ( long annotationTagBits ) { if ( ( annotationTagBits & TagBits . AnnotationTargetMASK ) != <NUM_LIT:0> ) { char [ ] [ ] compoundName = TypeConstants . JAVA_LANG_ANNOTATION_TARGET ; addAnnotationTypeReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; addBinaryTargetAnnotation ( annotationTagBits ) ; } if ( ( annotationTagBits & TagBits . AnnotationRetentionMASK ) != <NUM_LIT:0> ) { char [ ] [ ] compoundName = TypeConstants . JAVA_LANG_ANNOTATION_RETENTION ; addAnnotationTypeReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; addBinaryRetentionAnnotation ( annotationTagBits ) ; } if ( ( annotationTagBits & TagBits . AnnotationDeprecated ) != <NUM_LIT:0> ) { char [ ] [ ] compoundName = TypeConstants . JAVA_LANG_DEPRECATED ; addAnnotationTypeReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; } if ( ( annotationTagBits & TagBits . AnnotationDocumented ) != <NUM_LIT:0> ) { char [ ] [ ] compoundName = TypeConstants . JAVA_LANG_ANNOTATION_DOCUMENTED ; addAnnotationTypeReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; } if ( ( annotationTagBits & TagBits . AnnotationInherited ) != <NUM_LIT:0> ) { char [ ] [ ] compoundName = TypeConstants . JAVA_LANG_ANNOTATION_INHERITED ; addAnnotationTypeReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; } if ( ( annotationTagBits & TagBits . AnnotationOverride ) != <NUM_LIT:0> ) { char [ ] [ ] compoundName = TypeConstants . JAVA_LANG_OVERRIDE ; addAnnotationTypeReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; } if ( ( annotationTagBits & TagBits . AnnotationSuppressWarnings ) != <NUM_LIT:0> ) { char [ ] [ ] compoundName = TypeConstants . JAVA_LANG_SUPPRESSWARNINGS ; addAnnotationTypeReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; } } private void addBinaryTargetAnnotation ( long bits ) { char [ ] [ ] compoundName = null ; if ( ( bits & TagBits . AnnotationForAnnotationType ) != <NUM_LIT:0> ) { compoundName = TypeConstants . JAVA_LANG_ANNOTATION_ELEMENTTYPE ; addTypeReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; addFieldReference ( TypeConstants . UPPER_ANNOTATION_TYPE ) ; } if ( ( bits & TagBits . AnnotationForConstructor ) != <NUM_LIT:0> ) { if ( compoundName == null ) { compoundName = TypeConstants . JAVA_LANG_ANNOTATION_ELEMENTTYPE ; addTypeReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; } addFieldReference ( TypeConstants . UPPER_CONSTRUCTOR ) ; } if ( ( bits & TagBits . AnnotationForField ) != <NUM_LIT:0> ) { if ( compoundName == null ) { compoundName = TypeConstants . JAVA_LANG_ANNOTATION_ELEMENTTYPE ; addTypeReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; } addFieldReference ( TypeConstants . UPPER_FIELD ) ; } if ( ( bits & TagBits . AnnotationForLocalVariable ) != <NUM_LIT:0> ) { if ( compoundName == null ) { compoundName = TypeConstants . JAVA_LANG_ANNOTATION_ELEMENTTYPE ; addTypeReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; } addFieldReference ( TypeConstants . UPPER_LOCAL_VARIABLE ) ; } if ( ( bits & TagBits . AnnotationForMethod ) != <NUM_LIT:0> ) { if ( compoundName == null ) { compoundName = TypeConstants . JAVA_LANG_ANNOTATION_ELEMENTTYPE ; addTypeReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; } addFieldReference ( TypeConstants . UPPER_METHOD ) ; } if ( ( bits & TagBits . AnnotationForPackage ) != <NUM_LIT:0> ) { if ( compoundName == null ) { compoundName = TypeConstants . JAVA_LANG_ANNOTATION_ELEMENTTYPE ; addTypeReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; } addFieldReference ( TypeConstants . UPPER_PACKAGE ) ; } if ( ( bits & TagBits . AnnotationForParameter ) != <NUM_LIT:0> ) { if ( compoundName == null ) { compoundName = TypeConstants . JAVA_LANG_ANNOTATION_ELEMENTTYPE ; addTypeReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; } addFieldReference ( TypeConstants . UPPER_PARAMETER ) ; } if ( ( bits & TagBits . AnnotationForType ) != <NUM_LIT:0> ) { if ( compoundName == null ) { compoundName = TypeConstants . JAVA_LANG_ANNOTATION_ELEMENTTYPE ; addTypeReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; } addFieldReference ( TypeConstants . TYPE ) ; } } private void addBinaryRetentionAnnotation ( long bits ) { char [ ] [ ] compoundName = TypeConstants . JAVA_LANG_ANNOTATION_RETENTIONPOLICY ; addTypeReference ( compoundName [ compoundName . length - <NUM_LIT:1> ] ) ; if ( ( bits & TagBits . AnnotationRuntimeRetention ) == TagBits . AnnotationRuntimeRetention ) { addFieldReference ( TypeConstants . UPPER_RUNTIME ) ; } else if ( ( bits & TagBits . AnnotationClassRetention ) != <NUM_LIT:0> ) { addFieldReference ( TypeConstants . UPPER_CLASS ) ; } else if ( ( bits & TagBits . AnnotationSourceRetention ) != <NUM_LIT:0> ) { addFieldReference ( TypeConstants . UPPER_SOURCE ) ; } } private void addBinaryAnnotation ( IBinaryAnnotation annotation ) { addAnnotationTypeReference ( replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' , Signature . toCharArray ( annotation . getTypeName ( ) ) ) ) ; IBinaryElementValuePair [ ] valuePairs = annotation . getElementValuePairs ( ) ; if ( valuePairs != null ) { for ( int j = <NUM_LIT:0> , vpLength = valuePairs . length ; j < vpLength ; j ++ ) { IBinaryElementValuePair valuePair = valuePairs [ j ] ; addMethodReference ( valuePair . getName ( ) , <NUM_LIT:0> ) ; Object pairValue = valuePair . getValue ( ) ; addPairValue ( pairValue ) ; } } } private void addPairValue ( Object pairValue ) { if ( pairValue instanceof EnumConstantSignature ) { EnumConstantSignature enumConstant = ( EnumConstantSignature ) pairValue ; addTypeReference ( replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' , Signature . toCharArray ( enumConstant . getTypeName ( ) ) ) ) ; addNameReference ( enumConstant . getEnumConstantName ( ) ) ; } else if ( pairValue instanceof ClassSignature ) { ClassSignature classConstant = ( ClassSignature ) pairValue ; addTypeReference ( replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' , Signature . toCharArray ( classConstant . getTypeName ( ) ) ) ) ; } else if ( pairValue instanceof IBinaryAnnotation ) { addBinaryAnnotation ( ( IBinaryAnnotation ) pairValue ) ; } else if ( pairValue instanceof Object [ ] ) { Object [ ] objects = ( Object [ ] ) pairValue ; for ( int i = <NUM_LIT:0> , l = objects . length ; i < l ; i ++ ) { addPairValue ( objects [ i ] ) ; } } } public void addTypeReference ( char [ ] typeName ) { int length = typeName . length ; if ( length > <NUM_LIT:2> && typeName [ length - <NUM_LIT:2> ] == '<CHAR_LIT>' ) { switch ( typeName [ length - <NUM_LIT:1> ] ) { case '<CHAR_LIT:0>' : case '<CHAR_LIT:1>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT:9>' : return ; } } typeName = CharOperation . replaceOnCopy ( typeName , '<CHAR_LIT>' , '<CHAR_LIT:.>' ) ; super . addTypeReference ( typeName ) ; } private void convertToArrayType ( char [ ] [ ] parameterTypes , int counter , int arrayDim ) { int length = parameterTypes [ counter ] . length ; char [ ] arrayType = new char [ length + arrayDim * <NUM_LIT:2> ] ; System . arraycopy ( parameterTypes [ counter ] , <NUM_LIT:0> , arrayType , <NUM_LIT:0> , length ) ; for ( int i = <NUM_LIT:0> ; i < arrayDim ; i ++ ) { arrayType [ length + ( i * <NUM_LIT:2> ) ] = '<CHAR_LIT:[>' ; arrayType [ length + ( i * <NUM_LIT:2> ) + <NUM_LIT:1> ] = '<CHAR_LIT:]>' ; } parameterTypes [ counter ] = arrayType ; } private char [ ] convertToArrayType ( char [ ] typeName , int arrayDim ) { int length = typeName . length ; char [ ] arrayType = new char [ length + arrayDim * <NUM_LIT:2> ] ; System . arraycopy ( typeName , <NUM_LIT:0> , arrayType , <NUM_LIT:0> , length ) ; for ( int i = <NUM_LIT:0> ; i < arrayDim ; i ++ ) { arrayType [ length + ( i * <NUM_LIT:2> ) ] = '<CHAR_LIT:[>' ; arrayType [ length + ( i * <NUM_LIT:2> ) + <NUM_LIT:1> ] = '<CHAR_LIT:]>' ; } return arrayType ; } private char [ ] decodeFieldType ( char [ ] signature ) throws ClassFormatException { if ( signature == null ) return null ; int arrayDim = <NUM_LIT:0> ; for ( int i = <NUM_LIT:0> , max = signature . length ; i < max ; i ++ ) { switch ( signature [ i ] ) { case '<CHAR_LIT>' : if ( arrayDim > <NUM_LIT:0> ) return convertToArrayType ( BYTE , arrayDim ) ; return BYTE ; case '<CHAR_LIT>' : if ( arrayDim > <NUM_LIT:0> ) return convertToArrayType ( CHAR , arrayDim ) ; return CHAR ; case '<CHAR_LIT>' : if ( arrayDim > <NUM_LIT:0> ) return convertToArrayType ( DOUBLE , arrayDim ) ; return DOUBLE ; case '<CHAR_LIT>' : if ( arrayDim > <NUM_LIT:0> ) return convertToArrayType ( FLOAT , arrayDim ) ; return FLOAT ; case '<CHAR_LIT>' : if ( arrayDim > <NUM_LIT:0> ) return convertToArrayType ( INT , arrayDim ) ; return INT ; case '<CHAR_LIT>' : if ( arrayDim > <NUM_LIT:0> ) return convertToArrayType ( LONG , arrayDim ) ; return LONG ; case '<CHAR_LIT>' : int indexOfSemiColon = CharOperation . indexOf ( '<CHAR_LIT:;>' , signature , i + <NUM_LIT:1> ) ; if ( indexOfSemiColon == - <NUM_LIT:1> ) throw new ClassFormatException ( ClassFormatException . ErrInvalidMethodSignature ) ; if ( arrayDim > <NUM_LIT:0> ) { return convertToArrayType ( replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' , CharOperation . subarray ( signature , i + <NUM_LIT:1> , indexOfSemiColon ) ) , arrayDim ) ; } return replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' , CharOperation . subarray ( signature , i + <NUM_LIT:1> , indexOfSemiColon ) ) ; case '<CHAR_LIT>' : if ( arrayDim > <NUM_LIT:0> ) return convertToArrayType ( SHORT , arrayDim ) ; return SHORT ; case '<CHAR_LIT:Z>' : if ( arrayDim > <NUM_LIT:0> ) return convertToArrayType ( BOOLEAN , arrayDim ) ; return BOOLEAN ; case '<CHAR_LIT>' : return VOID ; case '<CHAR_LIT:[>' : arrayDim ++ ; break ; default : throw new ClassFormatException ( ClassFormatException . ErrInvalidMethodSignature ) ; } } return null ; } private char [ ] [ ] decodeParameterTypes ( char [ ] signature , boolean firstIsSynthetic ) throws ClassFormatException { if ( signature == null ) return null ; int indexOfClosingParen = CharOperation . lastIndexOf ( '<CHAR_LIT:)>' , signature ) ; if ( indexOfClosingParen == <NUM_LIT:1> ) { return null ; } if ( indexOfClosingParen == - <NUM_LIT:1> ) { throw new ClassFormatException ( ClassFormatException . ErrInvalidMethodSignature ) ; } char [ ] [ ] parameterTypes = new char [ <NUM_LIT:3> ] [ ] ; int parameterTypesCounter = <NUM_LIT:0> ; int arrayDim = <NUM_LIT:0> ; for ( int i = <NUM_LIT:1> ; i < indexOfClosingParen ; i ++ ) { if ( parameterTypesCounter == parameterTypes . length ) { System . arraycopy ( parameterTypes , <NUM_LIT:0> , ( parameterTypes = new char [ parameterTypesCounter * <NUM_LIT:2> ] [ ] ) , <NUM_LIT:0> , parameterTypesCounter ) ; } switch ( signature [ i ] ) { case '<CHAR_LIT>' : parameterTypes [ parameterTypesCounter ++ ] = BYTE ; if ( arrayDim > <NUM_LIT:0> ) convertToArrayType ( parameterTypes , parameterTypesCounter - <NUM_LIT:1> , arrayDim ) ; arrayDim = <NUM_LIT:0> ; break ; case '<CHAR_LIT>' : parameterTypes [ parameterTypesCounter ++ ] = CHAR ; if ( arrayDim > <NUM_LIT:0> ) convertToArrayType ( parameterTypes , parameterTypesCounter - <NUM_LIT:1> , arrayDim ) ; arrayDim = <NUM_LIT:0> ; break ; case '<CHAR_LIT>' : parameterTypes [ parameterTypesCounter ++ ] = DOUBLE ; if ( arrayDim > <NUM_LIT:0> ) convertToArrayType ( parameterTypes , parameterTypesCounter - <NUM_LIT:1> , arrayDim ) ; arrayDim = <NUM_LIT:0> ; break ; case '<CHAR_LIT>' : parameterTypes [ parameterTypesCounter ++ ] = FLOAT ; if ( arrayDim > <NUM_LIT:0> ) convertToArrayType ( parameterTypes , parameterTypesCounter - <NUM_LIT:1> , arrayDim ) ; arrayDim = <NUM_LIT:0> ; break ; case '<CHAR_LIT>' : parameterTypes [ parameterTypesCounter ++ ] = INT ; if ( arrayDim > <NUM_LIT:0> ) convertToArrayType ( parameterTypes , parameterTypesCounter - <NUM_LIT:1> , arrayDim ) ; arrayDim = <NUM_LIT:0> ; break ; case '<CHAR_LIT>' : parameterTypes [ parameterTypesCounter ++ ] = LONG ; if ( arrayDim > <NUM_LIT:0> ) convertToArrayType ( parameterTypes , parameterTypesCounter - <NUM_LIT:1> , arrayDim ) ; arrayDim = <NUM_LIT:0> ; break ; case '<CHAR_LIT>' : int indexOfSemiColon = CharOperation . indexOf ( '<CHAR_LIT:;>' , signature , i + <NUM_LIT:1> ) ; if ( indexOfSemiColon == - <NUM_LIT:1> ) throw new ClassFormatException ( ClassFormatException . ErrInvalidMethodSignature ) ; if ( firstIsSynthetic && parameterTypesCounter == <NUM_LIT:0> ) { firstIsSynthetic = false ; } else { parameterTypes [ parameterTypesCounter ++ ] = replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' , CharOperation . subarray ( signature , i + <NUM_LIT:1> , indexOfSemiColon ) ) ; if ( arrayDim > <NUM_LIT:0> ) convertToArrayType ( parameterTypes , parameterTypesCounter - <NUM_LIT:1> , arrayDim ) ; } i = indexOfSemiColon ; arrayDim = <NUM_LIT:0> ; break ; case '<CHAR_LIT>' : parameterTypes [ parameterTypesCounter ++ ] = SHORT ; if ( arrayDim > <NUM_LIT:0> ) convertToArrayType ( parameterTypes , parameterTypesCounter - <NUM_LIT:1> , arrayDim ) ; arrayDim = <NUM_LIT:0> ; break ; case '<CHAR_LIT:Z>' : parameterTypes [ parameterTypesCounter ++ ] = BOOLEAN ; if ( arrayDim > <NUM_LIT:0> ) convertToArrayType ( parameterTypes , parameterTypesCounter - <NUM_LIT:1> , arrayDim ) ; arrayDim = <NUM_LIT:0> ; break ; case '<CHAR_LIT:[>' : arrayDim ++ ; break ; default : throw new ClassFormatException ( ClassFormatException . ErrInvalidMethodSignature ) ; } } if ( parameterTypes . length != parameterTypesCounter ) { System . arraycopy ( parameterTypes , <NUM_LIT:0> , parameterTypes = new char [ parameterTypesCounter ] [ ] , <NUM_LIT:0> , parameterTypesCounter ) ; } return parameterTypes ; } private char [ ] decodeReturnType ( char [ ] signature ) throws ClassFormatException { if ( signature == null ) return null ; int indexOfClosingParen = CharOperation . lastIndexOf ( '<CHAR_LIT:)>' , signature ) ; if ( indexOfClosingParen == - <NUM_LIT:1> ) throw new ClassFormatException ( ClassFormatException . ErrInvalidMethodSignature ) ; int arrayDim = <NUM_LIT:0> ; for ( int i = indexOfClosingParen + <NUM_LIT:1> , max = signature . length ; i < max ; i ++ ) { switch ( signature [ i ] ) { case '<CHAR_LIT>' : if ( arrayDim > <NUM_LIT:0> ) return convertToArrayType ( BYTE , arrayDim ) ; return BYTE ; case '<CHAR_LIT>' : if ( arrayDim > <NUM_LIT:0> ) return convertToArrayType ( CHAR , arrayDim ) ; return CHAR ; case '<CHAR_LIT>' : if ( arrayDim > <NUM_LIT:0> ) return convertToArrayType ( DOUBLE , arrayDim ) ; return DOUBLE ; case '<CHAR_LIT>' : if ( arrayDim > <NUM_LIT:0> ) return convertToArrayType ( FLOAT , arrayDim ) ; return FLOAT ; case '<CHAR_LIT>' : if ( arrayDim > <NUM_LIT:0> ) return convertToArrayType ( INT , arrayDim ) ; return INT ; case '<CHAR_LIT>' : if ( arrayDim > <NUM_LIT:0> ) return convertToArrayType ( LONG , arrayDim ) ; return LONG ; case '<CHAR_LIT>' : int indexOfSemiColon = CharOperation . indexOf ( '<CHAR_LIT:;>' , signature , i + <NUM_LIT:1> ) ; if ( indexOfSemiColon == - <NUM_LIT:1> ) throw new ClassFormatException ( ClassFormatException . ErrInvalidMethodSignature ) ; if ( arrayDim > <NUM_LIT:0> ) { return convertToArrayType ( replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' , CharOperation . subarray ( signature , i + <NUM_LIT:1> , indexOfSemiColon ) ) , arrayDim ) ; } return replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' , CharOperation . subarray ( signature , i + <NUM_LIT:1> , indexOfSemiColon ) ) ; case '<CHAR_LIT>' : if ( arrayDim > <NUM_LIT:0> ) return convertToArrayType ( SHORT , arrayDim ) ; return SHORT ; case '<CHAR_LIT:Z>' : if ( arrayDim > <NUM_LIT:0> ) return convertToArrayType ( BOOLEAN , arrayDim ) ; return BOOLEAN ; case '<CHAR_LIT>' : return VOID ; case '<CHAR_LIT:[>' : arrayDim ++ ; break ; default : throw new ClassFormatException ( ClassFormatException . ErrInvalidMethodSignature ) ; } } return null ; } private int extractArgCount ( char [ ] signature , char [ ] className ) throws ClassFormatException { int indexOfClosingParen = CharOperation . lastIndexOf ( '<CHAR_LIT:)>' , signature ) ; if ( indexOfClosingParen == <NUM_LIT:1> ) { return <NUM_LIT:0> ; } if ( indexOfClosingParen == - <NUM_LIT:1> ) { throw new ClassFormatException ( ClassFormatException . ErrInvalidMethodSignature ) ; } int parameterTypesCounter = <NUM_LIT:0> ; for ( int i = <NUM_LIT:1> ; i < indexOfClosingParen ; i ++ ) { switch ( signature [ i ] ) { case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT>' : case '<CHAR_LIT:Z>' : parameterTypesCounter ++ ; break ; case '<CHAR_LIT>' : int indexOfSemiColon = CharOperation . indexOf ( '<CHAR_LIT:;>' , signature , i + <NUM_LIT:1> ) ; if ( indexOfSemiColon == - <NUM_LIT:1> ) throw new ClassFormatException ( ClassFormatException . ErrInvalidMethodSignature ) ; if ( className != null && parameterTypesCounter == <NUM_LIT:0> ) { char [ ] classSignature = Signature . createCharArrayTypeSignature ( className , true ) ; int length = indexOfSemiColon - i + <NUM_LIT:1> ; if ( classSignature . length > ( length + <NUM_LIT:1> ) ) { for ( int j = i , k = <NUM_LIT:0> ; j < indexOfSemiColon ; j ++ , k ++ ) { if ( ! ( signature [ j ] == classSignature [ k ] || ( signature [ j ] == '<CHAR_LIT:/>' && classSignature [ k ] == '<CHAR_LIT:.>' ) ) ) { parameterTypesCounter ++ ; break ; } } } else { parameterTypesCounter ++ ; } className = null ; } else { parameterTypesCounter ++ ; } i = indexOfSemiColon ; break ; case '<CHAR_LIT:[>' : break ; default : throw new ClassFormatException ( ClassFormatException . ErrInvalidMethodSignature ) ; } } return parameterTypesCounter ; } private char [ ] extractClassName ( int [ ] constantPoolOffsets , ClassFileReader reader , int index ) { int class_index = reader . u2At ( constantPoolOffsets [ index ] + <NUM_LIT:1> ) ; int utf8Offset = constantPoolOffsets [ reader . u2At ( constantPoolOffsets [ class_index ] + <NUM_LIT:1> ) ] ; return reader . utf8At ( utf8Offset + <NUM_LIT:3> , reader . u2At ( utf8Offset + <NUM_LIT:1> ) ) ; } private char [ ] extractName ( int [ ] constantPoolOffsets , ClassFileReader reader , int index ) { int nameAndTypeIndex = reader . u2At ( constantPoolOffsets [ index ] + <NUM_LIT:3> ) ; int utf8Offset = constantPoolOffsets [ reader . u2At ( constantPoolOffsets [ nameAndTypeIndex ] + <NUM_LIT:1> ) ] ; return reader . utf8At ( utf8Offset + <NUM_LIT:3> , reader . u2At ( utf8Offset + <NUM_LIT:1> ) ) ; } private char [ ] extractClassReference ( int [ ] constantPoolOffsets , ClassFileReader reader , int index ) { int utf8Offset = constantPoolOffsets [ reader . u2At ( constantPoolOffsets [ index ] + <NUM_LIT:1> ) ] ; return reader . utf8At ( utf8Offset + <NUM_LIT:3> , reader . u2At ( utf8Offset + <NUM_LIT:1> ) ) ; } private void extractReferenceFromConstantPool ( byte [ ] contents , ClassFileReader reader ) throws ClassFormatException { int [ ] constantPoolOffsets = reader . getConstantPoolOffsets ( ) ; int constantPoolCount = constantPoolOffsets . length ; for ( int i = <NUM_LIT:1> ; i < constantPoolCount ; i ++ ) { int tag = reader . u1At ( constantPoolOffsets [ i ] ) ; char [ ] name = null ; char [ ] type = null ; switch ( tag ) { case ClassFileConstants . FieldRefTag : name = extractName ( constantPoolOffsets , reader , i ) ; addFieldReference ( name ) ; break ; case ClassFileConstants . MethodRefTag : case ClassFileConstants . InterfaceMethodRefTag : name = extractName ( constantPoolOffsets , reader , i ) ; type = extractType ( constantPoolOffsets , reader , i ) ; if ( CharOperation . equals ( INIT , name ) ) { char [ ] className = extractClassName ( constantPoolOffsets , reader , i ) ; boolean localType = false ; if ( className != null ) { for ( int c = <NUM_LIT:0> , max = className . length ; c < max ; c ++ ) { switch ( className [ c ] ) { case '<CHAR_LIT:/>' : className [ c ] = '<CHAR_LIT:.>' ; break ; case '<CHAR_LIT>' : localType = true ; break ; } } } addConstructorReference ( className , extractArgCount ( type , localType ? className : null ) ) ; } else { addMethodReference ( name , extractArgCount ( type , null ) ) ; } break ; case ClassFileConstants . ClassTag : name = extractClassReference ( constantPoolOffsets , reader , i ) ; if ( name . length > <NUM_LIT:0> && name [ <NUM_LIT:0> ] == '<CHAR_LIT:[>' ) break ; name = replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' , name ) ; addTypeReference ( name ) ; char [ ] [ ] qualification = CharOperation . splitOn ( '<CHAR_LIT:.>' , name ) ; for ( int j = <NUM_LIT:0> , length = qualification . length ; j < length ; j ++ ) { addNameReference ( qualification [ j ] ) ; } break ; } } } private char [ ] extractType ( int [ ] constantPoolOffsets , ClassFileReader reader , int index ) { int constantPoolIndex = reader . u2At ( constantPoolOffsets [ index ] + <NUM_LIT:3> ) ; int utf8Offset = constantPoolOffsets [ reader . u2At ( constantPoolOffsets [ constantPoolIndex ] + <NUM_LIT:3> ) ] ; return reader . utf8At ( utf8Offset + <NUM_LIT:3> , reader . u2At ( utf8Offset + <NUM_LIT:1> ) ) ; } public void indexDocument ( ) { try { final byte [ ] contents = this . document . getByteContents ( ) ; if ( contents == null ) return ; final String path = this . document . getPath ( ) ; ClassFileReader reader = new ClassFileReader ( contents , path == null ? null : path . toCharArray ( ) ) ; char [ ] className = replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' , reader . getName ( ) ) ; int packageNameIndex = CharOperation . lastIndexOf ( '<CHAR_LIT:.>' , className ) ; char [ ] packageName = null ; char [ ] name = null ; if ( packageNameIndex >= <NUM_LIT:0> ) { packageName = CharOperation . subarray ( className , <NUM_LIT:0> , packageNameIndex ) ; name = CharOperation . subarray ( className , packageNameIndex + <NUM_LIT:1> , className . length ) ; } else { packageName = CharOperation . NO_CHAR ; name = className ; } char [ ] enclosingTypeName = null ; boolean isNestedType = reader . isNestedType ( ) ; if ( isNestedType ) { if ( reader . isAnonymous ( ) ) { name = CharOperation . NO_CHAR ; } else { name = reader . getInnerSourceName ( ) ; } if ( reader . isLocal ( ) || reader . isAnonymous ( ) ) { enclosingTypeName = ONE_ZERO ; } else { char [ ] fullEnclosingName = reader . getEnclosingTypeName ( ) ; int nameLength = fullEnclosingName . length - packageNameIndex - <NUM_LIT:1> ; if ( nameLength <= <NUM_LIT:0> ) { return ; } enclosingTypeName = new char [ nameLength ] ; System . arraycopy ( fullEnclosingName , packageNameIndex + <NUM_LIT:1> , enclosingTypeName , <NUM_LIT:0> , nameLength ) ; } } char [ ] [ ] typeParameterSignatures = null ; char [ ] genericSignature = reader . getGenericSignature ( ) ; if ( genericSignature != null ) { CharOperation . replace ( genericSignature , '<CHAR_LIT:/>' , '<CHAR_LIT:.>' ) ; typeParameterSignatures = Signature . getTypeParameters ( genericSignature ) ; } if ( name == null ) return ; char [ ] [ ] superinterfaces = replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' , reader . getInterfaceNames ( ) ) ; char [ ] [ ] enclosingTypeNames = enclosingTypeName == null ? null : new char [ ] [ ] { enclosingTypeName } ; int modifiers = reader . getModifiers ( ) ; switch ( TypeDeclaration . kind ( modifiers ) ) { case TypeDeclaration . CLASS_DECL : char [ ] superclass = replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' , reader . getSuperclassName ( ) ) ; addClassDeclaration ( modifiers , packageName , name , enclosingTypeNames , superclass , superinterfaces , typeParameterSignatures , false ) ; break ; case TypeDeclaration . INTERFACE_DECL : addInterfaceDeclaration ( modifiers , packageName , name , enclosingTypeNames , superinterfaces , typeParameterSignatures , false ) ; break ; case TypeDeclaration . ENUM_DECL : superclass = replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' , reader . getSuperclassName ( ) ) ; addEnumDeclaration ( modifiers , packageName , name , enclosingTypeNames , superclass , superinterfaces , false ) ; break ; case TypeDeclaration . ANNOTATION_TYPE_DECL : addAnnotationTypeDeclaration ( modifiers , packageName , name , enclosingTypeNames , false ) ; break ; } IBinaryAnnotation [ ] annotations = reader . getAnnotations ( ) ; if ( annotations != null ) { for ( int a = <NUM_LIT:0> , length = annotations . length ; a < length ; a ++ ) { IBinaryAnnotation annotation = annotations [ a ] ; addBinaryAnnotation ( annotation ) ; } } long tagBits = reader . getTagBits ( ) & TagBits . AllStandardAnnotationsMask ; if ( tagBits != <NUM_LIT:0> ) { addBinaryStandardAnnotations ( tagBits ) ; } int extraFlags = ExtraFlags . getExtraFlags ( reader ) ; MethodInfo [ ] methods = ( MethodInfo [ ] ) reader . getMethods ( ) ; boolean noConstructor = true ; if ( methods != null ) { for ( int i = <NUM_LIT:0> , max = methods . length ; i < max ; i ++ ) { MethodInfo method = methods [ i ] ; boolean isConstructor = method . isConstructor ( ) ; char [ ] descriptor = method . getMethodDescriptor ( ) ; char [ ] [ ] parameterTypes = decodeParameterTypes ( descriptor , isConstructor && isNestedType ) ; char [ ] returnType = decodeReturnType ( descriptor ) ; char [ ] [ ] exceptionTypes = replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' , method . getExceptionTypeNames ( ) ) ; if ( isConstructor ) { noConstructor = false ; char [ ] signature = method . getGenericSignature ( ) ; if ( signature == null ) { if ( reader . isNestedType ( ) && ( ( modifiers & ClassFileConstants . AccStatic ) == <NUM_LIT:0> ) ) { signature = removeFirstSyntheticParameter ( descriptor ) ; } else { signature = descriptor ; } } addConstructorDeclaration ( name , parameterTypes == null ? <NUM_LIT:0> : parameterTypes . length , signature , parameterTypes , method . getArgumentNames ( ) , method . getModifiers ( ) , packageName , modifiers , exceptionTypes , extraFlags ) ; } else { if ( ! method . isClinit ( ) ) { addMethodDeclaration ( method . getSelector ( ) , parameterTypes , returnType , exceptionTypes ) ; } } annotations = method . getAnnotations ( ) ; if ( annotations != null ) { for ( int a = <NUM_LIT:0> , length = annotations . length ; a < length ; a ++ ) { IBinaryAnnotation annotation = annotations [ a ] ; addBinaryAnnotation ( annotation ) ; } } tagBits = method . getTagBits ( ) & TagBits . AllStandardAnnotationsMask ; if ( tagBits != <NUM_LIT:0> ) { addBinaryStandardAnnotations ( tagBits ) ; } } } if ( noConstructor ) { addDefaultConstructorDeclaration ( className , packageName , modifiers , extraFlags ) ; } FieldInfo [ ] fields = ( FieldInfo [ ] ) reader . getFields ( ) ; if ( fields != null ) { for ( int i = <NUM_LIT:0> , max = fields . length ; i < max ; i ++ ) { FieldInfo field = fields [ i ] ; char [ ] fieldName = field . getName ( ) ; char [ ] fieldType = decodeFieldType ( replace ( '<CHAR_LIT:/>' , '<CHAR_LIT:.>' , field . getTypeName ( ) ) ) ; addFieldDeclaration ( fieldType , fieldName ) ; annotations = field . getAnnotations ( ) ; if ( annotations != null ) { for ( int a = <NUM_LIT:0> , length = annotations . length ; a < length ; a ++ ) { IBinaryAnnotation annotation = annotations [ a ] ; addBinaryAnnotation ( annotation ) ; } } tagBits = field . getTagBits ( ) & TagBits . AllStandardAnnotationsMask ; if ( tagBits != <NUM_LIT:0> ) { addBinaryStandardAnnotations ( tagBits ) ; } } } extractReferenceFromConstantPool ( contents , reader ) ; } catch ( ClassFormatException e ) { this . document . removeAllIndexEntries ( ) ; Util . log ( IStatus . WARNING , "<STR_LIT>" + this . document . getPath ( ) + "<STR_LIT>" ) ; } catch ( RuntimeException e ) { this . document . removeAllIndexEntries ( ) ; Util . log ( IStatus . WARNING , "<STR_LIT>" + this . document . getPath ( ) + "<STR_LIT>" ) ; } } private char [ ] removeFirstSyntheticParameter ( char [ ] descriptor ) { if ( descriptor == null ) return null ; if ( descriptor . length < <NUM_LIT:3> ) return descriptor ; if ( descriptor [ <NUM_LIT:0> ] != '<CHAR_LIT:(>' ) return descriptor ; if ( descriptor [ <NUM_LIT:1> ] != '<CHAR_LIT:)>' ) { int start = Util . scanTypeSignature ( descriptor , <NUM_LIT:1> ) + <NUM_LIT:1> ; int length = descriptor . length - start ; char [ ] signature = new char [ length + <NUM_LIT:1> ] ; signature [ <NUM_LIT:0> ] = descriptor [ <NUM_LIT:0> ] ; System . arraycopy ( descriptor , start , signature , <NUM_LIT:1> , length ) ; return signature ; } else { return descriptor ; } } private char [ ] [ ] replace ( char toBeReplaced , char newChar , char [ ] [ ] array ) { if ( array == null ) return null ; for ( int i = <NUM_LIT:0> , max = array . length ; i < max ; i ++ ) { replace ( toBeReplaced , newChar , array [ i ] ) ; } return array ; } private char [ ] replace ( char toBeReplaced , char newChar , char [ ] array ) { if ( array == null ) return null ; for ( int i = <NUM_LIT:0> , max = array . length ; i < max ; i ++ ) { if ( array [ i ] == toBeReplaced ) { array [ i ] = newChar ; } } return array ; } } </s>
<s> package org . eclipse . jdt . internal . core . search . indexing ; import java . io . IOException ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . internal . core . index . Index ; import org . eclipse . jdt . internal . core . search . processing . JobManager ; import org . eclipse . jdt . internal . core . util . Util ; class RemoveFolderFromIndex extends IndexRequest { IPath folderPath ; char [ ] [ ] inclusionPatterns ; char [ ] [ ] exclusionPatterns ; public RemoveFolderFromIndex ( IPath folderPath , char [ ] [ ] inclusionPatterns , char [ ] [ ] exclusionPatterns , IProject project , IndexManager manager ) { super ( project . getFullPath ( ) , manager ) ; this . folderPath = folderPath ; this . inclusionPatterns = inclusionPatterns ; this . exclusionPatterns = exclusionPatterns ; } public boolean execute ( IProgressMonitor progressMonitor ) { if ( this . isCancelled || progressMonitor != null && progressMonitor . isCanceled ( ) ) return true ; Index index = this . manager . getIndex ( this . containerPath , true , false ) ; if ( index == null ) return true ; ReadWriteMonitor monitor = index . monitor ; if ( monitor == null ) return true ; try { monitor . enterRead ( ) ; String containerRelativePath = Util . relativePath ( this . folderPath , this . containerPath . segmentCount ( ) ) ; String [ ] paths = index . queryDocumentNames ( containerRelativePath ) ; if ( paths != null ) { if ( this . exclusionPatterns == null && this . inclusionPatterns == null ) { for ( int i = <NUM_LIT:0> , max = paths . length ; i < max ; i ++ ) { this . manager . remove ( paths [ i ] , this . containerPath ) ; } } else { for ( int i = <NUM_LIT:0> , max = paths . length ; i < max ; i ++ ) { String documentPath = this . containerPath . toString ( ) + '<CHAR_LIT:/>' + paths [ i ] ; if ( ! Util . isExcluded ( new Path ( documentPath ) , this . inclusionPatterns , this . exclusionPatterns , false ) ) this . manager . remove ( paths [ i ] , this . containerPath ) ; } } } } catch ( IOException e ) { if ( JobManager . VERBOSE ) { Util . verbose ( "<STR_LIT>" + this . folderPath + "<STR_LIT>" , System . err ) ; e . printStackTrace ( ) ; } return false ; } finally { monitor . exitRead ( ) ; } return true ; } public String toString ( ) { return "<STR_LIT>" + this . folderPath + "<STR_LIT>" + this . containerPath ; } } </s>
<s> package org . eclipse . jdt . internal . core . search . indexing ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . search . SearchDocument ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . core . JavaModelManager ; import org . eclipse . jdt . internal . core . search . matching . * ; public abstract class AbstractIndexer implements IIndexConstants { SearchDocument document ; public AbstractIndexer ( SearchDocument document ) { this . document = document ; } public void addAnnotationTypeDeclaration ( int modifiers , char [ ] packageName , char [ ] name , char [ ] [ ] enclosingTypeNames , boolean secondary ) { addTypeDeclaration ( modifiers , packageName , name , enclosingTypeNames , secondary ) ; addIndexEntry ( SUPER_REF , SuperTypeReferencePattern . createIndexKey ( modifiers , packageName , name , enclosingTypeNames , null , ANNOTATION_TYPE_SUFFIX , CharOperation . concatWith ( TypeConstants . JAVA_LANG_ANNOTATION_ANNOTATION , '<CHAR_LIT:.>' ) , ANNOTATION_TYPE_SUFFIX ) ) ; } public void addAnnotationTypeReference ( char [ ] typeName ) { addIndexEntry ( ANNOTATION_REF , CharOperation . lastSegment ( typeName , '<CHAR_LIT:.>' ) ) ; } public void addClassDeclaration ( int modifiers , char [ ] packageName , char [ ] name , char [ ] [ ] enclosingTypeNames , char [ ] superclass , char [ ] [ ] superinterfaces , char [ ] [ ] typeParameterSignatures , boolean secondary ) { addTypeDeclaration ( modifiers , packageName , name , enclosingTypeNames , secondary ) ; if ( superclass != null ) { superclass = erasure ( superclass ) ; addTypeReference ( superclass ) ; } addIndexEntry ( SUPER_REF , SuperTypeReferencePattern . createIndexKey ( modifiers , packageName , name , enclosingTypeNames , typeParameterSignatures , CLASS_SUFFIX , superclass , CLASS_SUFFIX ) ) ; if ( superinterfaces != null ) { for ( int i = <NUM_LIT:0> , max = superinterfaces . length ; i < max ; i ++ ) { char [ ] superinterface = erasure ( superinterfaces [ i ] ) ; addTypeReference ( superinterface ) ; addIndexEntry ( SUPER_REF , SuperTypeReferencePattern . createIndexKey ( modifiers , packageName , name , enclosingTypeNames , typeParameterSignatures , CLASS_SUFFIX , superinterface , INTERFACE_SUFFIX ) ) ; } } } private char [ ] erasure ( char [ ] typeName ) { int genericStart = CharOperation . indexOf ( Signature . C_GENERIC_START , typeName ) ; if ( genericStart > - <NUM_LIT:1> ) typeName = CharOperation . subarray ( typeName , <NUM_LIT:0> , genericStart ) ; return typeName ; } public void addConstructorDeclaration ( char [ ] typeName , int argCount , char [ ] signature , char [ ] [ ] parameterTypes , char [ ] [ ] parameterNames , int modifiers , char [ ] packageName , int typeModifiers , char [ ] [ ] exceptionTypes , int extraFlags ) { addIndexEntry ( CONSTRUCTOR_DECL , ConstructorPattern . createDeclarationIndexKey ( typeName , argCount , signature , parameterTypes , parameterNames , modifiers , packageName , typeModifiers , extraFlags ) ) ; if ( parameterTypes != null ) { for ( int i = <NUM_LIT:0> ; i < argCount ; i ++ ) addTypeReference ( parameterTypes [ i ] ) ; } if ( exceptionTypes != null ) for ( int i = <NUM_LIT:0> , max = exceptionTypes . length ; i < max ; i ++ ) addTypeReference ( exceptionTypes [ i ] ) ; } public void addConstructorReference ( char [ ] typeName , int argCount ) { char [ ] simpleTypeName = CharOperation . lastSegment ( typeName , '<CHAR_LIT:.>' ) ; addTypeReference ( simpleTypeName ) ; addIndexEntry ( CONSTRUCTOR_REF , ConstructorPattern . createIndexKey ( simpleTypeName , argCount ) ) ; char [ ] innermostTypeName = CharOperation . lastSegment ( simpleTypeName , '<CHAR_LIT>' ) ; if ( innermostTypeName != simpleTypeName ) addIndexEntry ( CONSTRUCTOR_REF , ConstructorPattern . createIndexKey ( innermostTypeName , argCount ) ) ; } public void addDefaultConstructorDeclaration ( char [ ] typeName , char [ ] packageName , int typeModifiers , int extraFlags ) { addIndexEntry ( CONSTRUCTOR_DECL , ConstructorPattern . createDefaultDeclarationIndexKey ( CharOperation . lastSegment ( typeName , '<CHAR_LIT:.>' ) , packageName , typeModifiers , extraFlags ) ) ; } public void addEnumDeclaration ( int modifiers , char [ ] packageName , char [ ] name , char [ ] [ ] enclosingTypeNames , char [ ] superclass , char [ ] [ ] superinterfaces , boolean secondary ) { addTypeDeclaration ( modifiers , packageName , name , enclosingTypeNames , secondary ) ; addIndexEntry ( SUPER_REF , SuperTypeReferencePattern . createIndexKey ( modifiers , packageName , name , enclosingTypeNames , null , ENUM_SUFFIX , superclass , CLASS_SUFFIX ) ) ; if ( superinterfaces != null ) { for ( int i = <NUM_LIT:0> , max = superinterfaces . length ; i < max ; i ++ ) { char [ ] superinterface = erasure ( superinterfaces [ i ] ) ; addTypeReference ( superinterface ) ; addIndexEntry ( SUPER_REF , SuperTypeReferencePattern . createIndexKey ( modifiers , packageName , name , enclosingTypeNames , null , ENUM_SUFFIX , superinterface , INTERFACE_SUFFIX ) ) ; } } } public void addFieldDeclaration ( char [ ] typeName , char [ ] fieldName ) { addIndexEntry ( FIELD_DECL , FieldPattern . createIndexKey ( fieldName ) ) ; addTypeReference ( typeName ) ; } public void addFieldReference ( char [ ] fieldName ) { addNameReference ( fieldName ) ; } protected void addIndexEntry ( char [ ] category , char [ ] key ) { this . document . addIndexEntry ( category , key ) ; } public void addInterfaceDeclaration ( int modifiers , char [ ] packageName , char [ ] name , char [ ] [ ] enclosingTypeNames , char [ ] [ ] superinterfaces , char [ ] [ ] typeParameterSignatures , boolean secondary ) { addTypeDeclaration ( modifiers , packageName , name , enclosingTypeNames , secondary ) ; if ( superinterfaces != null ) { for ( int i = <NUM_LIT:0> , max = superinterfaces . length ; i < max ; i ++ ) { char [ ] superinterface = erasure ( superinterfaces [ i ] ) ; addTypeReference ( superinterface ) ; addIndexEntry ( SUPER_REF , SuperTypeReferencePattern . createIndexKey ( modifiers , packageName , name , enclosingTypeNames , typeParameterSignatures , INTERFACE_SUFFIX , superinterface , INTERFACE_SUFFIX ) ) ; } } } public void addMethodDeclaration ( char [ ] methodName , char [ ] [ ] parameterTypes , char [ ] returnType , char [ ] [ ] exceptionTypes ) { int argCount = parameterTypes == null ? <NUM_LIT:0> : parameterTypes . length ; addIndexEntry ( METHOD_DECL , MethodPattern . createIndexKey ( methodName , argCount ) ) ; if ( parameterTypes != null ) { for ( int i = <NUM_LIT:0> ; i < argCount ; i ++ ) addTypeReference ( parameterTypes [ i ] ) ; } if ( exceptionTypes != null ) for ( int i = <NUM_LIT:0> , max = exceptionTypes . length ; i < max ; i ++ ) addTypeReference ( exceptionTypes [ i ] ) ; if ( returnType != null ) addTypeReference ( returnType ) ; } public void addMethodReference ( char [ ] methodName , int argCount ) { addIndexEntry ( METHOD_REF , MethodPattern . createIndexKey ( methodName , argCount ) ) ; } public void addNameReference ( char [ ] name ) { addIndexEntry ( REF , name ) ; } protected void addTypeDeclaration ( int modifiers , char [ ] packageName , char [ ] name , char [ ] [ ] enclosingTypeNames , boolean secondary ) { char [ ] indexKey = TypeDeclarationPattern . createIndexKey ( modifiers , name , packageName , enclosingTypeNames , secondary ) ; if ( secondary ) JavaModelManager . getJavaModelManager ( ) . secondaryTypeAdding ( this . document . getPath ( ) , name == null ? CharOperation . NO_CHAR : name , packageName == null ? CharOperation . NO_CHAR : packageName ) ; addIndexEntry ( TYPE_DECL , indexKey ) ; } public void addTypeReference ( char [ ] typeName ) { addNameReference ( CharOperation . lastSegment ( typeName , '<CHAR_LIT:.>' ) ) ; } public abstract void indexDocument ( ) ; } </s>
<s> package org . eclipse . jdt . internal . core . search . indexing ; import org . eclipse . jdt . core . Signature ; import org . eclipse . jdt . core . compiler . * ; import org . eclipse . jdt . internal . compiler . ExtraFlags ; import org . eclipse . jdt . internal . compiler . ISourceElementRequestor ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . Expression ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . lookup . TypeConstants ; import org . eclipse . jdt . internal . core . search . processing . JobManager ; public class SourceIndexerRequestor implements ISourceElementRequestor , IIndexConstants { SourceIndexer indexer ; char [ ] packageName = CharOperation . NO_CHAR ; char [ ] [ ] enclosingTypeNames = new char [ <NUM_LIT:5> ] [ ] ; int depth = <NUM_LIT:0> ; int methodDepth = <NUM_LIT:0> ; public SourceIndexerRequestor ( SourceIndexer indexer ) { this . indexer = indexer ; } public void acceptAnnotationTypeReference ( char [ ] [ ] typeName , int sourceStart , int sourceEnd ) { int length = typeName . length ; for ( int i = <NUM_LIT:0> ; i < length - <NUM_LIT:1> ; i ++ ) acceptUnknownReference ( typeName [ i ] , <NUM_LIT:0> ) ; acceptAnnotationTypeReference ( typeName [ length - <NUM_LIT:1> ] , <NUM_LIT:0> ) ; } public void acceptAnnotationTypeReference ( char [ ] simpleTypeName , int sourcePosition ) { this . indexer . addAnnotationTypeReference ( simpleTypeName ) ; } public void acceptConstructorReference ( char [ ] typeName , int argCount , int sourcePosition ) { if ( CharOperation . indexOf ( Signature . C_GENERIC_START , typeName ) > <NUM_LIT:0> ) { typeName = Signature . toCharArray ( Signature . getTypeErasure ( Signature . createTypeSignature ( typeName , false ) ) . toCharArray ( ) ) ; } this . indexer . addConstructorReference ( typeName , argCount ) ; int lastDot = CharOperation . lastIndexOf ( '<CHAR_LIT:.>' , typeName ) ; if ( lastDot != - <NUM_LIT:1> ) { char [ ] [ ] qualification = CharOperation . splitOn ( '<CHAR_LIT:.>' , CharOperation . subarray ( typeName , <NUM_LIT:0> , lastDot ) ) ; for ( int i = <NUM_LIT:0> , length = qualification . length ; i < length ; i ++ ) { this . indexer . addNameReference ( qualification [ i ] ) ; } } } public void acceptFieldReference ( char [ ] fieldName , int sourcePosition ) { this . indexer . addFieldReference ( fieldName ) ; } public void acceptImport ( int declarationStart , int declarationEnd , char [ ] [ ] tokens , boolean onDemand , int modifiers ) { } public void acceptLineSeparatorPositions ( int [ ] positions ) { } public void acceptMethodReference ( char [ ] methodName , int argCount , int sourcePosition ) { this . indexer . addMethodReference ( methodName , argCount ) ; } public void acceptPackage ( ImportReference importReference ) { this . packageName = CharOperation . concatWith ( importReference . getImportName ( ) , '<CHAR_LIT:.>' ) ; } public void acceptProblem ( CategorizedProblem problem ) { } public void acceptTypeReference ( char [ ] [ ] typeName , int sourceStart , int sourceEnd ) { int length = typeName . length ; for ( int i = <NUM_LIT:0> ; i < length - <NUM_LIT:1> ; i ++ ) acceptUnknownReference ( typeName [ i ] , <NUM_LIT:0> ) ; acceptTypeReference ( typeName [ length - <NUM_LIT:1> ] , <NUM_LIT:0> ) ; } public void acceptTypeReference ( char [ ] simpleTypeName , int sourcePosition ) { this . indexer . addTypeReference ( simpleTypeName ) ; } public void acceptUnknownReference ( char [ ] [ ] name , int sourceStart , int sourceEnd ) { for ( int i = <NUM_LIT:0> ; i < name . length ; i ++ ) { acceptUnknownReference ( name [ i ] , <NUM_LIT:0> ) ; } } public void acceptUnknownReference ( char [ ] name , int sourcePosition ) { this . indexer . addNameReference ( name ) ; } private void addDefaultConstructorIfNecessary ( TypeInfo typeInfo ) { boolean hasConstructor = false ; TypeDeclaration typeDeclaration = typeInfo . node ; AbstractMethodDeclaration [ ] methods = typeDeclaration . methods ; int methodCounter = methods == null ? <NUM_LIT:0> : methods . length ; done : for ( int i = <NUM_LIT:0> ; i < methodCounter ; i ++ ) { AbstractMethodDeclaration method = methods [ i ] ; if ( method . isConstructor ( ) && ! method . isDefaultConstructor ( ) ) { hasConstructor = true ; break done ; } } if ( ! hasConstructor ) { this . indexer . addDefaultConstructorDeclaration ( typeInfo . name , this . packageName == null ? CharOperation . NO_CHAR : this . packageName , typeInfo . modifiers , getMoreExtraFlags ( typeInfo . extraFlags ) ) ; } } public char [ ] [ ] enclosingTypeNames ( ) { if ( this . depth == <NUM_LIT:0> ) return null ; char [ ] [ ] qualification = new char [ this . depth ] [ ] ; System . arraycopy ( this . enclosingTypeNames , <NUM_LIT:0> , qualification , <NUM_LIT:0> , this . depth ) ; return qualification ; } private void enterAnnotationType ( TypeInfo typeInfo ) { char [ ] [ ] typeNames ; if ( this . methodDepth > <NUM_LIT:0> ) { typeNames = ONE_ZERO_CHAR ; } else { typeNames = enclosingTypeNames ( ) ; } this . indexer . addAnnotationTypeDeclaration ( typeInfo . modifiers , this . packageName , typeInfo . name , typeNames , typeInfo . secondary ) ; addDefaultConstructorIfNecessary ( typeInfo ) ; pushTypeName ( typeInfo . name ) ; } private void enterClass ( TypeInfo typeInfo ) { if ( typeInfo . superclass != null ) { typeInfo . superclass = getSimpleName ( typeInfo . superclass ) ; this . indexer . addConstructorReference ( typeInfo . superclass , <NUM_LIT:0> ) ; } if ( typeInfo . superinterfaces != null ) { for ( int i = <NUM_LIT:0> , length = typeInfo . superinterfaces . length ; i < length ; i ++ ) { typeInfo . superinterfaces [ i ] = getSimpleName ( typeInfo . superinterfaces [ i ] ) ; } } char [ ] [ ] typeNames ; if ( this . methodDepth > <NUM_LIT:0> ) { typeNames = ONE_ZERO_CHAR ; } else { typeNames = enclosingTypeNames ( ) ; } char [ ] [ ] typeParameterSignatures = null ; if ( typeInfo . typeParameters != null ) { int typeParametersLength = typeInfo . typeParameters . length ; typeParameterSignatures = new char [ typeParametersLength ] [ ] ; for ( int i = <NUM_LIT:0> ; i < typeParametersLength ; i ++ ) { ISourceElementRequestor . TypeParameterInfo typeParameterInfo = typeInfo . typeParameters [ i ] ; typeParameterSignatures [ i ] = Signature . createTypeParameterSignature ( typeParameterInfo . name , typeParameterInfo . bounds == null ? CharOperation . NO_CHAR_CHAR : typeParameterInfo . bounds ) ; } } this . indexer . addClassDeclaration ( typeInfo . modifiers , this . packageName , typeInfo . name , typeNames , typeInfo . superclass , typeInfo . superinterfaces , typeParameterSignatures , typeInfo . secondary ) ; addDefaultConstructorIfNecessary ( typeInfo ) ; pushTypeName ( typeInfo . name ) ; } public void enterCompilationUnit ( ) { } public void enterConstructor ( MethodInfo methodInfo ) { int argCount = methodInfo . parameterTypes == null ? <NUM_LIT:0> : methodInfo . parameterTypes . length ; this . indexer . addConstructorDeclaration ( methodInfo . name , argCount , null , methodInfo . parameterTypes , methodInfo . parameterNames , methodInfo . modifiers , methodInfo . declaringPackageName , methodInfo . declaringTypeModifiers , methodInfo . exceptionTypes , getMoreExtraFlags ( methodInfo . extraFlags ) ) ; this . methodDepth ++ ; } private void enterEnum ( TypeInfo typeInfo ) { if ( typeInfo . superinterfaces != null ) { for ( int i = <NUM_LIT:0> , length = typeInfo . superinterfaces . length ; i < length ; i ++ ) { typeInfo . superinterfaces [ i ] = getSimpleName ( typeInfo . superinterfaces [ i ] ) ; } } char [ ] [ ] typeNames ; if ( this . methodDepth > <NUM_LIT:0> ) { typeNames = ONE_ZERO_CHAR ; } else { typeNames = enclosingTypeNames ( ) ; } char [ ] superclass = typeInfo . superclass == null ? CharOperation . concatWith ( TypeConstants . JAVA_LANG_ENUM , '<CHAR_LIT:.>' ) : typeInfo . superclass ; this . indexer . addEnumDeclaration ( typeInfo . modifiers , this . packageName , typeInfo . name , typeNames , superclass , typeInfo . superinterfaces , typeInfo . secondary ) ; addDefaultConstructorIfNecessary ( typeInfo ) ; pushTypeName ( typeInfo . name ) ; } public void enterField ( FieldInfo fieldInfo ) { this . indexer . addFieldDeclaration ( fieldInfo . type , fieldInfo . name ) ; this . methodDepth ++ ; } public void enterInitializer ( int declarationSourceStart , int modifiers ) { this . methodDepth ++ ; } private void enterInterface ( TypeInfo typeInfo ) { if ( typeInfo . superinterfaces != null ) { for ( int i = <NUM_LIT:0> , length = typeInfo . superinterfaces . length ; i < length ; i ++ ) { typeInfo . superinterfaces [ i ] = getSimpleName ( typeInfo . superinterfaces [ i ] ) ; } } char [ ] [ ] typeNames ; if ( this . methodDepth > <NUM_LIT:0> ) { typeNames = ONE_ZERO_CHAR ; } else { typeNames = enclosingTypeNames ( ) ; } char [ ] [ ] typeParameterSignatures = null ; if ( typeInfo . typeParameters != null ) { int typeParametersLength = typeInfo . typeParameters . length ; typeParameterSignatures = new char [ typeParametersLength ] [ ] ; for ( int i = <NUM_LIT:0> ; i < typeParametersLength ; i ++ ) { ISourceElementRequestor . TypeParameterInfo typeParameterInfo = typeInfo . typeParameters [ i ] ; typeParameterSignatures [ i ] = Signature . createTypeParameterSignature ( typeParameterInfo . name , typeParameterInfo . bounds ) ; } } this . indexer . addInterfaceDeclaration ( typeInfo . modifiers , this . packageName , typeInfo . name , typeNames , typeInfo . superinterfaces , typeParameterSignatures , typeInfo . secondary ) ; addDefaultConstructorIfNecessary ( typeInfo ) ; pushTypeName ( typeInfo . name ) ; } public void enterMethod ( MethodInfo methodInfo ) { this . indexer . addMethodDeclaration ( methodInfo . name , methodInfo . parameterTypes , methodInfo . returnType , methodInfo . exceptionTypes ) ; this . methodDepth ++ ; } public void enterType ( TypeInfo typeInfo ) { switch ( TypeDeclaration . kind ( typeInfo . modifiers ) ) { case TypeDeclaration . CLASS_DECL : enterClass ( typeInfo ) ; break ; case TypeDeclaration . ANNOTATION_TYPE_DECL : enterAnnotationType ( typeInfo ) ; break ; case TypeDeclaration . INTERFACE_DECL : enterInterface ( typeInfo ) ; break ; case TypeDeclaration . ENUM_DECL : enterEnum ( typeInfo ) ; break ; } } public void exitCompilationUnit ( int declarationEnd ) { } public void exitConstructor ( int declarationEnd ) { this . methodDepth -- ; } public void exitField ( int initializationStart , int declarationEnd , int declarationSourceEnd ) { this . methodDepth -- ; } public void exitInitializer ( int declarationEnd ) { this . methodDepth -- ; } public void exitMethod ( int declarationEnd , Expression defaultValue ) { this . methodDepth -- ; } public void exitType ( int declarationEnd ) { popTypeName ( ) ; } private char [ ] getSimpleName ( char [ ] typeName ) { int lastDot = - <NUM_LIT:1> , lastGenericStart = - <NUM_LIT:1> ; int depthCount = <NUM_LIT:0> ; int length = typeName . length ; lastDotLookup : for ( int i = length - <NUM_LIT:1> ; i >= <NUM_LIT:0> ; i -- ) { switch ( typeName [ i ] ) { case '<CHAR_LIT:.>' : if ( depthCount == <NUM_LIT:0> ) { lastDot = i ; break lastDotLookup ; } break ; case '<CHAR_LIT>' : depthCount -- ; if ( depthCount == <NUM_LIT:0> ) lastGenericStart = i ; break ; case '<CHAR_LIT:>>' : depthCount ++ ; break ; } } if ( lastGenericStart < <NUM_LIT:0> ) { if ( lastDot < <NUM_LIT:0> ) { return typeName ; } return CharOperation . subarray ( typeName , lastDot + <NUM_LIT:1> , length ) ; } return CharOperation . subarray ( typeName , lastDot + <NUM_LIT:1> , lastGenericStart ) ; } private int getMoreExtraFlags ( int extraFlags ) { if ( this . methodDepth > <NUM_LIT:0> ) { extraFlags |= ExtraFlags . IsLocalType ; } return extraFlags ; } public void popTypeName ( ) { if ( this . depth > <NUM_LIT:0> ) { this . enclosingTypeNames [ -- this . depth ] = null ; } else if ( JobManager . VERBOSE ) { try { this . enclosingTypeNames [ - <NUM_LIT:1> ] = null ; } catch ( ArrayIndexOutOfBoundsException e ) { e . printStackTrace ( ) ; } } } public void pushTypeName ( char [ ] typeName ) { if ( this . depth == this . enclosingTypeNames . length ) System . arraycopy ( this . enclosingTypeNames , <NUM_LIT:0> , this . enclosingTypeNames = new char [ this . depth * <NUM_LIT:2> ] [ ] , <NUM_LIT:0> , this . depth ) ; this . enclosingTypeNames [ this . depth ++ ] = typeName ; } } </s>
<s> package org . eclipse . jdt . internal . core . search . indexing ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . internal . core . index . Index ; class RemoveFromIndex extends IndexRequest { String resourceName ; public RemoveFromIndex ( String resourceName , IPath containerPath , IndexManager manager ) { super ( containerPath , manager ) ; this . resourceName = resourceName ; } public boolean execute ( IProgressMonitor progressMonitor ) { if ( this . isCancelled || progressMonitor != null && progressMonitor . isCanceled ( ) ) return true ; Index index = this . manager . getIndex ( this . containerPath , true , false ) ; if ( index == null ) return true ; ReadWriteMonitor monitor = index . monitor ; if ( monitor == null ) return true ; try { monitor . enterWrite ( ) ; index . remove ( this . resourceName ) ; } finally { monitor . exitWrite ( ) ; } return true ; } public String toString ( ) { return "<STR_LIT>" + this . resourceName + "<STR_LIT>" + this . containerPath ; } } </s>
<s> package org . eclipse . jdt . internal . core . search . indexing ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . IResourceProxy ; import org . eclipse . core . resources . IResourceProxyVisitor ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . internal . compiler . SourceElementParser ; import org . eclipse . jdt . internal . core . index . Index ; import org . eclipse . jdt . internal . core . search . processing . JobManager ; import org . eclipse . jdt . internal . core . util . Util ; class AddFolderToIndex extends IndexRequest { IPath folderPath ; IProject project ; char [ ] [ ] inclusionPatterns ; char [ ] [ ] exclusionPatterns ; public AddFolderToIndex ( IPath folderPath , IProject project , char [ ] [ ] inclusionPatterns , char [ ] [ ] exclusionPatterns , IndexManager manager ) { super ( project . getFullPath ( ) , manager ) ; this . folderPath = folderPath ; this . project = project ; this . inclusionPatterns = inclusionPatterns ; this . exclusionPatterns = exclusionPatterns ; } public boolean execute ( IProgressMonitor progressMonitor ) { if ( this . isCancelled || progressMonitor != null && progressMonitor . isCanceled ( ) ) return true ; if ( ! this . project . isAccessible ( ) ) return true ; IResource folder = this . project . getParent ( ) . findMember ( this . folderPath ) ; if ( folder == null || folder . getType ( ) == IResource . FILE ) return true ; Index index = this . manager . getIndex ( this . containerPath , true , true ) ; if ( index == null ) return true ; ReadWriteMonitor monitor = index . monitor ; if ( monitor == null ) return true ; try { monitor . enterRead ( ) ; final IPath container = this . containerPath ; final IndexManager indexManager = this . manager ; final SourceElementParser parser = indexManager . getSourceElementParser ( JavaCore . create ( this . project ) , null ) ; if ( this . exclusionPatterns == null && this . inclusionPatterns == null ) { folder . accept ( new IResourceProxyVisitor ( ) { public boolean visit ( IResourceProxy proxy ) { if ( proxy . getType ( ) == IResource . FILE ) { if ( org . eclipse . jdt . internal . core . util . Util . isJavaLikeFileName ( proxy . getName ( ) ) ) indexManager . addSource ( ( IFile ) proxy . requestResource ( ) , container , parser ) ; return false ; } return true ; } } , IResource . NONE ) ; } else { folder . accept ( new IResourceProxyVisitor ( ) { public boolean visit ( IResourceProxy proxy ) { switch ( proxy . getType ( ) ) { case IResource . FILE : if ( org . eclipse . jdt . internal . core . util . Util . isJavaLikeFileName ( proxy . getName ( ) ) ) { IResource resource = proxy . requestResource ( ) ; if ( ! Util . isExcluded ( resource , AddFolderToIndex . this . inclusionPatterns , AddFolderToIndex . this . exclusionPatterns ) ) indexManager . addSource ( ( IFile ) resource , container , parser ) ; } return false ; case IResource . FOLDER : if ( AddFolderToIndex . this . exclusionPatterns != null && AddFolderToIndex . this . inclusionPatterns == null ) { if ( Util . isExcluded ( proxy . requestFullPath ( ) , AddFolderToIndex . this . inclusionPatterns , AddFolderToIndex . this . exclusionPatterns , true ) ) return false ; } } return true ; } } , IResource . NONE ) ; } } catch ( CoreException e ) { if ( JobManager . VERBOSE ) { Util . verbose ( "<STR_LIT>" + this . folderPath + "<STR_LIT>" , System . err ) ; e . printStackTrace ( ) ; } return false ; } finally { monitor . exitRead ( ) ; } return true ; } public String toString ( ) { return "<STR_LIT>" + this . folderPath + "<STR_LIT>" + this . containerPath ; } } </s>
<s> package org . eclipse . jdt . internal . core . search . indexing ; import org . eclipse . core . runtime . IPath ; import org . eclipse . jdt . internal . core . search . processing . IJob ; public abstract class IndexRequest implements IJob { protected boolean isCancelled = false ; protected IPath containerPath ; protected IndexManager manager ; public IndexRequest ( IPath containerPath , IndexManager manager ) { this . containerPath = containerPath ; this . manager = manager ; } public boolean belongsTo ( String projectNameOrJarPath ) { return projectNameOrJarPath . equals ( this . containerPath . segment ( <NUM_LIT:0> ) ) || projectNameOrJarPath . equals ( this . containerPath . toString ( ) ) ; } public void cancel ( ) { this . manager . jobWasCancelled ( this . containerPath ) ; this . isCancelled = true ; } public void ensureReadyToRun ( ) { this . manager . aboutToUpdateIndex ( this . containerPath , updatedIndexState ( ) ) ; } public String getJobFamily ( ) { return this . containerPath . toString ( ) ; } protected Integer updatedIndexState ( ) { return IndexManager . UPDATING_STATE ; } } </s>
<s> package org . eclipse . jdt . internal . core . search . indexing ; import org . eclipse . jdt . core . search . IJavaSearchConstants ; public interface IIndexConstants { char [ ] REF = "<STR_LIT>" . toCharArray ( ) ; char [ ] ANNOTATION_REF = "<STR_LIT>" . toCharArray ( ) ; char [ ] METHOD_REF = "<STR_LIT>" . toCharArray ( ) ; char [ ] CONSTRUCTOR_REF = "<STR_LIT>" . toCharArray ( ) ; char [ ] SUPER_REF = "<STR_LIT>" . toCharArray ( ) ; char [ ] TYPE_DECL = "<STR_LIT>" . toCharArray ( ) ; char [ ] METHOD_DECL = "<STR_LIT>" . toCharArray ( ) ; char [ ] CONSTRUCTOR_DECL = "<STR_LIT>" . toCharArray ( ) ; char [ ] FIELD_DECL = "<STR_LIT>" . toCharArray ( ) ; char [ ] OBJECT = "<STR_LIT>" . toCharArray ( ) ; char [ ] [ ] COUNTS = new char [ ] [ ] { new char [ ] { '<CHAR_LIT:/>' , '<CHAR_LIT:0>' } , new char [ ] { '<CHAR_LIT:/>' , '<CHAR_LIT:1>' } , new char [ ] { '<CHAR_LIT:/>' , '<CHAR_LIT>' } , new char [ ] { '<CHAR_LIT:/>' , '<CHAR_LIT>' } , new char [ ] { '<CHAR_LIT:/>' , '<CHAR_LIT>' } , new char [ ] { '<CHAR_LIT:/>' , '<CHAR_LIT>' } , new char [ ] { '<CHAR_LIT:/>' , '<CHAR_LIT>' } , new char [ ] { '<CHAR_LIT:/>' , '<CHAR_LIT>' } , new char [ ] { '<CHAR_LIT:/>' , '<CHAR_LIT>' } , new char [ ] { '<CHAR_LIT:/>' , '<CHAR_LIT:9>' } } ; char [ ] DEFAULT_CONSTRUCTOR = new char [ ] { '<CHAR_LIT:/>' , '<CHAR_LIT>' } ; char CLASS_SUFFIX = '<CHAR_LIT>' ; char INTERFACE_SUFFIX = '<CHAR_LIT>' ; char ENUM_SUFFIX = '<CHAR_LIT>' ; char ANNOTATION_TYPE_SUFFIX = '<CHAR_LIT:A>' ; char TYPE_SUFFIX = <NUM_LIT:0> ; char CLASS_AND_ENUM_SUFFIX = IJavaSearchConstants . CLASS_AND_ENUM ; char CLASS_AND_INTERFACE_SUFFIX = IJavaSearchConstants . CLASS_AND_INTERFACE ; char INTERFACE_AND_ANNOTATION_SUFFIX = IJavaSearchConstants . INTERFACE_AND_ANNOTATION ; char SEPARATOR = '<CHAR_LIT:/>' ; char PARAMETER_SEPARATOR = '<CHAR_LIT:U+002C>' ; char SECONDARY_SUFFIX = '<CHAR_LIT>' ; char [ ] ONE_STAR = new char [ ] { '<CHAR_LIT>' } ; char [ ] [ ] ONE_STAR_CHAR = new char [ ] [ ] { ONE_STAR } ; char ZERO_CHAR = '<CHAR_LIT:0>' ; char [ ] ONE_ZERO = new char [ ] { ZERO_CHAR } ; char [ ] [ ] ONE_ZERO_CHAR = new char [ ] [ ] { ONE_ZERO } ; int PKG_REF_PATTERN = <NUM_LIT> ; int PKG_DECL_PATTERN = <NUM_LIT> ; int TYPE_REF_PATTERN = <NUM_LIT> ; int TYPE_DECL_PATTERN = <NUM_LIT> ; int SUPER_REF_PATTERN = <NUM_LIT> ; int CONSTRUCTOR_PATTERN = <NUM_LIT> ; int FIELD_PATTERN = <NUM_LIT> ; int METHOD_PATTERN = <NUM_LIT> ; int OR_PATTERN = <NUM_LIT> ; int LOCAL_VAR_PATTERN = <NUM_LIT> ; int TYPE_PARAM_PATTERN = <NUM_LIT> ; int AND_PATTERN = <NUM_LIT> ; int ANNOT_REF_PATTERN = <NUM_LIT> ; } </s>
<s> package org . eclipse . jdt . internal . core . search . indexing ; import java . io . IOException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . internal . core . index . Index ; import org . eclipse . jdt . internal . core . search . processing . JobManager ; import org . eclipse . jdt . internal . core . util . Util ; public class SaveIndex extends IndexRequest { public SaveIndex ( IPath containerPath , IndexManager manager ) { super ( containerPath , manager ) ; } public boolean execute ( IProgressMonitor progressMonitor ) { if ( this . isCancelled || progressMonitor != null && progressMonitor . isCanceled ( ) ) return true ; Index index = this . manager . getIndex ( this . containerPath , true , false ) ; if ( index == null ) return true ; ReadWriteMonitor monitor = index . monitor ; if ( monitor == null ) return true ; try { monitor . enterWrite ( ) ; this . manager . saveIndex ( index ) ; } catch ( IOException e ) { if ( JobManager . VERBOSE ) { Util . verbose ( "<STR_LIT>" + this . containerPath + "<STR_LIT>" , System . err ) ; e . printStackTrace ( ) ; } return false ; } finally { monitor . exitWrite ( ) ; } return true ; } public String toString ( ) { return "<STR_LIT>" + this . containerPath ; } } </s>
<s> package org . eclipse . jdt . internal . core . search . indexing ; import java . io . File ; import java . io . IOException ; import java . net . URI ; import java . util . Enumeration ; import java . util . zip . ZipEntry ; import java . util . zip . ZipFile ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . core . search . IJavaSearchScope ; import org . eclipse . jdt . core . search . SearchEngine ; import org . eclipse . jdt . core . search . SearchParticipant ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . compiler . util . Util ; import org . eclipse . jdt . internal . core . JavaModelManager ; import org . eclipse . jdt . internal . core . index . Index ; import org . eclipse . jdt . internal . core . search . JavaSearchDocument ; import org . eclipse . jdt . internal . core . search . processing . JobManager ; class AddJarFileToIndex extends IndexRequest { private static final char JAR_SEPARATOR = IJavaSearchScope . JAR_FILE_ENTRY_SEPARATOR . charAt ( <NUM_LIT:0> ) ; IFile resource ; Scanner scanner ; public AddJarFileToIndex ( IFile resource , IndexManager manager ) { super ( resource . getFullPath ( ) , manager ) ; this . resource = resource ; } public AddJarFileToIndex ( IPath jarPath , IndexManager manager ) { super ( jarPath , manager ) ; } public boolean equals ( Object o ) { if ( o instanceof AddJarFileToIndex ) { if ( this . resource != null ) return this . resource . equals ( ( ( AddJarFileToIndex ) o ) . resource ) ; if ( this . containerPath != null ) return this . containerPath . equals ( ( ( AddJarFileToIndex ) o ) . containerPath ) ; } return false ; } public int hashCode ( ) { if ( this . resource != null ) return this . resource . hashCode ( ) ; if ( this . containerPath != null ) return this . containerPath . hashCode ( ) ; return - <NUM_LIT:1> ; } public boolean execute ( IProgressMonitor progressMonitor ) { if ( this . isCancelled || progressMonitor != null && progressMonitor . isCanceled ( ) ) return true ; try { Index index = this . manager . getIndexForUpdate ( this . containerPath , false , false ) ; if ( index != null ) { if ( JobManager . VERBOSE ) org . eclipse . jdt . internal . core . util . Util . verbose ( "<STR_LIT>" + this . containerPath ) ; return true ; } index = this . manager . getIndexForUpdate ( this . containerPath , true , true ) ; if ( index == null ) { if ( JobManager . VERBOSE ) org . eclipse . jdt . internal . core . util . Util . verbose ( "<STR_LIT>" + this . containerPath ) ; return true ; } ReadWriteMonitor monitor = index . monitor ; if ( monitor == null ) { if ( JobManager . VERBOSE ) org . eclipse . jdt . internal . core . util . Util . verbose ( "<STR_LIT>" + this . containerPath + "<STR_LIT>" ) ; return true ; } index . separator = JAR_SEPARATOR ; ZipFile zip = null ; try { Path zipFilePath = null ; monitor . enterWrite ( ) ; if ( this . resource != null ) { URI location = this . resource . getLocationURI ( ) ; if ( location == null ) return false ; if ( JavaModelManager . ZIP_ACCESS_VERBOSE ) System . out . println ( "<STR_LIT:(>" + Thread . currentThread ( ) + "<STR_LIT>" + location . getPath ( ) ) ; File file = null ; try { file = org . eclipse . jdt . internal . core . util . Util . toLocalFile ( location , progressMonitor ) ; } catch ( CoreException e ) { if ( JobManager . VERBOSE ) { org . eclipse . jdt . internal . core . util . Util . verbose ( "<STR_LIT>" + location . getPath ( ) + "<STR_LIT>" ) ; e . printStackTrace ( ) ; } } if ( file == null ) { if ( JobManager . VERBOSE ) org . eclipse . jdt . internal . core . util . Util . verbose ( "<STR_LIT>" + location . getPath ( ) + "<STR_LIT>" ) ; return false ; } zip = new ZipFile ( file ) ; zipFilePath = ( Path ) this . resource . getFullPath ( ) . makeRelative ( ) ; } else { if ( JavaModelManager . ZIP_ACCESS_VERBOSE ) System . out . println ( "<STR_LIT:(>" + Thread . currentThread ( ) + "<STR_LIT>" + this . containerPath ) ; zip = new ZipFile ( this . containerPath . toFile ( ) ) ; zipFilePath = ( Path ) this . containerPath ; } if ( this . isCancelled ) { if ( JobManager . VERBOSE ) org . eclipse . jdt . internal . core . util . Util . verbose ( "<STR_LIT>" + zip . getName ( ) + "<STR_LIT>" ) ; return false ; } if ( JobManager . VERBOSE ) org . eclipse . jdt . internal . core . util . Util . verbose ( "<STR_LIT>" + zip . getName ( ) ) ; long initialTime = System . currentTimeMillis ( ) ; String [ ] paths = index . queryDocumentNames ( "<STR_LIT>" ) ; if ( paths != null ) { int max = paths . length ; String EXISTS = "<STR_LIT:OK>" ; String DELETED = "<STR_LIT>" ; SimpleLookupTable indexedFileNames = new SimpleLookupTable ( max == <NUM_LIT:0> ? <NUM_LIT> : max + <NUM_LIT:11> ) ; for ( int i = <NUM_LIT:0> ; i < max ; i ++ ) indexedFileNames . put ( paths [ i ] , DELETED ) ; for ( Enumeration e = zip . entries ( ) ; e . hasMoreElements ( ) ; ) { ZipEntry ze = ( ZipEntry ) e . nextElement ( ) ; String zipEntryName = ze . getName ( ) ; if ( Util . isClassFileName ( zipEntryName ) && isValidPackageNameForClass ( zipEntryName ) ) indexedFileNames . put ( zipEntryName , EXISTS ) ; } boolean needToReindex = indexedFileNames . elementSize != max ; if ( ! needToReindex ) { Object [ ] valueTable = indexedFileNames . valueTable ; for ( int i = <NUM_LIT:0> , l = valueTable . length ; i < l ; i ++ ) { if ( valueTable [ i ] == DELETED ) { needToReindex = true ; break ; } } if ( ! needToReindex ) { if ( JobManager . VERBOSE ) org . eclipse . jdt . internal . core . util . Util . verbose ( "<STR_LIT>" + zip . getName ( ) + "<STR_LIT:U+0020(>" + ( System . currentTimeMillis ( ) - initialTime ) + "<STR_LIT>" ) ; this . manager . saveIndex ( index ) ; return true ; } } } SearchParticipant participant = SearchEngine . getDefaultSearchParticipant ( ) ; if ( ! this . manager . resetIndex ( this . containerPath ) ) { this . manager . removeIndex ( this . containerPath ) ; return false ; } index . separator = JAR_SEPARATOR ; for ( Enumeration e = zip . entries ( ) ; e . hasMoreElements ( ) ; ) { if ( this . isCancelled ) { if ( JobManager . VERBOSE ) org . eclipse . jdt . internal . core . util . Util . verbose ( "<STR_LIT>" + zip . getName ( ) + "<STR_LIT>" ) ; return false ; } ZipEntry ze = ( ZipEntry ) e . nextElement ( ) ; String zipEntryName = ze . getName ( ) ; if ( Util . isClassFileName ( zipEntryName ) && isValidPackageNameForClass ( zipEntryName ) ) { final byte [ ] classFileBytes = org . eclipse . jdt . internal . compiler . util . Util . getZipEntryByteContent ( ze , zip ) ; JavaSearchDocument entryDocument = new JavaSearchDocument ( ze , zipFilePath , classFileBytes , participant ) ; this . manager . indexDocument ( entryDocument , participant , index , this . containerPath ) ; } } this . manager . saveIndex ( index ) ; if ( JobManager . VERBOSE ) org . eclipse . jdt . internal . core . util . Util . verbose ( "<STR_LIT>" + zip . getName ( ) + "<STR_LIT:U+0020(>" + ( System . currentTimeMillis ( ) - initialTime ) + "<STR_LIT>" ) ; } finally { if ( zip != null ) { if ( JavaModelManager . ZIP_ACCESS_VERBOSE ) System . out . println ( "<STR_LIT:(>" + Thread . currentThread ( ) + "<STR_LIT>" + zip ) ; zip . close ( ) ; } monitor . exitWrite ( ) ; } } catch ( IOException e ) { if ( JobManager . VERBOSE ) { org . eclipse . jdt . internal . core . util . Util . verbose ( "<STR_LIT>" + this . containerPath + "<STR_LIT>" ) ; e . printStackTrace ( ) ; } this . manager . removeIndex ( this . containerPath ) ; return false ; } return true ; } public String getJobFamily ( ) { if ( this . resource != null ) return super . getJobFamily ( ) ; return this . containerPath . toOSString ( ) ; } private boolean isValidPackageNameForClass ( String className ) { char [ ] classNameArray = className . toCharArray ( ) ; if ( this . scanner == null ) this . scanner = new Scanner ( false , true , false , ClassFileConstants . JDK1_3 , null , null , true ) ; this . scanner . setSource ( classNameArray ) ; this . scanner . eofPosition = classNameArray . length - SuffixConstants . SUFFIX_CLASS . length ; try { if ( this . scanner . scanIdentifier ( ) == TerminalTokens . TokenNameIdentifier ) { while ( this . scanner . eofPosition > this . scanner . currentPosition ) { if ( this . scanner . getNextChar ( ) != '<CHAR_LIT:/>' || this . scanner . eofPosition <= this . scanner . currentPosition ) { return false ; } if ( this . scanner . scanIdentifier ( ) != TerminalTokens . TokenNameIdentifier ) { return false ; } } return true ; } } catch ( InvalidInputException e ) { } return false ; } protected Integer updatedIndexState ( ) { return IndexManager . REBUILDING_STATE ; } public String toString ( ) { return "<STR_LIT>" + this . containerPath . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . core . search . indexing ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . Path ; import org . eclipse . jdt . core . JavaCore ; import org . eclipse . jdt . core . search . SearchDocument ; import org . eclipse . jdt . internal . compiler . SourceElementParser ; import org . eclipse . jdt . internal . compiler . util . SuffixConstants ; import org . eclipse . jdt . internal . core . JavaModelManager ; import org . eclipse . jdt . internal . core . jdom . CompilationUnit ; import org . eclipse . jdt . internal . core . search . processing . JobManager ; public class SourceIndexer extends AbstractIndexer implements SuffixConstants { public SourceIndexer ( SearchDocument document ) { super ( document ) ; } public void indexDocument ( ) { SourceIndexerRequestor requestor = new SourceIndexerRequestor ( this ) ; String documentPath = this . document . getPath ( ) ; SourceElementParser parser = this . document . getParser ( ) ; if ( parser == null ) { IPath path = new Path ( documentPath ) ; IProject project = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getProject ( path . segment ( <NUM_LIT:0> ) ) ; parser = JavaModelManager . getJavaModelManager ( ) . indexManager . getSourceElementParser ( JavaCore . create ( project ) , requestor ) ; } else { parser . setRequestor ( requestor ) ; } char [ ] source = null ; char [ ] name = null ; try { source = this . document . getCharContents ( ) ; name = documentPath . toCharArray ( ) ; } catch ( Exception e ) { } if ( source == null || name == null ) return ; CompilationUnit compilationUnit = new CompilationUnit ( source , name ) ; try { parser . parseCompilationUnit ( compilationUnit , true , null ) ; } catch ( Exception e ) { if ( JobManager . VERBOSE ) { e . printStackTrace ( ) ; } } } } </s>
<s> package org . eclipse . jdt . internal . core . search . indexing ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . IProblemFactory ; import org . eclipse . jdt . internal . compiler . ISourceElementRequestor ; import org . eclipse . jdt . internal . compiler . SourceElementParser ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . ImportReference ; import org . eclipse . jdt . internal . compiler . ast . QualifiedNameReference ; import org . eclipse . jdt . internal . compiler . ast . SingleNameReference ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; public class IndexingParser extends SourceElementParser { SingleNameReference singleNameReference = new SingleNameReference ( CharOperation . NO_CHAR , <NUM_LIT:0> ) ; QualifiedNameReference qualifiedNameReference = new QualifiedNameReference ( CharOperation . NO_CHAR_CHAR , new long [ <NUM_LIT:0> ] , <NUM_LIT:0> , <NUM_LIT:0> ) ; ImportReference importReference = new ImportReference ( CharOperation . NO_CHAR_CHAR , new long [ <NUM_LIT:1> ] , false , <NUM_LIT:0> ) ; public IndexingParser ( ISourceElementRequestor requestor , IProblemFactory problemFactory , CompilerOptions options , boolean reportLocalDeclarations , boolean optimizeStringLiterals , boolean useSourceJavadocParser ) { super ( requestor , problemFactory , options , reportLocalDeclarations , optimizeStringLiterals , useSourceJavadocParser ) ; } protected ImportReference newImportReference ( char [ ] [ ] tokens , long [ ] sourcePositions , boolean onDemand , int mod ) { ImportReference ref = this . importReference ; ref . tokens = tokens ; ref . sourcePositions = sourcePositions ; if ( onDemand ) { ref . bits |= ASTNode . OnDemand ; } ref . sourceEnd = ( int ) ( sourcePositions [ sourcePositions . length - <NUM_LIT:1> ] & <NUM_LIT> ) ; ref . sourceStart = ( int ) ( sourcePositions [ <NUM_LIT:0> ] > > > <NUM_LIT:32> ) ; ref . modifiers = this . modifiers ; return ref ; } protected SingleNameReference newSingleNameReference ( char [ ] source , long positions ) { SingleNameReference ref = this . singleNameReference ; ref . token = source ; ref . sourceStart = ( int ) ( positions > > > <NUM_LIT:32> ) ; ref . sourceEnd = ( int ) positions ; return ref ; } protected QualifiedNameReference newQualifiedNameReference ( char [ ] [ ] tokens , long [ ] positions , int sourceStart , int sourceEnd ) { QualifiedNameReference ref = this . qualifiedNameReference ; ref . tokens = tokens ; ref . sourcePositions = positions ; ref . sourceStart = sourceStart ; ref . sourceEnd = sourceEnd ; return ref ; } } </s>
<s> package org . eclipse . jdt . internal . core . search . indexing ; import java . io . IOException ; import java . net . URI ; import org . eclipse . core . filesystem . EFS ; import org . eclipse . core . resources . IContainer ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . IResourceProxy ; import org . eclipse . core . resources . IResourceProxyVisitor ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jdt . internal . compiler . util . SimpleLookupTable ; import org . eclipse . jdt . internal . core . index . Index ; import org . eclipse . jdt . internal . core . search . processing . JobManager ; import org . eclipse . jdt . internal . core . util . Util ; public class IndexBinaryFolder extends IndexRequest { IContainer folder ; public IndexBinaryFolder ( IContainer folder , IndexManager manager ) { super ( folder . getFullPath ( ) , manager ) ; this . folder = folder ; } public boolean equals ( Object o ) { if ( o instanceof IndexBinaryFolder ) return this . folder . equals ( ( ( IndexBinaryFolder ) o ) . folder ) ; return false ; } public boolean execute ( IProgressMonitor progressMonitor ) { if ( this . isCancelled || progressMonitor != null && progressMonitor . isCanceled ( ) ) return true ; if ( ! this . folder . isAccessible ( ) ) return true ; Index index = this . manager . getIndexForUpdate ( this . containerPath , true , true ) ; if ( index == null ) return true ; ReadWriteMonitor monitor = index . monitor ; if ( monitor == null ) return true ; try { monitor . enterRead ( ) ; String [ ] paths = index . queryDocumentNames ( "<STR_LIT>" ) ; int max = paths == null ? <NUM_LIT:0> : paths . length ; final SimpleLookupTable indexedFileNames = new SimpleLookupTable ( max == <NUM_LIT:0> ? <NUM_LIT> : max + <NUM_LIT:11> ) ; final String OK = "<STR_LIT:OK>" ; final String DELETED = "<STR_LIT>" ; if ( paths == null ) { this . folder . accept ( new IResourceProxyVisitor ( ) { public boolean visit ( IResourceProxy proxy ) { if ( IndexBinaryFolder . this . isCancelled ) return false ; if ( proxy . getType ( ) == IResource . FILE ) { if ( org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( proxy . getName ( ) ) ) { IFile file = ( IFile ) proxy . requestResource ( ) ; String containerRelativePath = Util . relativePath ( file . getFullPath ( ) , IndexBinaryFolder . this . containerPath . segmentCount ( ) ) ; indexedFileNames . put ( containerRelativePath , file ) ; } return false ; } return true ; } } , IResource . NONE ) ; } else { for ( int i = <NUM_LIT:0> ; i < max ; i ++ ) { indexedFileNames . put ( paths [ i ] , DELETED ) ; } final long indexLastModified = index . getIndexFile ( ) . lastModified ( ) ; this . folder . accept ( new IResourceProxyVisitor ( ) { public boolean visit ( IResourceProxy proxy ) throws CoreException { if ( IndexBinaryFolder . this . isCancelled ) return false ; if ( proxy . getType ( ) == IResource . FILE ) { if ( org . eclipse . jdt . internal . compiler . util . Util . isClassFileName ( proxy . getName ( ) ) ) { IFile file = ( IFile ) proxy . requestResource ( ) ; URI location = file . getLocationURI ( ) ; if ( location != null ) { String containerRelativePath = Util . relativePath ( file . getFullPath ( ) , IndexBinaryFolder . this . containerPath . segmentCount ( ) ) ; indexedFileNames . put ( containerRelativePath , indexedFileNames . get ( containerRelativePath ) == null || indexLastModified < EFS . getStore ( location ) . fetchInfo ( ) . getLastModified ( ) ? ( Object ) file : ( Object ) OK ) ; } } return false ; } return true ; } } , IResource . NONE ) ; } Object [ ] names = indexedFileNames . keyTable ; Object [ ] values = indexedFileNames . valueTable ; for ( int i = <NUM_LIT:0> , length = names . length ; i < length ; i ++ ) { String name = ( String ) names [ i ] ; if ( name != null ) { if ( this . isCancelled ) return false ; Object value = values [ i ] ; if ( value != OK ) { if ( value == DELETED ) this . manager . remove ( name , this . containerPath ) ; else { this . manager . addBinary ( ( IFile ) value , this . containerPath ) ; } } } } this . manager . request ( new SaveIndex ( this . containerPath , this . manager ) ) ; } catch ( CoreException e ) { if ( JobManager . VERBOSE ) { Util . verbose ( "<STR_LIT>" + this . folder + "<STR_LIT>" , System . err ) ; e . printStackTrace ( ) ; } this . manager . removeIndex ( this . containerPath ) ; return false ; } catch ( IOException e ) { if ( JobManager . VERBOSE ) { Util . verbose ( "<STR_LIT>" + this . folder + "<STR_LIT>" , System . err ) ; e . printStackTrace ( ) ; } this . manager . removeIndex ( this . containerPath ) ; return false ; } finally { monitor . exitRead ( ) ; } return true ; } public int hashCode ( ) { return this . folder . hashCode ( ) ; } protected Integer updatedIndexState ( ) { return IndexManager . REBUILDING_STATE ; } public String toString ( ) { return "<STR_LIT>" + this . folder . getFullPath ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . core . search . indexing ; public class ReadWriteMonitor { private int status = <NUM_LIT:0> ; public synchronized void enterRead ( ) { while ( this . status < <NUM_LIT:0> ) { try { wait ( ) ; } catch ( InterruptedException e ) { } } this . status ++ ; } public synchronized void enterWrite ( ) { while ( this . status != <NUM_LIT:0> ) { try { wait ( ) ; } catch ( InterruptedException e ) { } } this . status -- ; } public synchronized void exitRead ( ) { if ( -- this . status == <NUM_LIT:0> ) notifyAll ( ) ; } public synchronized void exitWrite ( ) { if ( ++ this . status == <NUM_LIT:0> ) notifyAll ( ) ; } public synchronized boolean exitReadEnterWrite ( ) { if ( this . status != <NUM_LIT:1> ) return false ; this . status = - <NUM_LIT:1> ; return true ; } public synchronized void exitWriteEnterRead ( ) { exitWrite ( ) ; enterRead ( ) ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( ) ; if ( this . status == <NUM_LIT:0> ) { buffer . append ( "<STR_LIT>" ) ; } else if ( this . status < <NUM_LIT:0> ) { buffer . append ( "<STR_LIT>" ) ; } else if ( this . status > <NUM_LIT:0> ) { buffer . append ( "<STR_LIT>" ) ; } buffer . append ( "<STR_LIT>" ) ; buffer . append ( this . status ) ; buffer . append ( "<STR_LIT:)>" ) ; return buffer . toString ( ) ; } } </s>
<s> package org . eclipse . jdt . internal . core . search ; import org . eclipse . jdt . core . search . SearchParticipant ; import org . eclipse . jdt . core . search . SearchPattern ; import org . eclipse . jdt . internal . compiler . env . AccessRuleSet ; public abstract class IndexQueryRequestor { public abstract boolean acceptIndexMatch ( String documentPath , SearchPattern indexRecord , SearchParticipant participant , AccessRuleSet access ) ; } </s>