idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
200
public void addSerialUIDInfo ( String header , String serialUID , Content serialUidTree ) { Content headerContent = new StringContent ( header ) ; serialUidTree . addContent ( HtmlTree . DT ( headerContent ) ) ; Content serialContent = new StringContent ( serialUID ) ; serialUidTree . addContent ( HtmlTree . DD ( serialContent ) ) ; }
Adds the serial UID info .
201
public static void main ( String ... args ) { getElements ( ) . printElements ( new java . io . PrintWriter ( System . out ) , createMirror ( CoreReflectionFactory . class ) ) ; }
Main method ; prints out a representation of this class .
202
public JavaShellToolBuilder persistence ( Map < String , String > prefsMap ) { this . prefs = new MapStorage ( prefsMap ) ; return this ; }
Set the storage mechanism for persistent information which includes input history and retained settings . Default if not set is the tool s standard persistence mechanism .
203
public JShellTool rawTool ( ) { if ( prefs == null ) { prefs = new PreferencesStorage ( Preferences . userRoot ( ) . node ( PREFERENCES_NODE ) ) ; } if ( vars == null ) { vars = System . getenv ( ) ; } JShellTool sh = new JShellTool ( cmdIn , cmdOut , cmdErr , console , userIn , userOut , userErr , prefs , vars , locale ) ; sh . testPrompt = capturePrompt ; return sh ; }
Create a tool instance for testing . Not in JavaShellToolBuilder .
204
public static void generate ( ConfigurationImpl configuration , ModuleElement mdle ) throws DocFileIOException { DocPath filename = DocPaths . moduleFrame ( mdle ) ; ModulePackageIndexFrameWriter modpackgen = new ModulePackageIndexFrameWriter ( configuration , filename ) ; modpackgen . buildModulePackagesIndexFile ( "doclet.Window_Overview" , false , mdle ) ; }
Generate the module package index file .
205
protected void addAllModulesLink ( Content ul ) { Content linkContent = getHyperLink ( DocPaths . MODULE_OVERVIEW_FRAME , contents . allModulesLabel , "" , "packageListFrame" ) ; Content li = HtmlTree . LI ( linkContent ) ; ul . addContent ( li ) ; }
Adds All Modules link for the top of the left - hand frame page to the documentation tree .
206
public static < D , N extends TarjanNode < D , N > > List < ? extends List < ? extends N > > tarjan ( Iterable < ? extends N > nodes ) { Tarjan < D , N > tarjan = new Tarjan < > ( ) ; return tarjan . findSCC ( nodes ) ; }
Tarjan s algorithm to determine strongly connected components of a directed graph in linear time . Works on TarjanNode .
207
public void appendByte ( int b ) { elems = ArrayUtils . ensureCapacity ( elems , length ) ; elems [ length ++ ] = ( byte ) b ; }
Append byte to this buffer .
208
public void appendBytes ( byte [ ] bs , int start , int len ) { elems = ArrayUtils . ensureCapacity ( elems , length + len ) ; System . arraycopy ( bs , start , elems , length , len ) ; length += len ; }
Append len bytes from byte array starting at given start offset .
209
public void appendChar ( int x ) { elems = ArrayUtils . ensureCapacity ( elems , length + 1 ) ; elems [ length ] = ( byte ) ( ( x >> 8 ) & 0xFF ) ; elems [ length + 1 ] = ( byte ) ( ( x ) & 0xFF ) ; length = length + 2 ; }
Append a character as a two byte number .
210
public void appendInt ( int x ) { elems = ArrayUtils . ensureCapacity ( elems , length + 3 ) ; elems [ length ] = ( byte ) ( ( x >> 24 ) & 0xFF ) ; elems [ length + 1 ] = ( byte ) ( ( x >> 16 ) & 0xFF ) ; elems [ length + 2 ] = ( byte ) ( ( x >> 8 ) & 0xFF ) ; elems [ length + 3 ] = ( byte ) ( ( x ) & 0xFF ) ; length = length + 4 ; }
Append an integer as a four byte number .
211
public void appendLong ( long x ) { ByteArrayOutputStream buffer = new ByteArrayOutputStream ( 8 ) ; DataOutputStream bufout = new DataOutputStream ( buffer ) ; try { bufout . writeLong ( x ) ; appendBytes ( buffer . toByteArray ( ) , 0 , 8 ) ; } catch ( IOException e ) { throw new AssertionError ( "write" ) ; } }
Append a long as an eight byte number .
212
public void appendFloat ( float x ) { ByteArrayOutputStream buffer = new ByteArrayOutputStream ( 4 ) ; DataOutputStream bufout = new DataOutputStream ( buffer ) ; try { bufout . writeFloat ( x ) ; appendBytes ( buffer . toByteArray ( ) , 0 , 4 ) ; } catch ( IOException e ) { throw new AssertionError ( "write" ) ; } }
Append a float as a four byte number .
213
public void appendDouble ( double x ) { ByteArrayOutputStream buffer = new ByteArrayOutputStream ( 8 ) ; DataOutputStream bufout = new DataOutputStream ( buffer ) ; try { bufout . writeDouble ( x ) ; appendBytes ( buffer . toByteArray ( ) , 0 , 8 ) ; } catch ( IOException e ) { throw new AssertionError ( "write" ) ; } }
Append a double as a eight byte number .
214
public void appendName ( Name name ) { appendBytes ( name . getByteArray ( ) , name . getByteOffset ( ) , name . getByteLength ( ) ) ; }
Append a name .
215
public void visitClassDef ( JCClassDecl tree ) { classdefs . put ( tree . sym , tree ) ; super . visitClassDef ( tree ) ; }
All encountered class defs are entered into classdefs table .
216
private void addFreeVar ( VarSymbol v ) { for ( List < VarSymbol > l = fvs ; l . nonEmpty ( ) ; l = l . tail ) if ( l . head == v ) return ; fvs = fvs . prepend ( v ) ; }
Add free variable to fvs list unless it is already there .
217
public void visitSelect ( JCFieldAccess tree ) { if ( ( tree . name == names . _this || tree . name == names . _super ) && tree . selected . type . tsym != clazz && outerThisStack . head != null ) visitSymbol ( outerThisStack . head ) ; super . visitSelect ( tree ) ; }
If tree refers to a qualified this or super expression for anything but the current class add the outer this stack as a free variable .
218
void translate ( ) { make . at ( pos . getStartPosition ( ) ) ; JCClassDecl owner = classDef ( ( ClassSymbol ) mapVar . owner ) ; MethodSymbol valuesMethod = lookupMethod ( pos , names . values , forEnum . type , List . nil ( ) ) ; JCExpression size = make . Select ( make . App ( make . QualIdent ( valuesMethod ) ) , syms . lengthVar ) ; JCExpression mapVarInit = make . NewArray ( make . Type ( syms . intType ) , List . of ( size ) , null ) . setType ( new ArrayType ( syms . intType , syms . arrayClass ) ) ; ListBuffer < JCStatement > stmts = new ListBuffer < > ( ) ; Symbol ordinalMethod = lookupMethod ( pos , names . ordinal , forEnum . type , List . nil ( ) ) ; List < JCCatch > catcher = List . < JCCatch > nil ( ) . prepend ( make . Catch ( make . VarDef ( new VarSymbol ( PARAMETER , names . ex , syms . noSuchFieldErrorType , syms . noSymbol ) , null ) , make . Block ( 0 , List . nil ( ) ) ) ) ; for ( Map . Entry < VarSymbol , Integer > e : values . entrySet ( ) ) { VarSymbol enumerator = e . getKey ( ) ; Integer mappedValue = e . getValue ( ) ; JCExpression assign = make . Assign ( make . Indexed ( mapVar , make . App ( make . Select ( make . QualIdent ( enumerator ) , ordinalMethod ) ) ) , make . Literal ( mappedValue ) ) . setType ( syms . intType ) ; JCStatement exec = make . Exec ( assign ) ; JCStatement _try = make . Try ( make . Block ( 0 , List . of ( exec ) ) , catcher , null ) ; stmts . append ( _try ) ; } owner . defs = owner . defs . prepend ( make . Block ( STATIC , stmts . toList ( ) ) ) . prepend ( make . VarDef ( mapVar , mapVarInit ) ) ; }
generate the field initializer for the map
219
public Reference parse ( String sig ) throws ParseException { JCTree qualExpr ; Name member ; List < JCTree > paramTypes ; Log . DeferredDiagnosticHandler deferredDiagnosticHandler = new Log . DeferredDiagnosticHandler ( fac . log ) ; try { int hash = sig . indexOf ( "#" ) ; int lparen = sig . indexOf ( "(" , hash + 1 ) ; if ( hash == - 1 ) { if ( lparen == - 1 ) { qualExpr = parseType ( sig ) ; member = null ; } else { qualExpr = null ; member = parseMember ( sig . substring ( 0 , lparen ) ) ; } } else { qualExpr = ( hash == 0 ) ? null : parseType ( sig . substring ( 0 , hash ) ) ; if ( lparen == - 1 ) member = parseMember ( sig . substring ( hash + 1 ) ) ; else member = parseMember ( sig . substring ( hash + 1 , lparen ) ) ; } if ( lparen < 0 ) { paramTypes = null ; } else { int rparen = sig . indexOf ( ")" , lparen ) ; if ( rparen != sig . length ( ) - 1 ) throw new ParseException ( "dc.ref.bad.parens" ) ; paramTypes = parseParams ( sig . substring ( lparen + 1 , rparen ) ) ; } if ( ! deferredDiagnosticHandler . getDiagnostics ( ) . isEmpty ( ) ) throw new ParseException ( "dc.ref.syntax.error" ) ; } finally { fac . log . popDiagnosticHandler ( deferredDiagnosticHandler ) ; } return new Reference ( qualExpr , member , paramTypes ) ; }
Parse a reference to an API element as may be found in doc comment .
220
private static < D extends Directive > List < D > listFilter ( Iterable < ? extends Directive > directives , DirectiveKind directiveKind , Class < D > clazz ) { List < D > list = new ArrayList < > ( ) ; for ( Directive d : directives ) { if ( d . getKind ( ) == directiveKind ) list . add ( clazz . cast ( d ) ) ; } return list ; }
Assumes directiveKind and D are sensible .
221
protected void addLinkToMainTree ( Content div ) { Content span = HtmlTree . SPAN ( HtmlStyle . packageHierarchyLabel , getResource ( "doclet.Package_Hierarchies" ) ) ; div . addContent ( span ) ; HtmlTree ul = new HtmlTree ( HtmlTag . UL ) ; ul . addStyle ( HtmlStyle . horizontal ) ; ul . addContent ( getNavLinkMainTree ( configuration . getText ( "doclet.All_Packages" ) ) ) ; div . addContent ( ul ) ; }
Add a link to the tree for all the packages .
222
protected Content getNavLinkPackage ( ) { Content linkContent = getHyperLink ( DocPaths . PACKAGE_SUMMARY , packageLabel ) ; Content li = HtmlTree . LI ( linkContent ) ; return li ; }
Get link to the package summary page for the package of this tree .
223
public static DocFile createFileForDirectory ( Configuration configuration , String file ) { return DocFileFactory . getFactory ( configuration ) . createFileForDirectory ( file ) ; }
Create a DocFile for a directory .
224
public static DocFile createFileForInput ( Configuration configuration , String file ) { return DocFileFactory . getFactory ( configuration ) . createFileForInput ( file ) ; }
Create a DocFile for a file that will be opened for reading .
225
public static DocFile createFileForOutput ( Configuration configuration , DocPath path ) { return DocFileFactory . getFactory ( configuration ) . createFileForOutput ( path ) ; }
Create a DocFile for a file that will be opened for writing .
226
public static Iterable < DocFile > list ( Configuration configuration , Location location , DocPath path ) { return DocFileFactory . getFactory ( configuration ) . list ( location , path ) ; }
List the directories and files found in subdirectories along the elements of the given location .
227
void addInterfaces ( Deque < String > intfs , ClassFile cf ) throws ConstantPoolException { int count = cf . interfaces . length ; for ( int i = 0 ; i < count ; i ++ ) { intfs . addLast ( cf . getInterfaceName ( i ) ) ; } }
Adds all interfaces from this class to the deque of interfaces .
228
String resolveMember ( ClassFile cf , String startClassName , String findName , String findDesc , boolean resolveMethod , boolean checkStartClass ) throws ConstantPoolException { ClassFile startClass ; if ( cf . getName ( ) . equals ( startClassName ) ) { startClass = cf ; } else { startClass = finder . find ( startClassName ) ; if ( startClass == null ) { errorNoClass ( startClassName ) ; return startClassName ; } } ClassFile curClass = startClass ; Deque < String > intfs = new ArrayDeque < > ( ) ; while ( true ) { if ( ( checkStartClass || curClass != startClass ) && isMemberPresent ( curClass , findName , findDesc , resolveMethod ) ) { break ; } if ( curClass . super_class == 0 ) { curClass = null ; break ; } String superName = curClass . getSuperclassName ( ) ; curClass = finder . find ( superName ) ; if ( curClass == null ) { errorNoClass ( superName ) ; break ; } addInterfaces ( intfs , curClass ) ; } if ( curClass == null ) { addInterfaces ( intfs , startClass ) ; while ( intfs . size ( ) > 0 ) { String intf = intfs . removeFirst ( ) ; curClass = finder . find ( intf ) ; if ( curClass == null ) { errorNoClass ( intf ) ; break ; } if ( isMemberPresent ( curClass , findName , findDesc , resolveMethod ) ) { break ; } addInterfaces ( intfs , curClass ) ; } } if ( curClass == null ) { if ( checkStartClass ) { errorNoMethod ( startClassName , findName , findDesc ) ; return startClassName ; } else { return null ; } } else { String foundClassName = curClass . getName ( ) ; return foundClassName ; } }
Resolves a member by searching this class and all its superclasses and implemented interfaces .
229
void checkSuper ( ClassFile cf ) throws ConstantPoolException { String sname = cf . getSuperclassName ( ) ; DeprData dd = db . getTypeDeprecated ( sname ) ; if ( dd != null ) { printType ( "scan.out.extends" , cf , sname , dd . isForRemoval ( ) ) ; } }
Checks the superclass of this class .
230
void checkInterfaces ( ClassFile cf ) throws ConstantPoolException { int ni = cf . interfaces . length ; for ( int i = 0 ; i < ni ; i ++ ) { String iname = cf . getInterfaceName ( i ) ; DeprData dd = db . getTypeDeprecated ( iname ) ; if ( dd != null ) { printType ( "scan.out.implements" , cf , iname , dd . isForRemoval ( ) ) ; } } }
Checks the interfaces of this class .
231
void checkClasses ( ClassFile cf , CPEntries entries ) throws ConstantPoolException { for ( ConstantPool . CONSTANT_Class_info ci : entries . classes ) { String name = nameFromRefType ( ci . getName ( ) ) ; if ( name != null ) { DeprData dd = db . getTypeDeprecated ( name ) ; if ( dd != null ) { printType ( "scan.out.usesclass" , cf , name , dd . isForRemoval ( ) ) ; } } } }
Checks Class_info entries in the constant pool .
232
void checkMethodRef ( ClassFile cf , String clname , CONSTANT_NameAndType_info nti , String msgKey ) throws ConstantPoolException { String name = nti . getName ( ) ; String type = nti . getType ( ) ; clname = nameFromRefType ( clname ) ; if ( clname != null ) { clname = resolveMember ( cf , clname , name , type , true , true ) ; DeprData dd = db . getMethodDeprecated ( clname , name , type ) ; if ( dd != null ) { printMethod ( msgKey , cf , clname , name , type , dd . isForRemoval ( ) ) ; } } }
Checks methods referred to from the constant pool .
233
void checkFieldRef ( ClassFile cf , ConstantPool . CONSTANT_Fieldref_info fri ) throws ConstantPoolException { String clname = nameFromRefType ( fri . getClassName ( ) ) ; CONSTANT_NameAndType_info nti = fri . getNameAndTypeInfo ( ) ; String name = nti . getName ( ) ; String type = nti . getType ( ) ; if ( clname != null ) { clname = resolveMember ( cf , clname , name , type , false , true ) ; DeprData dd = db . getFieldDeprecated ( clname , name ) ; if ( dd != null ) { printField ( "scan.out.usesfield" , cf , clname , name , dd . isForRemoval ( ) ) ; } } }
Checks fields referred to from the constant pool .
234
void checkFields ( ClassFile cf ) throws ConstantPoolException { for ( Field f : cf . fields ) { String type = nameFromDescType ( cf . constant_pool . getUTF8Value ( f . descriptor . index ) ) ; if ( type != null ) { DeprData dd = db . getTypeDeprecated ( type ) ; if ( dd != null ) { printHasField ( cf , f . getName ( cf . constant_pool ) , type , dd . isForRemoval ( ) ) ; } } } }
Checks the fields declared in this class .
235
void checkMethods ( ClassFile cf ) throws ConstantPoolException { for ( Method m : cf . methods ) { String mname = m . getName ( cf . constant_pool ) ; String desc = cf . constant_pool . getUTF8Value ( m . descriptor . index ) ; MethodSig sig = MethodSig . fromDesc ( desc ) ; DeprData dd ; for ( String parm : sig . getParameters ( ) ) { parm = nameFromDescType ( parm ) ; if ( parm != null ) { dd = db . getTypeDeprecated ( parm ) ; if ( dd != null ) { printHasMethodParmType ( cf , mname , parm , dd . isForRemoval ( ) ) ; } } } String ret = nameFromDescType ( sig . getReturnType ( ) ) ; if ( ret != null ) { dd = db . getTypeDeprecated ( ret ) ; if ( dd != null ) { printHasMethodRetType ( cf , mname , ret , dd . isForRemoval ( ) ) ; } } String overridden = resolveMember ( cf , cf . getName ( ) , mname , desc , true , false ) ; if ( overridden != null ) { dd = db . getMethodDeprecated ( overridden , mname , desc ) ; if ( dd != null ) { printHasOverriddenMethod ( cf , overridden , mname , desc , dd . isForRemoval ( ) ) ; } } } }
Checks the methods declared in this class .
236
void processClass ( ClassFile cf ) throws ConstantPoolException { if ( verbose ) { out . println ( Messages . get ( "scan.process.class" , cf . getName ( ) ) ) ; } CPEntries entries = CPEntries . loadFrom ( cf ) ; checkSuper ( cf ) ; checkInterfaces ( cf ) ; checkClasses ( cf , entries ) ; for ( ConstantPool . CONSTANT_Methodref_info mri : entries . methodRefs ) { String clname = mri . getClassName ( ) ; CONSTANT_NameAndType_info nti = mri . getNameAndTypeInfo ( ) ; checkMethodRef ( cf , clname , nti , "scan.out.usesmethod" ) ; } for ( ConstantPool . CONSTANT_InterfaceMethodref_info imri : entries . intfMethodRefs ) { String clname = imri . getClassName ( ) ; CONSTANT_NameAndType_info nti = imri . getNameAndTypeInfo ( ) ; checkMethodRef ( cf , clname , nti , "scan.out.usesintfmethod" ) ; } for ( ConstantPool . CONSTANT_Fieldref_info fri : entries . fieldRefs ) { checkFieldRef ( cf , fri ) ; } checkFields ( cf ) ; checkMethods ( cf ) ; }
Processes a single class file .
237
public boolean scanJar ( String jarname ) { try ( JarFile jf = new JarFile ( jarname ) ) { out . println ( Messages . get ( "scan.head.jar" , jarname ) ) ; finder . addJar ( jarname ) ; Enumeration < JarEntry > entries = jf . entries ( ) ; while ( entries . hasMoreElements ( ) ) { JarEntry entry = entries . nextElement ( ) ; String name = entry . getName ( ) ; if ( name . endsWith ( ".class" ) && ! name . endsWith ( "package-info.class" ) && ! name . endsWith ( "module-info.class" ) ) { processClass ( ClassFile . read ( jf . getInputStream ( entry ) ) ) ; } } return true ; } catch ( NoSuchFileException nsfe ) { errorNoFile ( jarname ) ; } catch ( IOException | ConstantPoolException ex ) { errorException ( ex ) ; } return false ; }
Scans a jar file for uses of deprecated APIs .
238
public boolean scanDir ( String dirname ) { Path base = Paths . get ( dirname ) ; int baseCount = base . getNameCount ( ) ; finder . addDir ( dirname ) ; try ( Stream < Path > paths = Files . walk ( Paths . get ( dirname ) ) ) { List < Path > classes = paths . filter ( p -> p . getNameCount ( ) > baseCount ) . filter ( path -> path . toString ( ) . endsWith ( ".class" ) ) . filter ( path -> ! path . toString ( ) . endsWith ( "package-info.class" ) ) . filter ( path -> ! path . toString ( ) . endsWith ( "module-info.class" ) ) . collect ( Collectors . toList ( ) ) ; out . println ( Messages . get ( "scan.head.dir" , dirname ) ) ; for ( Path p : classes ) { processClass ( ClassFile . read ( p ) ) ; } return true ; } catch ( IOException | ConstantPoolException ex ) { errorException ( ex ) ; return false ; } }
Scans class files in the named directory hierarchy for uses of deprecated APIs .
239
public boolean processClassName ( String className ) { try { ClassFile cf = finder . find ( className ) ; if ( cf == null ) { errorNoClass ( className ) ; return false ; } else { processClass ( cf ) ; return true ; } } catch ( ConstantPoolException ex ) { errorException ( ex ) ; return false ; } }
Scans the named class for uses of deprecated APIs .
240
public boolean processClassFile ( String fileName ) { Path path = Paths . get ( fileName ) ; try { ClassFile cf = ClassFile . read ( path ) ; processClass ( cf ) ; return true ; } catch ( NoSuchFileException nsfe ) { errorNoFile ( fileName ) ; } catch ( IOException | ConstantPoolException ex ) { errorException ( ex ) ; } return false ; }
Scans the named class file for uses of deprecated APIs .
241
private Collection < TypeElement > subclasses ( TypeElement te ) { Collection < TypeElement > ret = classToSubclass . get ( te ) ; if ( ret == null ) { ret = new TreeSet < > ( utils . makeClassUseComparator ( ) ) ; Set < TypeElement > subs = classtree . subClasses ( te ) ; if ( subs != null ) { ret . addAll ( subs ) ; for ( TypeElement sub : subs ) { ret . addAll ( subclasses ( sub ) ) ; } } addAll ( classToSubclass , te , ret ) ; } return ret ; }
Return all subClasses of a class AND fill - in classToSubclass map .
242
private Collection < TypeElement > subinterfaces ( TypeElement te ) { Collection < TypeElement > ret = classToSubinterface . get ( te ) ; if ( ret == null ) { ret = new TreeSet < > ( utils . makeClassUseComparator ( ) ) ; Set < TypeElement > subs = classtree . subInterfaces ( te ) ; if ( subs != null ) { ret . addAll ( subs ) ; for ( TypeElement sub : subs ) { ret . addAll ( subinterfaces ( sub ) ) ; } } addAll ( classToSubinterface , te , ret ) ; } return ret ; }
Return all subInterfaces of an interface AND fill - in classToSubinterface map .
243
private < T extends Element > void mapTypeParameters ( final Map < TypeElement , List < T > > map , Element element , final T holder ) { SimpleElementVisitor9 < Void , Void > elementVisitor = new SimpleElementVisitor9 < Void , Void > ( ) { private void addParameters ( TypeParameterElement e ) { for ( TypeMirror type : utils . getBounds ( e ) ) { addTypeParameterToMap ( map , type , holder ) ; } } public Void visitType ( TypeElement e , Void p ) { for ( TypeParameterElement param : e . getTypeParameters ( ) ) { addParameters ( param ) ; } return null ; } public Void visitExecutable ( ExecutableElement e , Void p ) { for ( TypeParameterElement param : e . getTypeParameters ( ) ) { addParameters ( param ) ; } return null ; } protected Void defaultAction ( Element e , Void p ) { mapTypeParameters ( map , e . asType ( ) , holder ) ; return null ; } public Void visitTypeParameter ( TypeParameterElement e , Void p ) { addParameters ( e ) ; return null ; } } ; elementVisitor . visit ( element ) ; }
Map the TypeElements to the members that use them as type parameters .
244
private < T extends Element > void mapAnnotations ( final Map < TypeElement , List < T > > map , Element e , final T holder ) { new SimpleElementVisitor9 < Void , Void > ( ) { void addAnnotations ( Element e ) { for ( AnnotationMirror a : e . getAnnotationMirrors ( ) ) { add ( map , ( TypeElement ) a . getAnnotationType ( ) . asElement ( ) , holder ) ; } } public Void visitPackage ( PackageElement e , Void p ) { for ( AnnotationMirror a : e . getAnnotationMirrors ( ) ) { refList ( map , a . getAnnotationType ( ) . asElement ( ) ) . add ( holder ) ; } return null ; } protected Void defaultAction ( Element e , Void p ) { addAnnotations ( e ) ; return null ; } } . visit ( e ) ; }
Map the AnnotationType to the members that use them as type parameters .
245
public MessageInfo getMessageInfo ( ) { if ( messageInfo == null ) { MessageLine l = firstLine . prev ; if ( l != null && l . isInfo ( ) ) messageInfo = new MessageInfo ( l . text ) ; else messageInfo = MessageInfo . dummyInfo ; } return messageInfo ; }
Get the Info object for this message . It may be empty if there if no comment preceding the property specification .
246
public List < MessageLine > getLines ( boolean includeAllPrecedingComments ) { List < MessageLine > lines = new ArrayList < > ( ) ; MessageLine l = firstLine ; if ( includeAllPrecedingComments ) { while ( l . prev != null && l . prev . isEmptyOrComment ( ) ) l = l . prev ; while ( l . text . isEmpty ( ) ) l = l . next ; } else { if ( l . prev != null && l . prev . isInfo ( ) ) l = l . prev ; } for ( ; l != firstLine ; l = l . next ) lines . add ( l ) ; for ( l = firstLine ; l != null && l . hasContinuation ( ) ; l = l . next ) lines . add ( l ) ; lines . add ( l ) ; l = l . next ; if ( l != null && l . text . isEmpty ( ) ) lines . add ( l ) ; return lines ; }
Get all the lines pertaining to this message .
247
public Content getTypeParameterLinks ( LinkInfo linkInfo , boolean isClassLabel ) { Content links = newContent ( ) ; Type [ ] vars ; if ( linkInfo . executableMemberDoc != null ) { vars = linkInfo . executableMemberDoc . typeParameters ( ) ; } else if ( linkInfo . type != null && linkInfo . type . asParameterizedType ( ) != null ) { vars = linkInfo . type . asParameterizedType ( ) . typeArguments ( ) ; } else if ( linkInfo . classDoc != null ) { vars = linkInfo . classDoc . typeParameters ( ) ; } else { return links ; } if ( ( ( linkInfo . includeTypeInClassLinkLabel && isClassLabel ) || ( linkInfo . includeTypeAsSepLink && ! isClassLabel ) ) && vars . length > 0 ) { links . addContent ( "<" ) ; for ( int i = 0 ; i < vars . length ; i ++ ) { if ( i > 0 ) { links . addContent ( "," ) ; } links . addContent ( getTypeParameterLink ( linkInfo , vars [ i ] ) ) ; } links . addContent ( ">" ) ; } return links ; }
Return the links to the type parameters .
248
public ClassDoc fieldTypeDoc ( ) { if ( fieldTypeDoc == null && containingClass != null ) { fieldTypeDoc = containingClass . findClass ( fieldType ) ; } return fieldTypeDoc ; }
Return the ClassDocImpl for field type .
249
public String description ( ) { if ( description . length ( ) == 0 && matchingField != null ) { Comment comment = matchingField . comment ( ) ; if ( comment != null ) { return comment . commentText ( ) ; } } return description ; }
Return the field comment . If there is no serialField comment return javadoc comment of corresponding FieldDocImpl .
250
protected Content getNavLinkHelp ( ) { Content li = HtmlTree . LI ( HtmlStyle . navBarCell1Rev , helpLabel ) ; return li ; }
Get the help label .
251
public static KindName kindName ( Symbol sym ) { switch ( sym . getKind ( ) ) { case PACKAGE : return KindName . PACKAGE ; case ENUM : return KindName . ENUM ; case ANNOTATION_TYPE : case CLASS : return KindName . CLASS ; case INTERFACE : return KindName . INTERFACE ; case TYPE_PARAMETER : return KindName . TYPEVAR ; case ENUM_CONSTANT : case FIELD : case PARAMETER : case LOCAL_VARIABLE : case EXCEPTION_PARAMETER : case RESOURCE_VARIABLE : return KindName . VAR ; case CONSTRUCTOR : return KindName . CONSTRUCTOR ; case METHOD : return KindName . METHOD ; case STATIC_INIT : return KindName . STATIC_INIT ; case INSTANCE_INIT : return KindName . INSTANCE_INIT ; default : throw new AssertionError ( "Unexpected kind: " + sym . getKind ( ) ) ; } }
A KindName representing a given symbol
252
public Content getContentHeader ( ) { HtmlTree div = new HtmlTree ( HtmlTag . DIV ) ; div . addStyle ( HtmlStyle . contentContainer ) ; return div ; }
Get the document content header tree
253
public void addClassContentTree ( Content contentTree , Content classContentTree ) { if ( configuration . allowTag ( HtmlTag . MAIN ) ) { mainTree . addContent ( classContentTree ) ; contentTree . addContent ( mainTree ) ; } else { contentTree . addContent ( classContentTree ) ; } }
Add the class content tree .
254
public void addMemberTree ( Content memberSummaryTree , Content memberTree ) { if ( configuration . allowTag ( HtmlTag . SECTION ) ) { HtmlTree htmlTree = HtmlTree . SECTION ( getMemberTree ( memberTree ) ) ; memberSummaryTree . addContent ( htmlTree ) ; } else { memberSummaryTree . addContent ( getMemberTree ( memberTree ) ) ; } }
Add the member tree .
255
String [ ] divideAtWhite ( ) { String [ ] sa = new String [ 2 ] ; int len = text . length ( ) ; sa [ 0 ] = text ; sa [ 1 ] = "" ; for ( int inx = 0 ; inx < len ; ++ inx ) { char ch = text . charAt ( inx ) ; if ( Character . isWhitespace ( ch ) ) { sa [ 0 ] = text . substring ( 0 , inx ) ; for ( ; inx < len ; ++ inx ) { ch = text . charAt ( inx ) ; if ( ! Character . isWhitespace ( ch ) ) { sa [ 1 ] = text . substring ( inx , len ) ; break ; } } break ; } } return sa ; }
for use by subclasses which have two part tag text .
256
public Tag [ ] firstSentenceTags ( ) { if ( firstSentence == null ) { inlineTags ( ) ; try { docenv ( ) . setSilent ( true ) ; firstSentence = Comment . firstSentenceTags ( holder , text ) ; } finally { docenv ( ) . setSilent ( false ) ; } } return firstSentence ; }
Return array of tags for the first sentence in the doc comment text .
257
public ClassDoc [ ] thrownExceptions ( ) { ListBuffer < ClassDocImpl > l = new ListBuffer < > ( ) ; for ( Type ex : sym . type . getThrownTypes ( ) ) { ex = env . types . erasure ( ex ) ; ClassDocImpl cdi = env . getClassDoc ( ( ClassSymbol ) ex . tsym ) ; if ( cdi != null ) l . append ( cdi ) ; } return l . toArray ( new ClassDocImpl [ l . length ( ) ] ) ; }
Return exceptions this method or constructor throws .
258
public Parameter [ ] parameters ( ) { List < VarSymbol > params = sym . params ( ) ; Parameter result [ ] = new Parameter [ params . length ( ) ] ; int i = 0 ; for ( VarSymbol param : params ) { result [ i ++ ] = new ParameterImpl ( env , param ) ; } return result ; }
Get argument information .
259
public com . sun . javadoc . Type receiverType ( ) { Type recvtype = sym . type . asMethodType ( ) . recvtype ; return ( recvtype != null ) ? TypeMaker . getType ( env , recvtype , false , true ) : null ; }
Get the receiver type of this executable element .
260
public TypeVariable [ ] typeParameters ( ) { if ( env . legacyDoclet ) { return new TypeVariable [ 0 ] ; } TypeVariable res [ ] = new TypeVariable [ sym . type . getTypeArguments ( ) . length ( ) ] ; TypeMaker . getTypes ( env , sym . type . getTypeArguments ( ) , res ) ; return res ; }
Return the formal type parameters of this method or constructor . Return an empty array if there are none .
261
public void buildConstantMembers ( XMLNode node , Content classConstantTree ) { new ConstantFieldBuilder ( currentClass ) . buildMembersSummary ( node , classConstantTree ) ; }
Build the summary of constant members in the class .
262
void traverse ( String [ ] args ) { try { args = CommandLine . parse ( args ) ; } catch ( java . io . IOException e ) { throw new IllegalArgumentException ( "Problem reading @" + e . getMessage ( ) ) ; } ArgumentIterator argIter = new ArgumentIterator ( Arrays . asList ( args ) ) ; nextArg : while ( argIter . hasNext ( ) ) { String arg = argIter . next ( ) ; if ( arg . startsWith ( "-" ) ) { for ( Option opt : Option . values ( ) ) { if ( opt . processCurrent ( argIter , this ) ) continue nextArg ; } javacArg ( arg ) ; for ( com . sun . tools . javac . main . Option javacOpt : com . sun . tools . javac . main . Option . values ( ) ) { if ( javacOpt . matches ( arg ) ) { boolean takesArgument = javacOpt . hasArg ( ) ; boolean separateToken = ! arg . contains ( ":" ) && ! arg . contains ( "=" ) ; if ( takesArgument && separateToken ) javacArg ( argIter . next ( ) ) ; } } } else { sourceRoots ( Arrays . asList ( Paths . get ( arg ) ) ) ; } } }
Traverses an array of arguments and performs the appropriate callbacks .
263
public int begin ( String ... argv ) { boolean ok = begin ( null , argv , Collections . emptySet ( ) ) ; return ok ? 0 : 1 ; }
Main program - external wrapper
264
private void setDocletInvoker ( Class < ? > docletClass , JavaFileManager fileManager , String [ ] argv ) { boolean exportInternalAPI = false ; String docletClassName = null ; String docletPath = null ; for ( int i = 0 ; i < argv . length ; i ++ ) { String arg = argv [ i ] ; if ( arg . equals ( ToolOption . DOCLET . opt ) ) { oneArg ( argv , i ++ ) ; if ( docletClassName != null ) { usageError ( "main.more_than_one_doclet_specified_0_and_1" , docletClassName , argv [ i ] ) ; } docletClassName = argv [ i ] ; } else if ( arg . equals ( ToolOption . DOCLETPATH . opt ) ) { oneArg ( argv , i ++ ) ; if ( docletPath == null ) { docletPath = argv [ i ] ; } else { docletPath += File . pathSeparator + argv [ i ] ; } } else if ( arg . equals ( "-XDaccessInternalAPI" ) ) { exportInternalAPI = true ; } } if ( docletClass != null ) { docletInvoker = new DocletInvoker ( messager , docletClass , apiMode , exportInternalAPI ) ; } else { if ( docletClassName == null ) { docletClassName = defaultDocletClassName ; } docletInvoker = new DocletInvoker ( messager , fileManager , docletClassName , docletPath , docletParentClassLoader , apiMode , exportInternalAPI ) ; } }
Init the doclet invoker . The doclet class may be given explicitly or via the - doclet option in argv . If the doclet class is not given explicitly it will be loaded from the file manager s DOCLET_PATH location if available or via the - doclet path option in argv .
265
private void oneArg ( String [ ] args , int index ) { if ( ( index + 1 ) < args . length ) { setOption ( args [ index ] , args [ index + 1 ] ) ; } else { usageError ( "main.requires_argument" , args [ index ] ) ; } }
Set one arg option . Error and exit if one argument is not provided .
266
private void setOption ( String opt , String argument ) { String [ ] option = { opt , argument } ; options . append ( option ) ; }
indicate an option with one argument was given .
267
private void setOption ( String opt , List < String > arguments ) { String [ ] args = new String [ arguments . length ( ) + 1 ] ; int k = 0 ; args [ k ++ ] = opt ; for ( List < String > i = arguments ; i . nonEmpty ( ) ; i = i . tail ) { args [ k ++ ] = i . head ; } options . append ( args ) ; }
indicate an option with the specified list of arguments was given .
268
public void flush ( ) { if ( annotationsBlocked ( ) ) return ; if ( isFlushing ( ) ) return ; startFlushing ( ) ; try { while ( q . nonEmpty ( ) ) { q . next ( ) . run ( ) ; } while ( typesQ . nonEmpty ( ) ) { typesQ . next ( ) . run ( ) ; } while ( afterTypesQ . nonEmpty ( ) ) { afterTypesQ . next ( ) . run ( ) ; } while ( validateQ . nonEmpty ( ) ) { validateQ . next ( ) . run ( ) ; } } finally { doneFlushing ( ) ; } }
Flush all annotation queues
269
public void annotateLater ( List < JCAnnotation > annotations , Env < AttrContext > localEnv , Symbol s , DiagnosticPosition deferPos ) { if ( annotations . isEmpty ( ) ) { return ; } s . resetAnnotations ( ) ; normal ( ( ) -> { Assert . check ( s . kind == PCK || s . annotationsPendingCompletion ( ) ) ; JavaFileObject prev = log . useSource ( localEnv . toplevel . sourcefile ) ; DiagnosticPosition prevLintPos = deferPos != null ? deferredLintHandler . setPos ( deferPos ) : deferredLintHandler . immediate ( ) ; Lint prevLint = deferPos != null ? null : chk . setLint ( lint ) ; try { if ( s . hasAnnotations ( ) && annotations . nonEmpty ( ) ) log . error ( annotations . head . pos , "already.annotated" , Kinds . kindName ( s ) , s ) ; Assert . checkNonNull ( s , "Symbol argument to actualEnterAnnotations is null" ) ; annotateNow ( s , annotations , localEnv , false , false ) ; } finally { if ( prevLint != null ) chk . setLint ( prevLint ) ; deferredLintHandler . setPos ( prevLintPos ) ; log . useSource ( prev ) ; } } ) ; validate ( ( ) -> { JavaFileObject prev = log . useSource ( localEnv . toplevel . sourcefile ) ; try { chk . validateAnnotations ( annotations , s ) ; } finally { log . useSource ( prev ) ; } } ) ; }
Queue annotations for later attribution and entering . This is probably the method you are looking for .
270
public void annotateDefaultValueLater ( JCExpression defaultValue , Env < AttrContext > localEnv , MethodSymbol m , DiagnosticPosition deferPos ) { normal ( ( ) -> { JavaFileObject prev = log . useSource ( localEnv . toplevel . sourcefile ) ; DiagnosticPosition prevLintPos = deferredLintHandler . setPos ( deferPos ) ; try { enterDefaultValue ( defaultValue , localEnv , m ) ; } finally { deferredLintHandler . setPos ( prevLintPos ) ; log . useSource ( prev ) ; } } ) ; validate ( ( ) -> { JavaFileObject prev = log . useSource ( localEnv . toplevel . sourcefile ) ; try { chk . validateAnnotationTree ( defaultValue ) ; } finally { log . useSource ( prev ) ; } } ) ; }
Queue processing of an attribute default value .
271
private void enterDefaultValue ( JCExpression defaultValue , Env < AttrContext > localEnv , MethodSymbol m ) { m . defaultValue = attributeAnnotationValue ( m . type . getReturnType ( ) , defaultValue , localEnv ) ; }
Enter a default value for an annotation element .
272
private List < Pair < MethodSymbol , Attribute > > attributeAnnotationValues ( JCAnnotation a , Type expected , Env < AttrContext > env ) { Type at = ( a . annotationType . type != null ? a . annotationType . type : attr . attribType ( a . annotationType , env ) ) ; a . type = chk . checkType ( a . annotationType . pos ( ) , at , expected ) ; boolean isError = a . type . isErroneous ( ) ; if ( ! a . type . tsym . isAnnotationType ( ) && ! isError ) { log . error ( a . annotationType . pos ( ) , "not.annotation.type" , a . type . toString ( ) ) ; isError = true ; } List < JCExpression > args = a . args ; boolean elidedValue = false ; if ( args . length ( ) == 1 && ! args . head . hasTag ( ASSIGN ) ) { args . head = make . at ( args . head . pos ) . Assign ( make . Ident ( names . value ) , args . head ) ; elidedValue = true ; } ListBuffer < Pair < MethodSymbol , Attribute > > buf = new ListBuffer < > ( ) ; for ( List < JCExpression > tl = args ; tl . nonEmpty ( ) ; tl = tl . tail ) { Pair < MethodSymbol , Attribute > p = attributeAnnotationNameValuePair ( tl . head , a . type , isError , env , elidedValue ) ; if ( p != null && ! p . fst . type . isErroneous ( ) ) buf . append ( p ) ; } return buf . toList ( ) ; }
Attribute annotation elements creating a list of pairs of the Symbol representing that element and the value of that element as an Attribute .
273
private Attribute attributeAnnotationValue ( Type expectedElementType , JCExpression tree , Env < AttrContext > env ) { try { expectedElementType . tsym . complete ( ) ; } catch ( CompletionFailure e ) { log . error ( tree . pos ( ) , "cant.resolve" , Kinds . kindName ( e . sym ) , e . sym ) ; expectedElementType = syms . errType ; } if ( expectedElementType . hasTag ( ARRAY ) ) { return getAnnotationArrayValue ( expectedElementType , tree , env ) ; } if ( tree . hasTag ( NEWARRAY ) ) { if ( ! expectedElementType . isErroneous ( ) ) log . error ( tree . pos ( ) , "annotation.value.not.allowable.type" ) ; JCNewArray na = ( JCNewArray ) tree ; if ( na . elemtype != null ) { log . error ( na . elemtype . pos ( ) , "new.not.allowed.in.annotation" ) ; } for ( List < JCExpression > l = na . elems ; l . nonEmpty ( ) ; l = l . tail ) { attributeAnnotationValue ( syms . errType , l . head , env ) ; } return new Attribute . Error ( syms . errType ) ; } if ( expectedElementType . tsym . isAnnotationType ( ) ) { if ( tree . hasTag ( ANNOTATION ) ) { return attributeAnnotation ( ( JCAnnotation ) tree , expectedElementType , env ) ; } else { log . error ( tree . pos ( ) , "annotation.value.must.be.annotation" ) ; expectedElementType = syms . errType ; } } if ( tree . hasTag ( ANNOTATION ) ) { if ( ! expectedElementType . isErroneous ( ) ) log . error ( tree . pos ( ) , "annotation.not.valid.for.type" , expectedElementType ) ; attributeAnnotation ( ( JCAnnotation ) tree , syms . errType , env ) ; return new Attribute . Error ( ( ( JCAnnotation ) tree ) . annotationType . type ) ; } if ( expectedElementType . isPrimitive ( ) || ( types . isSameType ( expectedElementType , syms . stringType ) && ! expectedElementType . hasTag ( TypeTag . ERROR ) ) ) { return getAnnotationPrimitiveValue ( expectedElementType , tree , env ) ; } if ( expectedElementType . tsym == syms . classType . tsym ) { return getAnnotationClassValue ( expectedElementType , tree , env ) ; } if ( expectedElementType . hasTag ( CLASS ) && ( expectedElementType . tsym . flags ( ) & Flags . ENUM ) != 0 ) { return getAnnotationEnumValue ( expectedElementType , tree , env ) ; } if ( ! expectedElementType . isErroneous ( ) ) log . error ( tree . pos ( ) , "annotation.value.not.allowable.type" ) ; return new Attribute . Error ( attr . attribExpr ( tree , env , expectedElementType ) ) ; }
Attribute an annotation element value
274
private Type filterSame ( Type t , Type s ) { if ( t == null || s == null ) { return t ; } return types . isSameType ( t , s ) ? null : t ; }
returns null if t is same as s returns t otherwise
275
private Type extractContainingType ( Attribute . Compound ca , DiagnosticPosition pos , TypeSymbol annoDecl ) { if ( ca . values . isEmpty ( ) ) { log . error ( pos , "invalid.repeatable.annotation" , annoDecl ) ; return null ; } Pair < MethodSymbol , Attribute > p = ca . values . head ; Name name = p . fst . name ; if ( name != names . value ) { log . error ( pos , "invalid.repeatable.annotation" , annoDecl ) ; return null ; } if ( ! ( p . snd instanceof Attribute . Class ) ) { log . error ( pos , "invalid.repeatable.annotation" , annoDecl ) ; return null ; } return ( ( Attribute . Class ) p . snd ) . getValue ( ) ; }
Extract the actual Type to be used for a containing annotation .
276
public void enterTypeAnnotations ( List < JCAnnotation > annotations , Env < AttrContext > env , Symbol s , DiagnosticPosition deferPos , boolean isTypeParam ) { Assert . checkNonNull ( s , "Symbol argument to actualEnterTypeAnnotations is nul/" ) ; JavaFileObject prev = log . useSource ( env . toplevel . sourcefile ) ; DiagnosticPosition prevLintPos = null ; if ( deferPos != null ) { prevLintPos = deferredLintHandler . setPos ( deferPos ) ; } try { annotateNow ( s , annotations , env , true , isTypeParam ) ; } finally { if ( prevLintPos != null ) deferredLintHandler . setPos ( prevLintPos ) ; log . useSource ( prev ) ; } }
Attribute the list of annotations and enter them onto s .
277
public void queueScanTreeAndTypeAnnotate ( JCTree tree , Env < AttrContext > env , Symbol sym , DiagnosticPosition deferPos ) { Assert . checkNonNull ( sym ) ; normal ( ( ) -> tree . accept ( new TypeAnnotate ( env , sym , deferPos ) ) ) ; }
Enqueue tree for scanning of type annotations attaching to the Symbol sym .
278
public static Log instance ( Context context ) { Log instance = context . get ( logKey ) ; if ( instance == null ) instance = new Log ( context ) ; return instance ; }
Get the Log instance for this context .
279
public static void preRegister ( Context context , PrintWriter w ) { context . put ( Log . class , ( Context . Factory < Log > ) ( c -> new Log ( c , w ) ) ) ; }
Register a Context . Factory to create a Log .
280
private static Map < WriterKind , PrintWriter > initWriters ( Context context ) { PrintWriter out = context . get ( outKey ) ; PrintWriter err = context . get ( errKey ) ; if ( out == null && err == null ) { out = new PrintWriter ( System . out , true ) ; err = new PrintWriter ( System . err , true ) ; return initWriters ( out , err ) ; } else if ( out == null || err == null ) { PrintWriter pw = ( out != null ) ? out : err ; return initWriters ( pw , pw ) ; } else { return initWriters ( out , err ) ; } }
Initialize a map of writers based on values found in the context
281
private static Map < WriterKind , PrintWriter > initWriters ( PrintWriter out , PrintWriter err ) { Map < WriterKind , PrintWriter > writers = new EnumMap < > ( WriterKind . class ) ; writers . put ( WriterKind . ERROR , err ) ; writers . put ( WriterKind . WARNING , err ) ; writers . put ( WriterKind . NOTICE , err ) ; writers . put ( WriterKind . STDOUT , out ) ; writers . put ( WriterKind . STDERR , err ) ; return writers ; }
Initialize a writer map for a stream for normal output and a stream for diagnostics .
282
private static Map < WriterKind , PrintWriter > initWriters ( PrintWriter errWriter , PrintWriter warnWriter , PrintWriter noticeWriter ) { Map < WriterKind , PrintWriter > writers = new EnumMap < > ( WriterKind . class ) ; writers . put ( WriterKind . ERROR , errWriter ) ; writers . put ( WriterKind . WARNING , warnWriter ) ; writers . put ( WriterKind . NOTICE , noticeWriter ) ; writers . put ( WriterKind . STDOUT , noticeWriter ) ; writers . put ( WriterKind . STDERR , errWriter ) ; return writers ; }
Initialize a writer map with different streams for different types of diagnostics .
283
public void popDiagnosticHandler ( DiagnosticHandler h ) { Assert . check ( diagnosticHandler == h ) ; diagnosticHandler = h . prev ; }
Replace the specified diagnostic handler with the handler that was current at the time this handler was created . The given handler must be the currently installed handler ; it must be specified explicitly for clarity and consistency checking .
284
protected boolean shouldReport ( JavaFileObject file , int pos ) { if ( file == null ) return true ; Pair < JavaFileObject , Integer > coords = new Pair < > ( file , pos ) ; boolean shouldReport = ! recorded . contains ( coords ) ; if ( shouldReport ) recorded . add ( coords ) ; return shouldReport ; }
Returns true if an error needs to be reported for a given source name and pos .
285
private boolean shouldReport ( JCDiagnostic d ) { JavaFileObject file = d . getSource ( ) ; if ( file == null ) return true ; if ( ! shouldReport ( file , d . getIntPosition ( ) ) ) return false ; if ( ! d . isFlagSet ( DiagnosticFlag . SOURCE_LEVEL ) ) return true ; Pair < JavaFileObject , String > coords = new Pair < > ( file , d . getCode ( ) ) ; boolean shouldReport = ! recordedSourceLevelErrors . contains ( coords ) ; if ( shouldReport ) recordedSourceLevelErrors . add ( coords ) ; return shouldReport ; }
Returns true if a diagnostics needs to be reported .
286
public void prompt ( ) { if ( promptOnError ) { System . err . println ( localize ( "resume.abort" ) ) ; try { while ( true ) { switch ( System . in . read ( ) ) { case 'a' : case 'A' : System . exit ( - 1 ) ; return ; case 'r' : case 'R' : return ; case 'x' : case 'X' : throw new AssertionError ( "user abort" ) ; default : } } } catch ( IOException e ) { } } }
Prompt user after an error .
287
private void printErrLine ( int pos , PrintWriter writer ) { String line = ( source == null ? null : source . getLine ( pos ) ) ; if ( line == null ) return ; int col = source . getColumnNumber ( pos , false ) ; printRawLines ( writer , line ) ; for ( int i = 0 ; i < col - 1 ; i ++ ) { writer . print ( ( line . charAt ( i ) == '\t' ) ? "\t" : " " ) ; } writer . println ( "^" ) ; writer . flush ( ) ; }
Print the faulty source code line and point to the error .
288
public void strictWarning ( DiagnosticPosition pos , String key , Object ... args ) { writeDiagnostic ( diags . warning ( null , source , pos , key , args ) ) ; nwarnings ++ ; }
Report a warning that cannot be suppressed .
289
protected void writeDiagnostic ( JCDiagnostic diag ) { if ( diagListener != null ) { diagListener . report ( diag ) ; return ; } PrintWriter writer = getWriterForDiagnosticType ( diag . getType ( ) ) ; printRawLines ( writer , diagFormatter . format ( diag , messages . getCurrentLocale ( ) ) ) ; if ( promptOnError ) { switch ( diag . getType ( ) ) { case ERROR : case WARNING : prompt ( ) ; } } if ( dumpOnError ) new RuntimeException ( ) . printStackTrace ( writer ) ; writer . flush ( ) ; }
Write out a diagnostic .
290
public Env < A > dup ( JCTree tree , A info ) { return dupto ( new Env < > ( tree , info ) ) ; }
Duplicate this environment updating with given tree and info and copying all other fields .
291
public Env < A > dupto ( Env < A > that ) { that . next = this ; that . outer = this . outer ; that . toplevel = this . toplevel ; that . enclClass = this . enclClass ; that . enclMethod = this . enclMethod ; return that ; }
Duplicate this environment into a given Environment using its tree and info and copying all other fields .
292
public Env < A > enclosing ( JCTree . Tag tag ) { Env < A > env1 = this ; while ( env1 != null && ! env1 . tree . hasTag ( tag ) ) env1 = env1 . next ; return env1 ; }
Return closest enclosing environment which points to a tree with given tag .
293
public static Arguments instance ( Context context ) { Arguments instance = context . get ( argsKey ) ; if ( instance == null ) { instance = new Arguments ( context ) ; } return instance ; }
Gets the Arguments instance for this context .
294
public void init ( String ownName , String ... args ) { this . ownName = ownName ; errorMode = ErrorMode . LOG ; files = new LinkedHashSet < > ( ) ; deferredFileManagerOptions = new LinkedHashMap < > ( ) ; fileObjects = null ; classNames = new LinkedHashSet < > ( ) ; processArgs ( List . from ( args ) , Option . getJavaCompilerOptions ( ) , cmdLineHelper , true , false ) ; if ( errors ) { log . printLines ( PrefixKind . JAVAC , "msg.usage" , ownName ) ; } }
Initializes this Args instance with a set of command line args . The args will be processed in conjunction with the full set of command line options including - help - version etc . The args may also contain class names and filenames . Any errors during this call and later during validate will be reported to the log .
295
public void init ( String ownName , Iterable < String > options , Iterable < String > classNames , Iterable < ? extends JavaFileObject > files ) { this . ownName = ownName ; this . classNames = toSet ( classNames ) ; this . fileObjects = toSet ( files ) ; this . files = null ; errorMode = ErrorMode . ILLEGAL_ARGUMENT ; if ( options != null ) { processArgs ( toList ( options ) , Option . getJavacToolOptions ( ) , apiHelper , false , true ) ; } errorMode = ErrorMode . ILLEGAL_STATE ; }
Initializes this Args instance with the parameters for a JavacTask . The options will be processed in conjunction with the restricted set of tool options which does not include - help - version etc nor does it include classes and filenames which should be specified separately . File manager options are handled directly by the file manager . Any errors found while processing individual args will be reported via IllegalArgumentException . Any subsequent errors during validate will be reported via IllegalStateException .
296
public Set < JavaFileObject > getFileObjects ( ) { if ( fileObjects == null ) { fileObjects = new LinkedHashSet < > ( ) ; } if ( files != null ) { JavacFileManager jfm = ( JavacFileManager ) getFileManager ( ) ; for ( JavaFileObject fo : jfm . getJavaFileObjectsFromPaths ( files ) ) fileObjects . add ( fo ) ; } return fileObjects ; }
Gets the files to be compiled .
297
private boolean processArgs ( Iterable < String > args , Set < Option > allowableOpts , OptionHelper helper , boolean allowOperands , boolean checkFileManager ) { if ( ! doProcessArgs ( args , allowableOpts , helper , allowOperands , checkFileManager ) ) return false ; if ( ! handleReleaseOptions ( extra -> doProcessArgs ( extra , allowableOpts , helper , allowOperands , checkFileManager ) ) ) return false ; options . notifyListeners ( ) ; return true ; }
Processes strings containing options and operands .
298
public boolean isEmpty ( ) { return ( ( files == null ) || files . isEmpty ( ) ) && ( ( fileObjects == null ) || fileObjects . isEmpty ( ) ) && ( classNames == null || classNames . isEmpty ( ) ) ; }
Returns true if there are no files or classes specified for use .
299
public Set < List < String > > getPluginOpts ( ) { String plugins = options . get ( Option . PLUGIN ) ; if ( plugins == null ) return Collections . emptySet ( ) ; Set < List < String > > pluginOpts = new LinkedHashSet < > ( ) ; for ( String plugin : plugins . split ( "\\x00" ) ) { pluginOpts . add ( List . from ( plugin . split ( "\\s+" ) ) ) ; } return Collections . unmodifiableSet ( pluginOpts ) ; }
Gets any options specifying plugins to be run .