idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
900
private void handleException ( String key , Exception e ) { if ( e != null ) { log . error ( key , e . getLocalizedMessage ( ) ) ; throw new Abort ( e ) ; } else { log . error ( key ) ; throw new Abort ( ) ; } }
Handle a security exception thrown during initializing the Processor iterator .
901
private static < T > List < T > join ( List < T > list1 , List < T > list2 ) { return list1 . appendList ( list2 ) ; }
avoid unchecked warning from use of varargs
902
private static Pattern importStringToPattern ( boolean allowModules , String s , Processor p , Log log ) { String module ; String pkg ; int slash = s . indexOf ( '/' ) ; if ( slash == ( - 1 ) ) { if ( s . equals ( "*" ) ) { return MatchingUtils . validImportStringToPattern ( s ) ; } module = allowModules ? ".*/" : "" ; pkg = s ; } else { module = Pattern . quote ( s . substring ( 0 , slash + 1 ) ) ; pkg = s . substring ( slash + 1 ) ; } if ( MatchingUtils . isValidImportString ( pkg ) ) { return Pattern . compile ( module + MatchingUtils . validImportStringToPatternString ( pkg ) ) ; } else { log . warning ( "proc.malformed.supported.string" , s , p . getClass ( ) . getName ( ) ) ; return noMatches ; } }
Convert import - style string for supported annotations into a regex matching that string . If the string is not a valid import - style string return a regex that won t match anything .
903
public void build ( XMLNode node , Content contentTree ) throws DocletException { if ( hasMembersToDocument ( ) ) { super . build ( node , contentTree ) ; } }
Builds the sub component if there is anything to document .
904
private Stream < ImportSnippet > importSnippets ( ) { return state . keyMap . importKeys ( ) . map ( key -> ( ImportSnippet ) getSnippet ( key ) ) . filter ( sn -> sn != null && state . status ( sn ) . isDefined ( ) ) ; }
Compute the set of imports to prepend to a snippet
905
private < S extends Symbol > S nameToSymbol ( ModuleSymbol module , String nameStr , Class < S > clazz ) { Name name = names . fromString ( nameStr ) ; Symbol sym = ( clazz == ClassSymbol . class ) ? syms . getClass ( module , name ) : syms . lookupPackage ( module , name ) ; try { if ( sym == null ) sym = javaCompiler . resolveIdent ( module , nameStr ) ; sym . complete ( ) ; return ( sym . kind != ERR && sym . exists ( ) && clazz . isInstance ( sym ) && name . equals ( sym . getQualifiedName ( ) ) ) ? clazz . cast ( sym ) : null ; } catch ( CompletionFailure e ) { return null ; } }
Returns a symbol given the type s or package s canonical name or null if the name isn t found .
906
private JCExpression scanForAssign ( final MethodSymbol sym , final JCTree tree ) { class TS extends TreeScanner { JCExpression result = null ; public void scan ( JCTree t ) { if ( t != null && result == null ) t . accept ( this ) ; } public void visitAnnotation ( JCAnnotation t ) { if ( t == tree ) scan ( t . args ) ; } public void visitAssign ( JCAssign t ) { if ( t . lhs . hasTag ( IDENT ) ) { JCIdent ident = ( JCIdent ) t . lhs ; if ( ident . sym == sym ) result = t . rhs ; } } } TS scanner = new TS ( ) ; tree . accept ( scanner ) ; return scanner . result ; }
Scans for a JCAssign node with a LHS matching a given symbol and returns its RHS . Does not scan nested JCAnnotations .
907
public JCTree getTree ( Element e ) { Pair < JCTree , ? > treeTop = getTreeAndTopLevel ( e ) ; return ( treeTop != null ) ? treeTop . fst : null ; }
Returns the tree node corresponding to this element or null if none can be found .
908
public com . sun . javadoc . Type [ ] typeArguments ( ) { return TypeMaker . getTypes ( env , type . getTypeArguments ( ) ) ; }
Return the actual type arguments of this type .
909
public com . sun . javadoc . Type superclassType ( ) { if ( asClassDoc ( ) . isInterface ( ) ) { return null ; } Type sup = env . types . supertype ( type ) ; return TypeMaker . getType ( env , ( sup != type ) ? sup : env . syms . objectType ) ; }
Return the class type that is a direct supertype of this one . Return null if this is an interface type .
910
public com . sun . javadoc . Type containingType ( ) { if ( type . getEnclosingType ( ) . hasTag ( CLASS ) ) { return TypeMaker . getType ( env , type . getEnclosingType ( ) ) ; } ClassSymbol enclosing = type . tsym . owner . enclClass ( ) ; if ( enclosing != null ) { return env . getClassDoc ( enclosing ) ; } return null ; }
Return the type that contains this type as a member . Return null is this is a top - level type .
911
public static void setOrAdd ( EObject owner , EReference reference , Object value ) { if ( value != null ) { if ( reference . isMany ( ) ) { @ SuppressWarnings ( "unchecked" ) Collection < EObject > values = ( Collection < EObject > ) owner . eGet ( reference , false ) ; if ( values != null && value instanceof EObject ) { values . add ( ( EObject ) value ) ; } } else { owner . eSet ( reference , value ) ; } } }
Set or add a value to an object reference . The value must be an EObject .
912
public static boolean isContainmentProxy ( DatabindContext ctxt , EObject owner , EObject contained ) { if ( contained . eIsProxy ( ) ) return true ; Resource ownerResource = EMFContext . getResource ( ctxt , owner ) ; Resource containedResource = EMFContext . getResource ( ctxt , contained ) ; return ownerResource != null && ownerResource != containedResource ; }
Checks that the contained object is in a different resource than it s owner making it a contained proxy .
913
@ SuppressWarnings ( "unchecked" ) public static EObject createEntry ( String key , Object value , EClass type ) { if ( type == EcorePackage . Literals . ESTRING_TO_STRING_MAP_ENTRY ) { final EObject entry = EcoreUtil . create ( EcorePackage . Literals . ESTRING_TO_STRING_MAP_ENTRY ) ; entry . eSet ( EcorePackage . Literals . ESTRING_TO_STRING_MAP_ENTRY__KEY , key ) ; entry . eSet ( EcorePackage . Literals . ESTRING_TO_STRING_MAP_ENTRY__VALUE , value ) ; return entry ; } else { final BasicEMapEntry entry = new BasicEMapEntry < > ( ) ; entry . eSetClass ( type ) ; entry . setKey ( key ) ; entry . setValue ( value ) ; return entry ; } }
Creates a map entry of type string string .
914
protected Content getNavLinkDeprecated ( ) { Content li = HtmlTree . LI ( HtmlStyle . navBarCell1Rev , contents . deprecatedLabel ) ; return li ; }
Get the deprecated label .
915
Type signature ( MethodSymbol msym , List < JCTypeParameter > typarams , List < JCVariableDecl > params , JCTree res , JCVariableDecl recvparam , List < JCExpression > thrown , Env < AttrContext > env ) { List < Type > tvars = enter . classEnter ( typarams , env ) ; attr . attribTypeVariables ( typarams , env ) ; ListBuffer < Type > argbuf = new ListBuffer < > ( ) ; for ( List < JCVariableDecl > l = params ; l . nonEmpty ( ) ; l = l . tail ) { memberEnter ( l . head , env ) ; argbuf . append ( l . head . vartype . type ) ; } Type restype = res == null ? syms . voidType : attr . attribType ( res , env ) ; Type recvtype ; if ( recvparam != null ) { memberEnter ( recvparam , env ) ; recvtype = recvparam . vartype . type ; } else { recvtype = null ; } ListBuffer < Type > thrownbuf = new ListBuffer < > ( ) ; for ( List < JCExpression > l = thrown ; l . nonEmpty ( ) ; l = l . tail ) { Type exc = attr . attribType ( l . head , env ) ; if ( ! exc . hasTag ( TYPEVAR ) ) { exc = chk . checkClassType ( l . head . pos ( ) , exc ) ; } else if ( exc . tsym . owner == msym ) { exc . tsym . flags_field |= THROWS ; } thrownbuf . append ( exc ) ; } MethodType mtype = new MethodType ( argbuf . toList ( ) , restype , thrownbuf . toList ( ) , syms . methodClass ) ; mtype . recvtype = recvtype ; return tvars . isEmpty ( ) ? mtype : new ForAll ( tvars , mtype ) ; }
Construct method type from method signature .
916
protected void memberEnter ( JCTree tree , Env < AttrContext > env ) { Env < AttrContext > prevEnv = this . env ; try { this . env = env ; tree . accept ( this ) ; } catch ( CompletionFailure ex ) { chk . completionError ( tree . pos ( ) , ex ) ; } finally { this . env = prevEnv ; } }
Enter field and method definitions and process import clauses catching any completion failure exceptions .
917
void memberEnter ( List < ? extends JCTree > trees , Env < AttrContext > env ) { for ( List < ? extends JCTree > l = trees ; l . nonEmpty ( ) ; l = l . tail ) memberEnter ( l . head , env ) ; }
Enter members from a list of trees .
918
Env < AttrContext > methodEnv ( JCMethodDecl tree , Env < AttrContext > env ) { Env < AttrContext > localEnv = env . dup ( tree , env . info . dup ( env . info . scope . dupUnshared ( tree . sym ) ) ) ; localEnv . enclMethod = tree ; if ( tree . sym . type != null ) { localEnv . info . returnResult = attr . new ResultInfo ( KindSelector . VAL , tree . sym . type . getReturnType ( ) ) ; } if ( ( tree . mods . flags & STATIC ) != 0 ) localEnv . info . staticLevel ++ ; return localEnv ; }
Create a fresh environment for method bodies .
919
Env < AttrContext > initEnv ( JCVariableDecl tree , Env < AttrContext > env ) { Env < AttrContext > localEnv = env . dupto ( new AttrContextEnv ( tree , env . info . dup ( ) ) ) ; if ( tree . sym . owner . kind == TYP ) { localEnv . info . scope = env . info . scope . dupUnshared ( tree . sym ) ; } if ( ( tree . mods . flags & STATIC ) != 0 || ( ( env . enclClass . sym . flags ( ) & INTERFACE ) != 0 && env . enclMethod == null ) ) localEnv . info . staticLevel ++ ; return localEnv ; }
Create a fresh environment for a variable s initializer . If the variable is a field the owner of the environment s scope is be the variable itself otherwise the owner is the method enclosing the variable definition .
920
public static int utf2chars ( byte [ ] src , int sindex , char [ ] dst , int dindex , int len ) { int i = sindex ; int j = dindex ; int limit = sindex + len ; while ( i < limit ) { int b = src [ i ++ ] & 0xFF ; if ( b >= 0xE0 ) { b = ( b & 0x0F ) << 12 ; b = b | ( src [ i ++ ] & 0x3F ) << 6 ; b = b | ( src [ i ++ ] & 0x3F ) ; } else if ( b >= 0xC0 ) { b = ( b & 0x1F ) << 6 ; b = b | ( src [ i ++ ] & 0x3F ) ; } dst [ j ++ ] = ( char ) b ; } return j ; }
Convert len bytes from utf8 to characters . Parameters are as in System . arraycopy Return first index in dst past the last copied char .
921
public static char [ ] utf2chars ( byte [ ] src , int sindex , int len ) { char [ ] dst = new char [ len ] ; int len1 = utf2chars ( src , sindex , dst , 0 , len ) ; char [ ] result = new char [ len1 ] ; System . arraycopy ( dst , 0 , result , 0 , len1 ) ; return result ; }
Return bytes in Utf8 representation as an array of characters .
922
public static String utf2string ( byte [ ] src , int sindex , int len ) { char dst [ ] = new char [ len ] ; int len1 = utf2chars ( src , sindex , dst , 0 , len ) ; return new String ( dst , 0 , len1 ) ; }
Return bytes in Utf8 representation as a string .
923
public static int chars2utf ( char [ ] src , int sindex , byte [ ] dst , int dindex , int len ) { int j = dindex ; int limit = sindex + len ; for ( int i = sindex ; i < limit ; i ++ ) { char ch = src [ i ] ; if ( 1 <= ch && ch <= 0x7F ) { dst [ j ++ ] = ( byte ) ch ; } else if ( ch <= 0x7FF ) { dst [ j ++ ] = ( byte ) ( 0xC0 | ( ch >> 6 ) ) ; dst [ j ++ ] = ( byte ) ( 0x80 | ( ch & 0x3F ) ) ; } else { dst [ j ++ ] = ( byte ) ( 0xE0 | ( ch >> 12 ) ) ; dst [ j ++ ] = ( byte ) ( 0x80 | ( ( ch >> 6 ) & 0x3F ) ) ; dst [ j ++ ] = ( byte ) ( 0x80 | ( ch & 0x3F ) ) ; } } return j ; }
Copy characters in source array to bytes in target array converting them to Utf8 representation . The target array must be large enough to hold the result . returns first index in dst past the last copied byte .
924
public static String quote ( String s ) { StringBuilder buf = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { buf . append ( quote ( s . charAt ( i ) ) ) ; } return buf . toString ( ) ; }
Escapes each character in a string that has an escape sequence or is non - printable ASCII . Leaves non - ASCII characters alone .
925
public static String quote ( char ch ) { switch ( ch ) { case '\b' : return "\\b" ; case '\f' : return "\\f" ; case '\n' : return "\\n" ; case '\r' : return "\\r" ; case '\t' : return "\\t" ; case '\'' : return "\\'" ; case '\"' : return "\\\"" ; case '\\' : return "\\\\" ; default : return ( isPrintableAscii ( ch ) ) ? String . valueOf ( ch ) : String . format ( "\\u%04x" , ( int ) ch ) ; } }
Escapes a character if it has an escape sequence or is non - printable ASCII . Leaves non - ASCII characters alone .
926
public static String escapeUnicode ( String s ) { int len = s . length ( ) ; int i = 0 ; while ( i < len ) { char ch = s . charAt ( i ) ; if ( ch > 255 ) { StringBuilder buf = new StringBuilder ( ) ; buf . append ( s . substring ( 0 , i ) ) ; while ( i < len ) { ch = s . charAt ( i ) ; if ( ch > 255 ) { buf . append ( "\\u" ) ; buf . append ( Character . forDigit ( ( ch >> 12 ) % 16 , 16 ) ) ; buf . append ( Character . forDigit ( ( ch >> 8 ) % 16 , 16 ) ) ; buf . append ( Character . forDigit ( ( ch >> 4 ) % 16 , 16 ) ) ; buf . append ( Character . forDigit ( ( ch ) % 16 , 16 ) ) ; } else { buf . append ( ch ) ; } i ++ ; } s = buf . toString ( ) ; } else { i ++ ; } } return s ; }
Escape all unicode characters in string .
927
public static Name shortName ( Name classname ) { return classname . subName ( classname . lastIndexOf ( ( byte ) '.' ) + 1 , classname . getByteLength ( ) ) ; }
Return the last part of a class name .
928
private VariableElement getVariableElement ( Element holder , Configuration config , DocTree tag ) { Utils utils = config . utils ; CommentHelper ch = utils . getCommentHelper ( holder ) ; String signature = ch . getReferencedSignature ( tag ) ; if ( signature == null ) { if ( utils . isVariableElement ( holder ) ) { return ( VariableElement ) ( holder ) ; } else { return null ; } } String [ ] sigValues = signature . split ( "#" ) ; String memberName = null ; TypeElement te = null ; if ( sigValues . length == 1 ) { if ( utils . isExecutableElement ( holder ) || utils . isVariableElement ( holder ) ) { te = utils . getEnclosingTypeElement ( holder ) ; } else if ( utils . isTypeElement ( holder ) ) { te = utils . getTopMostContainingTypeElement ( holder ) ; } memberName = sigValues [ 0 ] ; } else { Elements elements = config . docEnv . getElementUtils ( ) ; te = elements . getTypeElement ( sigValues [ 0 ] ) ; memberName = sigValues [ 1 ] ; } if ( te == null ) { return null ; } for ( Element field : utils . getFields ( te ) ) { if ( utils . getSimpleName ( field ) . equals ( memberName ) ) { return ( VariableElement ) field ; } } return null ; }
Given the name of the field return the corresponding VariableElement . Return null due to invalid use of value tag if the name is null or empty string and if the value tag is not used on a field .
929
public Iterable < JavaFileObject > list ( JavaFileManager . Location location , String packageName , Set < JavaFileObject . Kind > kinds , boolean recurse ) throws IOException { Iterable < JavaFileObject > stdList = stdFileManager . list ( location , packageName , kinds , recurse ) ; if ( location == CLASS_PATH && packageName . equals ( "REPL" ) ) { return ( ) -> new Iterator < JavaFileObject > ( ) { boolean stdDone = false ; Iterator < ? extends JavaFileObject > it ; public boolean hasNext ( ) { if ( it == null ) { it = stdList . iterator ( ) ; } if ( it . hasNext ( ) ) { return true ; } if ( stdDone ) { return false ; } else { stdDone = true ; it = generatedClasses ( ) . iterator ( ) ; return it . hasNext ( ) ; } } public JavaFileObject next ( ) { if ( ! hasNext ( ) ) { throw new NoSuchElementException ( ) ; } return it . next ( ) ; } } ; } else { return stdList ; } }
Lists all file objects matching the given criteria in the given location . List file objects in subpackages if recurse is true .
930
public boolean isSameFile ( FileObject a , FileObject b ) { return stdFileManager . isSameFile ( b , b ) ; }
Compares two file objects and return true if they represent the same underlying object .
931
public int isSupportedOption ( String option ) { proc . debug ( DBG_FMGR , "isSupportedOption: %s\n" , option ) ; return stdFileManager . isSupportedOption ( option ) ; }
Determines if the given option is supported and if so the number of arguments the option takes .
932
public boolean hasLocation ( JavaFileManager . Location location ) { proc . debug ( DBG_FMGR , "hasLocation: location: %s\n" , location ) ; return stdFileManager . hasLocation ( location ) ; }
Determines if a location is known to this file manager .
933
protected void reportSyntaxError ( int pos , String key , Object ... args ) { JCDiagnostic . DiagnosticPosition diag = new JCDiagnostic . SimpleDiagnosticPosition ( pos ) ; reportSyntaxError ( diag , key , args ) ; }
Report a syntax using the given the position parameter and arguments unless one was already reported at the same position .
934
protected JCErroneous syntaxError ( String key , TokenKind arg ) { return syntaxError ( token . pos , key , arg ) ; }
Generate a syntax error at current position unless one was already reported at the same position .
935
public void accept ( TokenKind tk ) { if ( token . kind == tk ) { nextToken ( ) ; } else { setErrorEndPos ( token . pos ) ; reportSyntaxError ( S . prevToken ( ) . endPos , "expected" , tk ) ; } }
If next input token matches given token skip it otherwise report an error .
936
private JCExpression makeOp ( int pos , TokenKind topOp , JCExpression od1 , JCExpression od2 ) { if ( topOp == INSTANCEOF ) { return F . at ( pos ) . TypeTest ( od1 , od2 ) ; } else { return F . at ( pos ) . Binary ( optag ( topOp ) , od1 , od2 ) ; } }
Construct a binary or type test node .
937
protected JCExpression foldStrings ( JCExpression tree ) { if ( ! allowStringFolding ) return tree ; ListBuffer < JCExpression > opStack = new ListBuffer < > ( ) ; ListBuffer < JCLiteral > litBuf = new ListBuffer < > ( ) ; boolean needsFolding = false ; JCExpression curr = tree ; while ( true ) { if ( curr . hasTag ( JCTree . Tag . PLUS ) ) { JCBinary op = ( JCBinary ) curr ; needsFolding |= foldIfNeeded ( op . rhs , litBuf , opStack , false ) ; curr = op . lhs ; } else { needsFolding |= foldIfNeeded ( curr , litBuf , opStack , true ) ; break ; } } if ( needsFolding ) { List < JCExpression > ops = opStack . toList ( ) ; JCExpression res = ops . head ; for ( JCExpression op : ops . tail ) { res = F . at ( op . getStartPosition ( ) ) . Binary ( optag ( TokenKind . PLUS ) , res , op ) ; storeEnd ( res , getEndPos ( op ) ) ; } return res ; } else { return tree ; } }
If tree is a concatenation of string literals replace it by a single literal representing the concatenated string .
938
JCPrimitiveTypeTree basicType ( ) { JCPrimitiveTypeTree t = to ( F . at ( token . pos ) . TypeIdent ( typetag ( token . kind ) ) ) ; nextToken ( ) ; return t ; }
BasicType = BYTE | SHORT | CHAR | INT | LONG | FLOAT | DOUBLE | BOOLEAN
939
JCExpression bracketsSuffix ( JCExpression t ) { if ( ( mode & EXPR ) != 0 && token . kind == DOT ) { mode = EXPR ; int pos = token . pos ; nextToken ( ) ; accept ( CLASS ) ; if ( token . pos == endPosTable . errorEndPos ) { Name name ; if ( LAX_IDENTIFIER . accepts ( token . kind ) ) { name = token . name ( ) ; nextToken ( ) ; } else { name = names . error ; } t = F . at ( pos ) . Erroneous ( List . < JCTree > of ( toP ( F . at ( pos ) . Select ( t , name ) ) ) ) ; } else { Tag tag = t . getTag ( ) ; if ( ( tag == TYPEARRAY && TreeInfo . containsTypeAnnotation ( t ) ) || tag == ANNOTATED_TYPE ) syntaxError ( "no.annotations.on.dot.class" ) ; t = toP ( F . at ( pos ) . Select ( t , names . _class ) ) ; } } else if ( ( mode & TYPE ) != 0 ) { if ( token . kind != COLCOL ) { mode = TYPE ; } } else if ( token . kind != COLCOL ) { syntaxError ( token . pos , "dot.class.expected" ) ; } return t ; }
BracketsSuffixExpr = . CLASS BracketsSuffixType =
940
public JCExpression variableInitializer ( ) { return token . kind == LBRACE ? arrayInitializer ( token . pos , null ) : parseExpression ( ) ; }
VariableInitializer = ArrayInitializer | Expression
941
List < JCExpressionStatement > forUpdate ( ) { return moreStatementExpressions ( token . pos , parseExpression ( ) , new ListBuffer < JCExpressionStatement > ( ) ) . toList ( ) ; }
ForUpdate = StatementExpression MoreStatementExpressions
942
JCExpression annotationFieldValue ( ) { if ( LAX_IDENTIFIER . accepts ( token . kind ) ) { mode = EXPR ; JCExpression t1 = term1 ( ) ; if ( t1 . hasTag ( IDENT ) && token . kind == EQ ) { int pos = token . pos ; accept ( EQ ) ; JCExpression v = annotationValue ( ) ; return toP ( F . at ( pos ) . Assign ( t1 , v ) ) ; } else { return t1 ; } } return annotationValue ( ) ; }
AnnotationFieldValue = AnnotationValue | Identifier = AnnotationValue
943
JCVariableDecl variableDeclarator ( JCModifiers mods , JCExpression type , boolean reqInit , Comment dc ) { return variableDeclaratorRest ( token . pos , mods , type , ident ( ) , reqInit , dc ) ; }
VariableDeclarator = Ident VariableDeclaratorRest ConstantDeclarator = Ident ConstantDeclaratorRest
944
JCVariableDecl variableDeclaratorId ( JCModifiers mods , JCExpression type ) { return variableDeclaratorId ( mods , type , false ) ; }
VariableDeclaratorId = Ident BracketsOpt
945
protected JCTree resource ( ) { int startPos = token . pos ; if ( token . kind == FINAL || token . kind == MONKEYS_AT ) { JCModifiers mods = optFinal ( Flags . FINAL ) ; JCExpression t = parseType ( ) ; return variableDeclaratorRest ( token . pos , mods , t , ident ( ) , true , null ) ; } JCExpression t = term ( EXPR | TYPE ) ; if ( ( lastmode & TYPE ) != 0 && LAX_IDENTIFIER . accepts ( token . kind ) ) { JCModifiers mods = toP ( F . at ( startPos ) . Modifiers ( Flags . FINAL ) ) ; return variableDeclaratorRest ( token . pos , mods , t , ident ( ) , true , null ) ; } else { checkVariableInTryWithResources ( startPos ) ; if ( ! t . hasTag ( IDENT ) && ! t . hasTag ( SELECT ) ) { log . error ( t . pos ( ) , "try.with.resources.expr.needs.var" ) ; } return t ; } }
Resource = VariableModifiersOpt Type VariableDeclaratorId = Expression | Expression
946
JCTree typeDeclaration ( JCModifiers mods , Comment docComment ) { int pos = token . pos ; if ( mods == null && token . kind == SEMI ) { nextToken ( ) ; return toP ( F . at ( pos ) . Skip ( ) ) ; } else { return classOrInterfaceOrEnumDeclaration ( modifiersOpt ( mods ) , docComment ) ; } }
TypeDeclaration = ClassOrInterfaceOrEnumDeclaration | ;
947
protected JCExpression checkExprStat ( JCExpression t ) { if ( ! TreeInfo . isExpressionStatement ( t ) ) { JCExpression ret = F . at ( t . pos ) . Erroneous ( List . < JCTree > of ( t ) ) ; error ( ret , "not.stmt" ) ; return ret ; } else { return t ; } }
Check that given tree is a legal expression statement .
948
static int prec ( TokenKind token ) { JCTree . Tag oc = optag ( token ) ; return ( oc != NO_TAG ) ? TreeInfo . opPrec ( oc ) : - 1 ; }
Return precedence of operator represented by token - 1 if token is not a binary operator .
949
static int earlier ( int pos1 , int pos2 ) { if ( pos1 == Position . NOPOS ) return pos2 ; if ( pos2 == Position . NOPOS ) return pos1 ; return ( pos1 < pos2 ? pos1 : pos2 ) ; }
Return the lesser of two positions making allowance for either one being unset .
950
static JCTree . Tag optag ( TokenKind token ) { switch ( token ) { case BARBAR : return OR ; case AMPAMP : return AND ; case BAR : return BITOR ; case BAREQ : return BITOR_ASG ; case CARET : return BITXOR ; case CARETEQ : return BITXOR_ASG ; case AMP : return BITAND ; case AMPEQ : return BITAND_ASG ; case EQEQ : return JCTree . Tag . EQ ; case BANGEQ : return NE ; case LT : return JCTree . Tag . LT ; case GT : return JCTree . Tag . GT ; case LTEQ : return LE ; case GTEQ : return GE ; case LTLT : return SL ; case LTLTEQ : return SL_ASG ; case GTGT : return SR ; case GTGTEQ : return SR_ASG ; case GTGTGT : return USR ; case GTGTGTEQ : return USR_ASG ; case PLUS : return JCTree . Tag . PLUS ; case PLUSEQ : return PLUS_ASG ; case SUB : return MINUS ; case SUBEQ : return MINUS_ASG ; case STAR : return MUL ; case STAREQ : return MUL_ASG ; case SLASH : return DIV ; case SLASHEQ : return DIV_ASG ; case PERCENT : return MOD ; case PERCENTEQ : return MOD_ASG ; case INSTANCEOF : return TYPETEST ; default : return NO_TAG ; } }
Return operation tag of binary operator represented by token No_TAG if token is not a binary operator .
951
static JCTree . Tag unoptag ( TokenKind token ) { switch ( token ) { case PLUS : return POS ; case SUB : return NEG ; case BANG : return NOT ; case TILDE : return COMPL ; case PLUSPLUS : return PREINC ; case SUBSUB : return PREDEC ; default : return NO_TAG ; } }
Return operation tag of unary operator represented by token No_TAG if token is not a binary operator .
952
static TypeTag typetag ( TokenKind token ) { switch ( token ) { case BYTE : return TypeTag . BYTE ; case CHAR : return TypeTag . CHAR ; case SHORT : return TypeTag . SHORT ; case INT : return TypeTag . INT ; case LONG : return TypeTag . LONG ; case FLOAT : return TypeTag . FLOAT ; case DOUBLE : return TypeTag . DOUBLE ; case BOOLEAN : return TypeTag . BOOLEAN ; default : return TypeTag . NONE ; } }
Return type tag of basic type represented by token NONE if token is not a basic type identifier .
953
public static String get ( String key , Object ... args ) { try { String msg = MessageFormat . format ( bundle . getString ( key ) , args ) ; if ( REPLACE_LINESEP ) { msg = msg . replace ( "\n" , System . lineSeparator ( ) ) ; } return msg ; } catch ( MissingResourceException e ) { throw new InternalError ( "Missing message: " + key , e ) ; } }
Gets a message from the resource bundle . If necessary translates \ n the line break string used in the message file to the system - specific line break string .
954
public String getText ( String key ) throws MissingResourceException { initBundles ( ) ; if ( docletBundle . containsKey ( key ) ) return docletBundle . getString ( key ) ; return commonBundle . getString ( key ) ; }
Gets the string for the given key from one of the doclet s resource bundles .
955
public < T > void put ( Key < T > key , Factory < T > fac ) { checkState ( ht ) ; Object old = ht . put ( key , fac ) ; if ( old != null ) throw new AssertionError ( "duplicate context value" ) ; checkState ( ft ) ; ft . put ( key , fac ) ; }
Set the factory for the key in this context .
956
public < T > void put ( Key < T > key , T data ) { if ( data instanceof Factory < ? > ) throw new AssertionError ( "T extends Context.Factory" ) ; checkState ( ht ) ; Object old = ht . put ( key , data ) ; if ( old != null && ! ( old instanceof Factory < ? > ) && old != data && data != null ) throw new AssertionError ( "duplicate context value" ) ; }
Set the value for the key in this context .
957
public int modifierSpecifier ( ) { int modifiers = getModifiers ( ) ; if ( isMethod ( ) && containingClass ( ) . isInterface ( ) ) return modifiers & ~ Modifier . ABSTRACT ; return modifiers ; }
Get the modifier specifier integer .
958
public static DocTrees instance ( ProcessingEnvironment env ) { if ( ! env . getClass ( ) . getName ( ) . equals ( "com.sun.tools.javac.processing.JavacProcessingEnvironment" ) ) throw new IllegalArgumentException ( ) ; return ( DocTrees ) getJavacTrees ( ProcessingEnvironment . class , env ) ; }
Returns a DocTrees object for a given ProcessingEnvironment .
959
Stream < Archive > getDependences ( Archive source ) { return source . getDependencies ( ) . map ( this :: locationToArchive ) . filter ( a -> a != source ) ; }
Returns the modules of all dependencies found
960
Archive locationToArchive ( Location location ) { return parsedClasses . containsKey ( location ) ? parsedClasses . get ( location ) : configuration . findClass ( location ) . orElse ( NOT_FOUND ) ; }
Returns the location to archive map ; or NOT_FOUND .
961
Map < Archive , Set < Archive > > dependences ( ) { Map < Archive , Set < Archive > > map = new HashMap < > ( ) ; parsedArchives . values ( ) . stream ( ) . flatMap ( Deque :: stream ) . filter ( a -> ! a . isEmpty ( ) ) . forEach ( source -> { Set < Archive > deps = getDependences ( source ) . collect ( toSet ( ) ) ; if ( ! deps . isEmpty ( ) ) { map . put ( source , deps ) ; } } ) ; return map ; }
Returns a map from an archive to its required archives
962
public Set < Location > parse ( Stream < ? extends Archive > archiveStream ) { archiveStream . forEach ( archive -> parse ( archive , CLASS_FINDER ) ) ; return waitForTasksCompleted ( ) ; }
Parses all class files from the given archive stream and returns all target locations .
963
public Set < Location > parseExportedAPIs ( Stream < ? extends Archive > archiveStream ) { archiveStream . forEach ( archive -> parse ( archive , API_FINDER ) ) ; return waitForTasksCompleted ( ) ; }
Parses the exported API class files from the given archive stream and returns all target locations .
964
public Set < Location > parse ( Archive archive , String name ) { try { return parse ( archive , CLASS_FINDER , name ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } }
Parses the named class from the given archive and returns all target locations the named class references .
965
public Set < Location > parseExportedAPIs ( Archive archive , String name ) { try { return parse ( archive , API_FINDER , name ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } }
Parses the exported API of the named class from the given archive and returns all target locations the named class references .
966
public static TransTypes instance ( Context context ) { TransTypes instance = context . get ( transTypesKey ) ; if ( instance == null ) instance = new TransTypes ( context ) ; return instance ; }
Get the instance for this context .
967
JCExpression cast ( JCExpression tree , Type target ) { int oldpos = make . pos ; make . at ( tree . pos ) ; if ( ! types . isSameType ( tree . type , target ) ) { if ( ! resolve . isAccessible ( env , target . tsym ) ) resolve . logAccessErrorInternal ( env , tree , target ) ; tree = make . TypeCast ( make . Type ( target ) , tree ) . setType ( target ) ; } make . pos = oldpos ; return tree ; }
Construct an attributed tree for a cast of expression to target type unless it already has precisely that type .
968
public JCExpression coerce ( Env < AttrContext > env , JCExpression tree , Type target ) { Env < AttrContext > prevEnv = this . env ; try { this . env = env ; return coerce ( tree , target ) ; } finally { this . env = prevEnv ; } }
Construct an attributed tree to coerce an expression to some erased target type unless the expression is already assignable to that type . If target type is a constant type use its base type instead .
969
< T extends JCTree > List < T > translateArgs ( List < T > _args , List < Type > parameters , Type varargsElement ) { if ( parameters . isEmpty ( ) ) return _args ; List < T > args = _args ; while ( parameters . tail . nonEmpty ( ) ) { args . head = translate ( args . head , parameters . head ) ; args = args . tail ; parameters = parameters . tail ; } Type parameter = parameters . head ; Assert . check ( varargsElement != null || args . length ( ) == 1 ) ; if ( varargsElement != null ) { while ( args . nonEmpty ( ) ) { args . head = translate ( args . head , varargsElement ) ; args = args . tail ; } } else { args . head = translate ( args . head , parameter ) ; } return _args ; }
Translate method argument list casting each argument to its corresponding type in a list of target types .
970
private boolean isSameMemberWhenErased ( Type type , MethodSymbol method , Type erasure ) { return types . isSameType ( erasure ( types . memberType ( type , method ) ) , erasure ) ; }
Lookup the method as a member of the type . Compare the erasures .
971
private void printError ( String prefix , String msg ) { if ( nerrors < MaxErrors ) { PrintWriter errWriter = getWriter ( WriterKind . ERROR ) ; printRawLines ( errWriter , prefix + ": " + getText ( "javadoc.error" ) + " - " + msg ) ; errWriter . flush ( ) ; prompt ( ) ; nerrors ++ ; } }
print the error and increment count
972
private void printWarning ( String prefix , String msg ) { if ( nwarnings < MaxWarnings ) { PrintWriter warnWriter = getWriter ( WriterKind . WARNING ) ; printRawLines ( warnWriter , prefix + ": " + getText ( "javadoc.warning" ) + " - " + msg ) ; warnWriter . flush ( ) ; nwarnings ++ ; } }
print the warning and increment count
973
WriteableScope enterScope ( Env < AttrContext > env ) { return ( env . tree . hasTag ( JCTree . Tag . CLASSDEF ) ) ? ( ( JCClassDecl ) env . tree ) . sym . members_field : env . info . scope ; }
The scope in which a member definition in environment env is to be entered This is usually the environment s scope except for class environments where the local scope is for type variables and the this and super symbol only and members go into the class member scope .
974
public Env < AttrContext > moduleEnv ( JCModuleDecl tree , Env < AttrContext > env ) { Assert . checkNonNull ( tree . sym ) ; Env < AttrContext > localEnv = env . dup ( tree , env . info . dup ( WriteableScope . create ( tree . sym ) ) ) ; localEnv . enclClass = predefClassDef ; localEnv . outer = env ; localEnv . info . isSelfCall = false ; localEnv . info . lint = null ; return localEnv ; }
Create a fresh environment for modules .
975
private static boolean classNameMatchesFileName ( ClassSymbol c , Env < AttrContext > env ) { return env . toplevel . sourcefile . isNameCompatible ( c . name . toString ( ) , JavaFileObject . Kind . SOURCE ) ; }
Does class have the same name as the file it appears in?
976
protected void duplicateClass ( DiagnosticPosition pos , ClassSymbol c ) { log . error ( pos , "duplicate.class" , c . fullname ) ; }
Complain about a duplicate class .
977
public void visitTypeParameter ( JCTypeParameter tree ) { TypeVar a = ( tree . type != null ) ? ( TypeVar ) tree . type : new TypeVar ( tree . name , env . info . scope . owner , syms . botType ) ; tree . type = a ; if ( chk . checkUnique ( tree . pos ( ) , a . tsym , env . info . scope ) ) { env . info . scope . enter ( a . tsym ) ; } result = a ; }
Class enter visitor method for type parameters . Enter a symbol for type parameter in local scope after checking that it is unique .
978
protected void addInheritedSummaryLink ( TypeElement te , Element member , Content linksTree ) { linksTree . addContent ( writer . getDocLink ( MEMBER , te , member , name ( member ) , false ) ) ; }
Add the inherited summary link for the member .
979
public void lock ( ) throws IOException , InterruptedException { if ( channel == null ) { initializeChannel ( ) ; } lockSem . acquire ( ) ; lock = channel . lock ( ) ; }
Lock the port file .
980
public void getValues ( ) { containsPortInfo = false ; if ( lock == null ) { return ; } try { if ( rwfile . length ( ) > 0 ) { rwfile . seek ( 0 ) ; int nr = rwfile . readInt ( ) ; serverPort = rwfile . readInt ( ) ; serverCookie = rwfile . readLong ( ) ; if ( nr == magicNr ) { containsPortInfo = true ; } else { containsPortInfo = false ; } } } catch ( IOException e ) { containsPortInfo = false ; } }
Read the values from the port file in the file system . Expects the port file to be locked .
981
public void setValues ( int port , long cookie ) throws IOException { Assert . check ( lock != null ) ; rwfile . seek ( 0 ) ; rwfile . writeInt ( magicNr ) ; rwfile . writeInt ( port ) ; rwfile . writeLong ( cookie ) ; myServerPort = port ; myServerCookie = cookie ; }
Store the values into the locked port file .
982
public void delete ( ) throws IOException , InterruptedException { rwfile . close ( ) ; file . delete ( ) ; for ( int i = 0 ; i < 10 && file . exists ( ) ; i ++ ) { Thread . sleep ( 1000 ) ; } if ( file . exists ( ) ) { throw new IOException ( "Failed to delete file." ) ; } }
Delete the port file .
983
public boolean markedForStop ( ) throws IOException { if ( stopFile . exists ( ) ) { try { stopFile . delete ( ) ; } catch ( Exception e ) { } return true ; } return false ; }
Is a stop file there?
984
public void unlock ( ) throws IOException { if ( lock == null ) { return ; } lock . release ( ) ; lock = null ; lockSem . release ( ) ; }
Unlock the port file .
985
public void waitForValidValues ( ) throws IOException , InterruptedException { final int MS_BETWEEN_ATTEMPTS = 500 ; long startTime = System . currentTimeMillis ( ) ; long timeout = startTime + getServerStartupTimeoutSeconds ( ) * 1000 ; while ( true ) { Log . debug ( "Looking for valid port file values..." ) ; if ( exists ( ) ) { lock ( ) ; getValues ( ) ; unlock ( ) ; } if ( containsPortInfo ) { Log . debug ( "Valid port file values found after " + ( System . currentTimeMillis ( ) - startTime ) + " ms" ) ; return ; } if ( System . currentTimeMillis ( ) > timeout ) { break ; } Thread . sleep ( MS_BETWEEN_ATTEMPTS ) ; } throw new IOException ( "No port file values materialized. Giving up after " + ( System . currentTimeMillis ( ) - startTime ) + " ms" ) ; }
Wait for the port file to contain values that look valid .
986
public static int compile ( String [ ] args ) { com . sun . tools . javac . main . Main compiler = new com . sun . tools . javac . main . Main ( "javac" ) ; return compiler . compile ( args ) . exitCode ; }
Programmatic interface to the Java Programming Language compiler javac .
987
public String getDocletSpecificBuildDate ( ) { if ( versionRB == null ) { try { versionRB = ResourceBundle . getBundle ( versionRBName ) ; } catch ( MissingResourceException e ) { return BUILD_DATE ; } } try { return versionRB . getString ( "release" ) ; } catch ( MissingResourceException e ) { return BUILD_DATE ; } }
Return the build date for the doclet .
988
public static Output search ( Configuration configuration , Input input ) { Output output = new Output ( ) ; Utils utils = configuration . utils ; if ( input . isInheritDocTag ) { } else if ( input . taglet == null ) { output . inlineTags = input . isFirstSentence ? utils . getFirstSentenceTrees ( input . element ) : utils . getFullBody ( input . element ) ; output . holder = input . element ; } else { input . taglet . inherit ( input , output ) ; } if ( output . inlineTags != null && ! output . inlineTags . isEmpty ( ) ) { return output ; } output . isValidInheritDocTag = false ; Input inheritedSearchInput = input . copy ( configuration . utils ) ; inheritedSearchInput . isInheritDocTag = false ; if ( utils . isMethod ( input . element ) ) { ExecutableElement overriddenMethod = utils . overriddenMethod ( ( ExecutableElement ) input . element ) ; if ( overriddenMethod != null ) { inheritedSearchInput . element = overriddenMethod ; output = search ( configuration , inheritedSearchInput ) ; output . isValidInheritDocTag = true ; if ( ! output . inlineTags . isEmpty ( ) ) { return output ; } } ImplementedMethods implMethods = new ImplementedMethods ( ( ExecutableElement ) input . element , configuration ) ; List < ExecutableElement > implementedMethods = implMethods . build ( ) ; for ( ExecutableElement implementedMethod : implementedMethods ) { inheritedSearchInput . element = implementedMethod ; output = search ( configuration , inheritedSearchInput ) ; output . isValidInheritDocTag = true ; if ( ! output . inlineTags . isEmpty ( ) ) { return output ; } } } else if ( utils . isTypeElement ( input . element ) ) { TypeMirror t = ( ( TypeElement ) input . element ) . getSuperclass ( ) ; Element superclass = utils . asTypeElement ( t ) ; if ( superclass != null ) { inheritedSearchInput . element = superclass ; output = search ( configuration , inheritedSearchInput ) ; output . isValidInheritDocTag = true ; if ( ! output . inlineTags . isEmpty ( ) ) { return output ; } } } return output ; }
Search for the requested comments in the given element . If it does not have comments return documentation from the overridden element if possible . If the overridden element does not exist or does not have documentation to inherit search for documentation to inherit from implemented methods .
989
public Iterator < Tree > iterator ( ) { return new Iterator < Tree > ( ) { public boolean hasNext ( ) { return next != null ; } public Tree next ( ) { Tree t = next . leaf ; next = next . parent ; return t ; } public void remove ( ) { throw new UnsupportedOperationException ( ) ; } private TreePath next = TreePath . this ; } ; }
Iterates from leaves to root .
990
public ClassDoc [ ] exceptions ( ) { ListBuffer < ClassDocImpl > ret = new ListBuffer < > ( ) ; for ( ClassDocImpl c : getClasses ( true ) ) { if ( c . isException ( ) ) { ret . append ( c ) ; } } return ret . toArray ( new ClassDocImpl [ ret . length ( ) ] ) ; }
Get Exception classes in this package .
991
public ClassDoc [ ] errors ( ) { ListBuffer < ClassDocImpl > ret = new ListBuffer < > ( ) ; for ( ClassDocImpl c : getClasses ( true ) ) { if ( c . isError ( ) ) { ret . append ( c ) ; } } return ret . toArray ( new ClassDocImpl [ ret . length ( ) ] ) ; }
Get Error classes in this package .
992
public AnnotationTypeDoc [ ] annotationTypes ( ) { ListBuffer < AnnotationTypeDocImpl > ret = new ListBuffer < > ( ) ; for ( ClassDocImpl c : getClasses ( true ) ) { if ( c . isAnnotationType ( ) ) { ret . append ( ( AnnotationTypeDocImpl ) c ) ; } } return ret . toArray ( new AnnotationTypeDocImpl [ ret . length ( ) ] ) ; }
Get included annotation types in this package .
993
public String qualifiedName ( ) { if ( qualifiedName == null ) { Name fullname = sym . getQualifiedName ( ) ; qualifiedName = fullname . isEmpty ( ) ? "" : fullname . toString ( ) ; } return qualifiedName ; }
Get package name .
994
public void setDocPath ( FileObject path ) { setDocPath = true ; if ( path == null ) return ; if ( ! path . equals ( docPath ) ) { docPath = path ; checkDoc ( ) ; } }
set doc path for an unzipped directory
995
private void checkDoc ( ) { if ( foundDoc ) { if ( ! checkDocWarningEmitted ) { env . warning ( null , "javadoc.Multiple_package_comments" , name ( ) ) ; checkDocWarningEmitted = true ; } } else { foundDoc = true ; } }
Invoked when a source of package doc comments is located . Emits a diagnostic if this is the second one .
996
void error ( String key , Object ... args ) { if ( apiMode ) { String msg = log . localize ( PrefixKind . JAVAC , key , args ) ; throw new PropagatedException ( new IllegalStateException ( msg ) ) ; } warning ( key , args ) ; log . printLines ( PrefixKind . JAVAC , "msg.usage" , ownName ) ; }
Report a usage error .
997
public Result compile ( String [ ] args ) { Context context = new Context ( ) ; JavacFileManager . preRegister ( context ) ; Result result = compile ( args , context ) ; if ( fileManager instanceof JavacFileManager ) { try { ( ( JavacFileManager ) fileManager ) . close ( ) ; } catch ( IOException ex ) { bugMessage ( ex ) ; } } return result ; }
Programmatic interface for main function .
998
void bugMessage ( Throwable ex ) { log . printLines ( PrefixKind . JAVAC , "msg.bug" , JavaCompiler . version ( ) ) ; ex . printStackTrace ( log . getWriter ( WriterKind . NOTICE ) ) ; }
Print a message reporting an internal error .
999
void feMessage ( Throwable ex , Options options ) { log . printRawLines ( ex . getMessage ( ) ) ; if ( ex . getCause ( ) != null && options . isSet ( "dev" ) ) { ex . getCause ( ) . printStackTrace ( log . getWriter ( WriterKind . NOTICE ) ) ; } }
Print a message reporting a fatal error .