idx
int64 0
41.2k
| question
stringlengths 74
4.21k
| target
stringlengths 5
888
|
---|---|---|
700 |
public Type externalType ( Types types ) { Type t = erasure ( types ) ; if ( name == name . table . names . init && owner . hasOuterInstance ( ) ) { Type outerThisType = types . erasure ( owner . type . getEnclosingType ( ) ) ; return new MethodType ( t . getParameterTypes ( ) . prepend ( outerThisType ) , t . getReturnType ( ) , t . getThrownTypes ( ) , t . tsym ) ; } else { return t ; } }
|
The external type of a symbol . This is the symbol s erased type except for constructors of inner classes which get the enclosing instance class added as first argument .
|
701 |
public ClassSymbol outermostClass ( ) { Symbol sym = this ; Symbol prev = null ; while ( sym . kind != PCK ) { prev = sym ; sym = sym . owner ; } return ( ClassSymbol ) prev ; }
|
The outermost class which indirectly owns this symbol .
|
702 |
public PackageSymbol packge ( ) { Symbol sym = this ; while ( sym . kind != PCK ) { sym = sym . owner ; } return ( PackageSymbol ) sym ; }
|
The package which indirectly owns this symbol .
|
703 |
public boolean isEnclosedBy ( ClassSymbol clazz ) { for ( Symbol sym = this ; sym . kind != PCK ; sym = sym . owner ) if ( sym == clazz ) return true ; return false ; }
|
Is this symbol the same as or enclosed by the given class?
|
704 |
Comment comment ( ) { if ( comment == null ) { String d = documentation ( ) ; if ( env . javaScriptScanner != null ) { env . javaScriptScanner . parse ( d , new JavaScriptScanner . Reporter ( ) { public void report ( ) { env . error ( DocImpl . this , "javadoc.JavaScript_in_comment" ) ; throw new FatalError ( ) ; } } ) ; } if ( env . doclint != null && treePath != null && env . shouldCheck ( treePath . getCompilationUnit ( ) ) && d . equals ( getCommentText ( treePath ) ) ) { env . doclint . scan ( treePath ) ; } comment = new Comment ( this , d ) ; } return comment ; }
|
For lazy initialization of comment .
|
705 |
String readHTMLDocumentation ( InputStream input , FileObject filename ) throws IOException { byte [ ] filecontents = new byte [ input . available ( ) ] ; try { DataInputStream dataIn = new DataInputStream ( input ) ; dataIn . readFully ( filecontents ) ; } finally { input . close ( ) ; } String encoding = env . getEncoding ( ) ; String rawDoc = ( encoding != null ) ? new String ( filecontents , encoding ) : new String ( filecontents ) ; Pattern bodyPat = Pattern . compile ( "(?is).*<body\\b[^>]*>(.*)</body\\b.*" ) ; Matcher m = bodyPat . matcher ( rawDoc ) ; if ( m . matches ( ) ) { return m . group ( 1 ) ; } else { String key = rawDoc . matches ( "(?is).*<body\\b.*" ) ? "javadoc.End_body_missing_from_html_file" : "javadoc.Body_missing_from_html_file" ; env . error ( SourcePositionImpl . make ( filename , Position . NOPOS , null ) , key ) ; return "" ; } }
|
Utility for subclasses which read HTML documentation files .
|
706 |
void setTreePath ( TreePath treePath ) { this . treePath = treePath ; documentation = getCommentText ( treePath ) ; comment = null ; }
|
Set the full unprocessed text of the comment and tree path .
|
707 |
private void validateTypeNotIn ( TypeMirror t , Set < TypeKind > invalidKinds ) { if ( invalidKinds . contains ( t . getKind ( ) ) ) throw new IllegalArgumentException ( t . toString ( ) ) ; }
|
Throws an IllegalArgumentException if a type s kind is one of a set .
|
708 |
private static < T > T cast ( Class < T > clazz , Object o ) { if ( ! clazz . isInstance ( o ) ) throw new IllegalArgumentException ( o . toString ( ) ) ; return clazz . cast ( o ) ; }
|
Returns an object cast to the specified type .
|
709 |
public final void setBorderWidth ( int unit , int size ) { if ( size < 0 ) { throw new IllegalArgumentException ( "Border width cannot be less than zero." ) ; } int scaledSize = ( int ) TypedValue . applyDimension ( unit , size , getResources ( ) . getDisplayMetrics ( ) ) ; setBorderInternal ( scaledSize , mBorderColor , true ) ; }
|
Sets the border width .
|
710 |
public final void setPlaceholder ( String text ) { if ( ! text . equalsIgnoreCase ( mText ) ) { setPlaceholderTextInternal ( text , mTextColor , mTextSize , true ) ; } }
|
Sets the placeholder text .
|
711 |
public final void setPlaceholderTextSize ( int unit , int size ) { if ( size < 0 ) { throw new IllegalArgumentException ( "Text size cannot be less than zero." ) ; } int scaledSize = ( int ) TypedValue . applyDimension ( unit , size , getResources ( ) . getDisplayMetrics ( ) ) ; setPlaceholderTextInternal ( mText , mTextColor , scaledSize , true ) ; }
|
Sets the placeholder text size .
|
712 |
public void setShadowRadius ( float radius ) { if ( radius < 0 ) { throw new IllegalArgumentException ( "Shadow radius cannot be less than zero." ) ; } if ( radius != mShadowRadius ) { setShadowInternal ( radius , mShadowColor , true ) ; } }
|
Sets shadow radius
|
713 |
public void allowCheckStateShadow ( boolean allow ) { if ( allow != mAllowCheckStateShadow ) { mAllowCheckStateShadow = allow ; setShadowInternal ( mShadowRadius , mShadowColor , true ) ; } }
|
Allow shadow when in checked state .
|
714 |
protected String formatPlaceholderText ( String text ) { String formattedText = ( null != text ) ? text . trim ( ) : null ; int length = ( null != formattedText ) ? formattedText . length ( ) : 0 ; if ( length > 0 ) { return formattedText . substring ( 0 , Math . min ( 2 , length ) ) . toUpperCase ( Locale . getDefault ( ) ) ; } return null ; }
|
Default implementation of the placeholder text formatting .
|
715 |
protected void drawCheckedState ( Canvas canvas , int w , int h ) { int x = w / 2 ; int y = h / 2 ; canvas . drawCircle ( x , y , mRadius - ( mShadowRadius * 1.5f ) , mCheckedBackgroundPaint ) ; canvas . save ( ) ; int shortStrokeHeight = ( int ) ( mLongStrokeHeight * .4f ) ; int halfH = ( int ) ( mLongStrokeHeight * .5f ) ; int offset = ( int ) ( shortStrokeHeight * .3f ) ; int sx = x + offset ; int sy = y - offset ; mPath . reset ( ) ; mPath . moveTo ( sx , sy - halfH ) ; mPath . lineTo ( sx , sy + halfH ) ; mPath . moveTo ( sx + ( getCheckMarkStrokeWidthInPixels ( ) * .5f ) , sy + halfH ) ; mPath . lineTo ( sx - shortStrokeHeight , sy + halfH ) ; canvas . rotate ( 45f , x , y ) ; canvas . drawPath ( mPath , mCheckMarkPaint ) ; canvas . restore ( ) ; }
|
Draws the checked state .
|
716 |
private void updateBitmapShader ( ) { Drawable drawable = getDrawable ( ) ; Bitmap bitmap = null ; if ( ( null != drawable ) && ( drawable instanceof BitmapDrawable ) ) { bitmap = ( ( BitmapDrawable ) drawable ) . getBitmap ( ) ; } if ( null == bitmap ) { mBitmapPaint . setShader ( null ) ; return ; } int bitmapWidth = bitmap . getWidth ( ) ; int bitmapHeight = bitmap . getHeight ( ) ; float x = 0 , y = 0 ; int diameter = mRadius * 2 ; int borderWidth = shouldDrawBorder ( ) ? mBorderWidth : 0 ; int offset = ( borderWidth > 0 ) ? ( borderWidth * 2 ) : 0 ; offset += mShadowRadius * 1.5f ; float scale = ( float ) ( diameter - offset ) / ( float ) Math . min ( bitmapHeight , bitmapWidth ) ; x = ( mWidth - bitmapWidth * scale ) * 0.5f ; y = ( mHeight - bitmapHeight * scale ) * 0.5f ; Matrix matrix = new Matrix ( ) ; matrix . setScale ( scale , scale ) ; matrix . postTranslate ( Math . round ( x ) , Math . round ( y ) ) ; BitmapShader shader = new BitmapShader ( bitmap , Shader . TileMode . CLAMP , Shader . TileMode . CLAMP ) ; shader . setLocalMatrix ( matrix ) ; mBitmapPaint . setShader ( shader ) ; }
|
Updates BitmapShader to draw the bitmap in CENTER_CROP mode .
|
717 |
@ DefinedBy ( Api . COMPILER_TREE ) public TypeMirror getOriginalType ( javax . lang . model . type . ErrorType errorType ) { if ( errorType instanceof com . sun . tools . javac . code . Type . ErrorType ) { return ( ( com . sun . tools . javac . code . Type . ErrorType ) errorType ) . getOriginalType ( ) ; } return com . sun . tools . javac . code . Type . noType ; }
|
Returns the original type from the ErrorType object .
|
718 |
@ DefinedBy ( Api . COMPILER_TREE ) public void printMessage ( Diagnostic . Kind kind , CharSequence msg , com . sun . source . tree . Tree t , com . sun . source . tree . CompilationUnitTree root ) { printMessage ( kind , msg , ( ( JCTree ) t ) . pos ( ) , root ) ; }
|
Prints a message of the specified kind at the location of the tree within the provided compilation unit
|
719 |
void setResult ( JCExpression tree , Type type ) { result = type ; if ( env . info . isSpeculative ) { tree . type = result ; } }
|
Set the results of method attribution .
|
720 |
Type attribArg ( JCTree tree , Env < AttrContext > env ) { Env < AttrContext > prevEnv = this . env ; try { this . env = env ; tree . accept ( this ) ; return result ; } finally { this . env = prevEnv ; } }
|
Main entry point for attributing an argument with given tree and attribution environment .
|
721 |
@ SuppressWarnings ( "unchecked" ) < T extends JCExpression , Z extends ArgumentType < T > > void processArg ( T that , Function < T , Z > argumentTypeFactory ) { UniquePos pos = new UniquePos ( that ) ; processArg ( that , ( ) -> { T speculativeTree = ( T ) deferredAttr . attribSpeculative ( that , env , attr . new MethodAttrInfo ( ) { protected boolean needsArgumentAttr ( JCTree tree ) { return ! new UniquePos ( tree ) . equals ( pos ) ; } } ) ; return argumentTypeFactory . apply ( speculativeTree ) ; } ) ; }
|
Process a method argument ; this method takes care of performing a speculative pass over the argument tree and calling a well - defined entry point to build the argument type associated with such tree .
|
722 |
public Stream < ModuleDescriptor > descriptors ( ) { return automaticToNormalModule . entrySet ( ) . stream ( ) . map ( Map . Entry :: getValue ) . map ( Module :: descriptor ) ; }
|
Returns the stream of resulting ModuleDescriptors
|
723 |
private Map < Archive , Set < Archive > > computeRequiresTransitive ( ) throws IOException { dependencyFinder . parseExportedAPIs ( automaticModules ( ) . stream ( ) ) ; return dependencyFinder . dependences ( ) ; }
|
Compute requires transitive dependences by analyzing API dependencies
|
724 |
String indent ( String s , int level ) { return Stream . of ( s . split ( "\n" ) ) . map ( sub -> INDENT_STRING . substring ( 0 , level * INDENT_WIDTH ) + sub ) . collect ( Collectors . joining ( "\n" ) ) ; }
|
Indent a string to a given level .
|
725 |
String packageName ( File file ) { String path = file . getAbsolutePath ( ) ; int begin = path . lastIndexOf ( File . separatorChar + "com" + File . separatorChar ) ; String packagePath = path . substring ( begin + 1 , path . lastIndexOf ( File . separatorChar ) ) ; String packageName = packagePath . replace ( File . separatorChar , '.' ) ; return packageName ; }
|
Retrieve package part of given file object .
|
726 |
public static String toplevelName ( File file ) { return Stream . of ( file . getName ( ) . split ( "\\." ) ) . map ( s -> Character . toUpperCase ( s . charAt ( 0 ) ) + s . substring ( 1 ) ) . collect ( Collectors . joining ( "" ) ) ; }
|
Form the name of the toplevel factory class .
|
727 |
List < String > generateImports ( Set < String > importedTypes ) { List < String > importDecls = new ArrayList < > ( ) ; for ( String it : importedTypes ) { importDecls . add ( StubKind . IMPORT . format ( it ) ) ; } return importDecls ; }
|
Generate a list of import declarations given a set of imported types .
|
728 |
List < String > argDecls ( List < String > types , List < String > args ) { List < String > argNames = new ArrayList < > ( ) ; for ( int i = 0 ; i < types . size ( ) ; i ++ ) { argNames . add ( types . get ( i ) + " " + args . get ( i ) ) ; } return argNames ; }
|
Generate a formal parameter list given a list of types and names .
|
729 |
List < String > argNames ( int size ) { List < String > argNames = new ArrayList < > ( ) ; for ( int i = 0 ; i < size ; i ++ ) { argNames . add ( StubKind . FACTORY_METHOD_ARG . format ( i ) ) ; } return argNames ; }
|
Generate a list of formal parameter names given a size .
|
730 |
boolean needsSuppressWarnings ( List < MessageType > msgTypes ) { return msgTypes . stream ( ) . anyMatch ( t -> t . accept ( suppressWarningsVisitor , null ) ) ; }
|
See if any of the parsed types in the given list needs warning suppression .
|
731 |
Set < String > importedTypes ( List < MessageType > msgTypes ) { Set < String > imports = new TreeSet < > ( ) ; msgTypes . forEach ( t -> t . accept ( importVisitor , imports ) ) ; return imports ; }
|
Retrieve a list of types that need to be imported so that the factory body can refer to the types in the given list using simple names .
|
732 |
List < List < MessageType > > normalizeTypes ( int idx , List < MessageType > msgTypes ) { if ( msgTypes . size ( ) == idx ) return Collections . singletonList ( Collections . emptyList ( ) ) ; MessageType head = msgTypes . get ( idx ) ; List < List < MessageType > > buf = new ArrayList < > ( ) ; for ( MessageType alternative : head . accept ( normalizeVisitor , null ) ) { for ( List < MessageType > rest : normalizeTypes ( idx + 1 , msgTypes ) ) { List < MessageType > temp = new ArrayList < > ( rest ) ; temp . add ( 0 , alternative ) ; buf . add ( temp ) ; } } return buf ; }
|
Normalize parsed types in a comment line . If one or more types in the line contains alternatives this routine generate a list of overloaded normalized signatures .
|
733 |
public ClassDocImpl lookupClass ( String name ) { ClassSymbol c = getClassSymbol ( name ) ; if ( c != null ) { return getClassDoc ( c ) ; } else { return null ; } }
|
Look up ClassDoc by qualified name .
|
734 |
public void setLocale ( String localeName ) { doclocale = new DocLocale ( this , localeName , breakiterator ) ; messager . setLocale ( doclocale . locale ) ; }
|
Set the locale .
|
735 |
public boolean shouldDocument ( VarSymbol sym ) { long mod = sym . flags ( ) ; if ( ( mod & Flags . SYNTHETIC ) != 0 ) { return false ; } return showAccess . checkModifier ( translateModifiers ( mod ) ) ; }
|
Check whether this member should be documented .
|
736 |
public boolean shouldDocument ( ClassSymbol sym ) { return ( sym . flags_field & Flags . SYNTHETIC ) == 0 && ( docClasses || getClassDoc ( sym ) . tree != null ) && isVisible ( sym ) ; }
|
check whether this class should be documented .
|
737 |
public PackageDocImpl getPackageDoc ( PackageSymbol pack ) { PackageDocImpl result = packageMap . get ( pack ) ; if ( result != null ) return result ; result = new PackageDocImpl ( this , pack ) ; packageMap . put ( pack , result ) ; return result ; }
|
Return the PackageDoc of this package symbol .
|
738 |
public FieldDocImpl getFieldDoc ( VarSymbol var ) { FieldDocImpl result = fieldMap . get ( var ) ; if ( result != null ) return result ; result = new FieldDocImpl ( this , var ) ; fieldMap . put ( var , result ) ; return result ; }
|
Return the FieldDoc of this var symbol .
|
739 |
protected void makeFieldDoc ( VarSymbol var , TreePath treePath ) { FieldDocImpl result = fieldMap . get ( var ) ; if ( result != null ) { if ( treePath != null ) result . setTreePath ( treePath ) ; } else { result = new FieldDocImpl ( this , var , treePath ) ; fieldMap . put ( var , result ) ; } }
|
Create a FieldDoc for a var symbol .
|
740 |
protected void makeMethodDoc ( MethodSymbol meth , TreePath treePath ) { MethodDocImpl result = ( MethodDocImpl ) methodMap . get ( meth ) ; if ( result != null ) { if ( treePath != null ) result . setTreePath ( treePath ) ; } else { result = new MethodDocImpl ( this , meth , treePath ) ; methodMap . put ( meth , result ) ; } }
|
Create a MethodDoc for this MethodSymbol . Should be called only on symbols representing methods .
|
741 |
public MethodDocImpl getMethodDoc ( MethodSymbol meth ) { assert ! meth . isConstructor ( ) : "not expecting a constructor symbol" ; MethodDocImpl result = ( MethodDocImpl ) methodMap . get ( meth ) ; if ( result != null ) return result ; result = new MethodDocImpl ( this , meth ) ; methodMap . put ( meth , result ) ; return result ; }
|
Return the MethodDoc for a MethodSymbol . Should be called only on symbols representing methods .
|
742 |
protected void makeConstructorDoc ( MethodSymbol meth , TreePath treePath ) { ConstructorDocImpl result = ( ConstructorDocImpl ) methodMap . get ( meth ) ; if ( result != null ) { if ( treePath != null ) result . setTreePath ( treePath ) ; } else { result = new ConstructorDocImpl ( this , meth , treePath ) ; methodMap . put ( meth , result ) ; } }
|
Create the ConstructorDoc for a MethodSymbol . Should be called only on symbols representing constructors .
|
743 |
public ConstructorDocImpl getConstructorDoc ( MethodSymbol meth ) { assert meth . isConstructor ( ) : "expecting a constructor symbol" ; ConstructorDocImpl result = ( ConstructorDocImpl ) methodMap . get ( meth ) ; if ( result != null ) return result ; result = new ConstructorDocImpl ( this , meth ) ; methodMap . put ( meth , result ) ; return result ; }
|
Return the ConstructorDoc for a MethodSymbol . Should be called only on symbols representing constructors .
|
744 |
protected void makeAnnotationTypeElementDoc ( MethodSymbol meth , TreePath treePath ) { AnnotationTypeElementDocImpl result = ( AnnotationTypeElementDocImpl ) methodMap . get ( meth ) ; if ( result != null ) { if ( treePath != null ) result . setTreePath ( treePath ) ; } else { result = new AnnotationTypeElementDocImpl ( this , meth , treePath ) ; methodMap . put ( meth , result ) ; } }
|
Create the AnnotationTypeElementDoc for a MethodSymbol . Should be called only on symbols representing annotation type elements .
|
745 |
public AnnotationTypeElementDocImpl getAnnotationTypeElementDoc ( MethodSymbol meth ) { AnnotationTypeElementDocImpl result = ( AnnotationTypeElementDocImpl ) methodMap . get ( meth ) ; if ( result != null ) return result ; result = new AnnotationTypeElementDocImpl ( this , meth ) ; methodMap . put ( meth , result ) ; return result ; }
|
Return the AnnotationTypeElementDoc for a MethodSymbol . Should be called only on symbols representing annotation type elements .
|
746 |
static int translateModifiers ( long flags ) { int result = 0 ; if ( ( flags & Flags . ABSTRACT ) != 0 ) result |= Modifier . ABSTRACT ; if ( ( flags & Flags . FINAL ) != 0 ) result |= Modifier . FINAL ; if ( ( flags & Flags . INTERFACE ) != 0 ) result |= Modifier . INTERFACE ; if ( ( flags & Flags . NATIVE ) != 0 ) result |= Modifier . NATIVE ; if ( ( flags & Flags . PRIVATE ) != 0 ) result |= Modifier . PRIVATE ; if ( ( flags & Flags . PROTECTED ) != 0 ) result |= Modifier . PROTECTED ; if ( ( flags & Flags . PUBLIC ) != 0 ) result |= Modifier . PUBLIC ; if ( ( flags & Flags . STATIC ) != 0 ) result |= Modifier . STATIC ; if ( ( flags & Flags . SYNCHRONIZED ) != 0 ) result |= Modifier . SYNCHRONIZED ; if ( ( flags & Flags . TRANSIENT ) != 0 ) result |= Modifier . TRANSIENT ; if ( ( flags & Flags . VOLATILE ) != 0 ) result |= Modifier . VOLATILE ; return result ; }
|
Convert modifier bits from private coding used by the compiler to that of java . lang . reflect . Modifier .
|
747 |
void analyzeIfNeeded ( JCTree tree , Env < AttrContext > env ) { if ( ! analyzerModes . isEmpty ( ) && ! env . info . isSpeculative && TreeInfo . isStatement ( tree ) ) { JCStatement stmt = ( JCStatement ) tree ; analyze ( stmt , env ) ; } }
|
Analyze an AST node if needed .
|
748 |
void analyze ( JCStatement statement , Env < AttrContext > env ) { AnalysisContext context = new AnalysisContext ( ) ; StatementScanner statementScanner = new StatementScanner ( context ) ; statementScanner . scan ( statement ) ; if ( ! context . treesToAnalyzer . isEmpty ( ) ) { JCBlock fakeBlock = make . Block ( SYNTHETIC , List . of ( statement ) ) ; TreeMapper treeMapper = new TreeMapper ( context ) ; deferredAttr . attribSpeculative ( fakeBlock , env , attr . statInfo , treeMapper , t -> new AnalyzeDeferredDiagHandler ( context ) , argumentAttr . withLocalCacheContext ( ) ) ; context . treeMap . entrySet ( ) . forEach ( e -> { context . treesToAnalyzer . get ( e . getKey ( ) ) . process ( e . getKey ( ) , e . getValue ( ) , context . errors . nonEmpty ( ) ) ; } ) ; } }
|
Analyze an AST node ; this involves collecting a list of all the nodes that needs rewriting and speculatively type - check the rewritten code to compare results against previously attributed code .
|
749 |
public boolean isOrdinaryClass ( ) { if ( isEnum ( ) || isInterface ( ) || isAnnotationType ( ) ) { return false ; } for ( Type t = type ; t . hasTag ( CLASS ) ; t = env . types . supertype ( t ) ) { if ( t . tsym == env . syms . errorType . tsym || t . tsym == env . syms . exceptionType . tsym ) { return false ; } } return true ; }
|
Return true if this is a ordinary class not an enumeration exception an error or an interface .
|
750 |
public boolean isThrowable ( ) { if ( isEnum ( ) || isInterface ( ) || isAnnotationType ( ) ) { return false ; } for ( Type t = type ; t . hasTag ( CLASS ) ; t = env . types . supertype ( t ) ) { if ( t . tsym == env . syms . throwableType . tsym ) { return true ; } } return false ; }
|
Return true if this is a throwable class
|
751 |
public boolean isIncluded ( ) { if ( isIncluded ) { return true ; } if ( env . shouldDocument ( tsym ) ) { if ( containingPackage ( ) . isIncluded ( ) ) { return isIncluded = true ; } ClassDoc outer = containingClass ( ) ; if ( outer != null && outer . isIncluded ( ) ) { return isIncluded = true ; } } return false ; }
|
Return true if this class is included in the active set . A ClassDoc is included iff either it is specified on the commandline or if it s containing package is specified on the command line or if it is a member class of an included class .
|
752 |
public PackageDoc containingPackage ( ) { PackageDocImpl p = env . getPackageDoc ( tsym . packge ( ) ) ; if ( p . setDocPath == false ) { FileObject docPath ; try { Location location = env . fileManager . hasLocation ( StandardLocation . SOURCE_PATH ) ? StandardLocation . SOURCE_PATH : StandardLocation . CLASS_PATH ; docPath = env . fileManager . getFileForInput ( location , p . qualifiedName ( ) , "package.html" ) ; } catch ( IOException e ) { docPath = null ; } if ( docPath == null ) { SourcePosition po = position ( ) ; if ( env . fileManager instanceof StandardJavaFileManager && po instanceof SourcePositionImpl ) { URI uri = ( ( SourcePositionImpl ) po ) . filename . toUri ( ) ; if ( "file" . equals ( uri . getScheme ( ) ) ) { File f = new File ( uri ) ; File dir = f . getParentFile ( ) ; if ( dir != null ) { File pf = new File ( dir , "package.html" ) ; if ( pf . exists ( ) ) { StandardJavaFileManager sfm = ( StandardJavaFileManager ) env . fileManager ; docPath = sfm . getJavaFileObjects ( pf ) . iterator ( ) . next ( ) ; } } } } } p . setDocPath ( docPath ) ; } return p ; }
|
Return the package that this class is contained in .
|
753 |
public ClassDoc superclass ( ) { if ( isInterface ( ) || isAnnotationType ( ) ) return null ; if ( tsym == env . syms . objectType . tsym ) return null ; ClassSymbol c = ( ClassSymbol ) env . types . supertype ( type ) . tsym ; if ( c == null || c == tsym ) c = ( ClassSymbol ) env . syms . objectType . tsym ; return env . getClassDoc ( c ) ; }
|
Return the superclass of this class
|
754 |
public boolean subclassOf ( ClassDoc cd ) { return tsym . isSubClass ( ( ( ClassDocImpl ) cd ) . tsym , env . types ) ; }
|
Test whether this class is a subclass of the specified class .
|
755 |
public ClassDoc [ ] interfaces ( ) { ListBuffer < ClassDocImpl > ta = new ListBuffer < > ( ) ; for ( Type t : env . types . interfaces ( type ) ) { ta . append ( env . getClassDoc ( ( ClassSymbol ) t . tsym ) ) ; } return ta . toArray ( new ClassDocImpl [ ta . length ( ) ] ) ; }
|
Return interfaces implemented by this class or interfaces extended by this interface .
|
756 |
public com . sun . javadoc . Type [ ] interfaceTypes ( ) { return TypeMaker . getTypes ( env , env . types . interfaces ( type ) ) ; }
|
Return interfaces implemented by this class or interfaces extended by this interface . Includes only directly - declared interfaces not inherited interfaces . Return an empty array if there are no interfaces .
|
757 |
public ClassDoc [ ] importedClasses ( ) { if ( tsym . sourcefile == null ) return new ClassDoc [ 0 ] ; ListBuffer < ClassDocImpl > importedClasses = new ListBuffer < > ( ) ; Env < AttrContext > compenv = env . enter . getEnv ( tsym ) ; if ( compenv == null ) return new ClassDocImpl [ 0 ] ; Name asterisk = tsym . name . table . names . asterisk ; for ( JCTree t : compenv . toplevel . defs ) { if ( t . hasTag ( IMPORT ) ) { JCTree imp = ( ( JCImport ) t ) . qualid ; if ( ( TreeInfo . name ( imp ) != asterisk ) && imp . type . tsym . kind . matches ( KindSelector . TYP ) ) { importedClasses . append ( env . getClassDoc ( ( ClassSymbol ) imp . type . tsym ) ) ; } } } return importedClasses . toArray ( new ClassDocImpl [ importedClasses . length ( ) ] ) ; }
|
Get the list of classes declared as imported . These are called single - type - import declarations in the JLS . This method is deprecated in the ClassDoc interface .
|
758 |
public PackageDoc [ ] importedPackages ( ) { if ( tsym . sourcefile == null ) return new PackageDoc [ 0 ] ; ListBuffer < PackageDocImpl > importedPackages = new ListBuffer < > ( ) ; Names names = tsym . name . table . names ; importedPackages . append ( env . getPackageDoc ( env . syms . enterPackage ( env . syms . java_base , names . java_lang ) ) ) ; Env < AttrContext > compenv = env . enter . getEnv ( tsym ) ; if ( compenv == null ) return new PackageDocImpl [ 0 ] ; for ( JCTree t : compenv . toplevel . defs ) { if ( t . hasTag ( IMPORT ) ) { JCTree imp = ( ( JCImport ) t ) . qualid ; if ( TreeInfo . name ( imp ) == names . asterisk ) { JCFieldAccess sel = ( JCFieldAccess ) imp ; Symbol s = sel . selected . type . tsym ; PackageDocImpl pdoc = env . getPackageDoc ( s . packge ( ) ) ; if ( ! importedPackages . contains ( pdoc ) ) importedPackages . append ( pdoc ) ; } } } return importedPackages . toArray ( new PackageDocImpl [ importedPackages . length ( ) ] ) ; }
|
Get the list of packages declared as imported . These are called type - import - on - demand declarations in the JLS . This method is deprecated in the ClassDoc interface .
|
759 |
public MethodDoc [ ] serializationMethods ( ) { if ( serializedForm == null ) { serializedForm = new SerializedForm ( env , tsym , this ) ; } return serializedForm . methods ( ) ; }
|
Return the serialization methods for this class .
|
760 |
protected void addModulesToIndexMap ( ) { for ( ModuleElement mdle : configuration . modules ) { String mdleName = mdle . getQualifiedName ( ) . toString ( ) ; char ch = ( mdleName . length ( ) == 0 ) ? '*' : Character . toUpperCase ( mdleName . charAt ( 0 ) ) ; Character unicode = ch ; SortedSet < Element > list = indexmap . computeIfAbsent ( unicode , c -> new TreeSet < > ( comparator ) ) ; list . add ( mdle ) ; } }
|
Add all the modules to index map .
|
761 |
protected boolean shouldAddToIndexMap ( Element element ) { if ( utils . isHidden ( element ) ) { return false ; } if ( utils . isPackage ( element ) ) return ! ( noDeprecated && configuration . utils . isDeprecated ( element ) ) ; else return ! ( noDeprecated && ( configuration . utils . isDeprecated ( element ) || configuration . utils . isDeprecated ( utils . containingPackage ( element ) ) ) ) ; }
|
Should this element be added to the index map?
|
762 |
public List < ? extends Element > getMemberList ( Character index ) { SortedSet < Element > set = indexmap . get ( index ) ; if ( set == null ) return null ; List < Element > out = new ArrayList < > ( ) ; out . addAll ( set ) ; return out ; }
|
Return the sorted list of members for passed Unicode Character .
|
763 |
protected void buildAllClassesFile ( boolean wantFrames ) throws IOException { String label = configuration . getText ( "doclet.All_Classes" ) ; Content body = getBody ( false , getWindowTitle ( label ) ) ; Content heading = HtmlTree . HEADING ( HtmlConstants . TITLE_HEADING , HtmlStyle . bar , allclassesLabel ) ; body . addContent ( heading ) ; Content ul = new HtmlTree ( HtmlTag . UL ) ; addAllClasses ( ul , wantFrames ) ; HtmlTree htmlTree = ( configuration . allowTag ( HtmlTag . MAIN ) ) ? HtmlTree . MAIN ( HtmlStyle . indexContainer , ul ) : HtmlTree . DIV ( HtmlStyle . indexContainer , ul ) ; body . addContent ( htmlTree ) ; printHtmlDocument ( null , false , body ) ; }
|
Print all the classes in the file .
|
764 |
public static Messager instance0 ( Context context ) { Log instance = context . get ( logKey ) ; if ( instance == null || ! ( instance instanceof Messager ) ) throw new InternalError ( "no messager instance!" ) ; return ( Messager ) instance ; }
|
Get the current messager which is also the compiler log .
|
765 |
String getText ( String key , Object ... args ) { return messages . getLocalizedString ( locale , key , args ) ; }
|
get and format message string from resource
|
766 |
public void printWarning ( SourcePosition pos , String msg ) { if ( diagListener != null ) { report ( DiagnosticType . WARNING , pos , msg ) ; return ; } if ( nwarnings < MaxWarnings ) { String prefix = ( pos == null ) ? programName : pos . toString ( ) ; PrintWriter warnWriter = getWriter ( WriterKind . WARNING ) ; warnWriter . println ( prefix + ": " + getText ( "javadoc.warning" ) + " - " + msg ) ; warnWriter . flush ( ) ; nwarnings ++ ; } }
|
Print warning message increment warning count . Part of DocErrorReporter .
|
767 |
public int get ( Object o ) { Integer n = indices . get ( o ) ; return n == null ? - 1 : n . intValue ( ) ; }
|
Return the given object s index in the pool or - 1 if object is not in there .
|
768 |
private static < T > T getSystemTool ( Class < T > clazz , String moduleName , String className ) { if ( useLegacy ) { try { return Class . forName ( className , true , ClassLoader . getSystemClassLoader ( ) ) . asSubclass ( clazz ) . getConstructor ( ) . newInstance ( ) ; } catch ( ReflectiveOperationException e ) { throw new Error ( e ) ; } } try { ServiceLoader < T > sl = ServiceLoader . load ( clazz , ClassLoader . getSystemClassLoader ( ) ) ; for ( Iterator < T > iter = sl . iterator ( ) ; iter . hasNext ( ) ; ) { T tool = iter . next ( ) ; if ( matches ( tool , moduleName ) ) return tool ; } } catch ( ServiceConfigurationError e ) { throw new Error ( e ) ; } return null ; }
|
Get an instance of a system tool using the service loader .
|
769 |
private static < T > boolean matches ( T tool , String moduleName ) { PrivilegedAction < Boolean > pa = ( ) -> { try { Method getModuleMethod = Class . class . getDeclaredMethod ( "getModule" ) ; Object toolModule = getModuleMethod . invoke ( tool . getClass ( ) ) ; Method getNameMethod = toolModule . getClass ( ) . getDeclaredMethod ( "getName" ) ; String toolModuleName = ( String ) getNameMethod . invoke ( toolModule ) ; return moduleName . equals ( toolModuleName ) ; } catch ( InvocationTargetException | NoSuchMethodException | IllegalAccessException e ) { return false ; } } ; return AccessController . doPrivileged ( pa ) ; }
|
Determine if this is the desired tool instance .
|
770 |
public static ModuleSummaryBuilder getInstance ( Context context , ModuleElement mdle , ModuleSummaryWriter moduleWriter ) { return new ModuleSummaryBuilder ( context , mdle , moduleWriter ) ; }
|
Construct a new ModuleSummaryBuilder .
|
771 |
public void buildModuleDoc ( XMLNode node , Content contentTree ) throws DocletException { contentTree = moduleWriter . getModuleHeader ( mdle . getQualifiedName ( ) . toString ( ) ) ; buildChildren ( node , contentTree ) ; moduleWriter . addModuleFooter ( contentTree ) ; moduleWriter . printDocument ( contentTree ) ; utils . copyDirectory ( mdle , DocPaths . moduleSummary ( mdle ) ) ; }
|
Build the module documentation .
|
772 |
public void buildContent ( XMLNode node , Content contentTree ) throws DocletException { Content moduleContentTree = moduleWriter . getContentHeader ( ) ; buildChildren ( node , moduleContentTree ) ; moduleWriter . addModuleContent ( contentTree , moduleContentTree ) ; }
|
Build the content for the module doc .
|
773 |
public void buildSummary ( XMLNode node , Content moduleContentTree ) throws DocletException { Content summaryContentTree = moduleWriter . getSummaryHeader ( ) ; buildChildren ( node , summaryContentTree ) ; moduleContentTree . addContent ( moduleWriter . getSummaryTree ( summaryContentTree ) ) ; }
|
Build the module summary .
|
774 |
public void buildModuleDescription ( XMLNode node , Content moduleContentTree ) { if ( ! configuration . nocomment ) { moduleWriter . addModuleDescription ( moduleContentTree ) ; } }
|
Build the description for the module .
|
775 |
public void buildClassContent ( XMLNode node , Content classTree ) throws DocletException { Content classContentTree = writer . getClassContentHeader ( ) ; buildChildren ( node , classContentTree ) ; classTree . addContent ( classContentTree ) ; }
|
Build the summaries for the methods and fields .
|
776 |
public void buildMethodSubHeader ( XMLNode node , Content methodsContentTree ) { methodWriter . addMemberHeader ( ( ExecutableElement ) currentMember , methodsContentTree ) ; }
|
Build the method sub header .
|
777 |
public void buildDeprecatedMethodInfo ( XMLNode node , Content methodsContentTree ) { methodWriter . addDeprecatedMemberInfo ( ( ExecutableElement ) currentMember , methodsContentTree ) ; }
|
Build the deprecated method description .
|
778 |
public void buildMethodInfo ( XMLNode node , Content methodsContentTree ) throws DocletException { if ( configuration . nocomment ) { return ; } buildChildren ( node , methodsContentTree ) ; }
|
Build the information for the method .
|
779 |
public static boolean serialInclude ( Utils utils , Element element ) { if ( element == null ) { return false ; } return utils . isClass ( element ) ? serialClassInclude ( utils , ( TypeElement ) element ) : serialDocInclude ( utils , element ) ; }
|
Returns true if the given Element should be included in the serialized form .
|
780 |
private static boolean serialClassInclude ( Utils utils , TypeElement te ) { if ( utils . isEnum ( te ) ) { return false ; } if ( utils . isSerializable ( te ) ) { if ( ! utils . getSerialTrees ( te ) . isEmpty ( ) ) { return serialDocInclude ( utils , te ) ; } else if ( utils . isPublic ( te ) || utils . isProtected ( te ) ) { return true ; } else { return false ; } } return false ; }
|
Returns true if the given TypeElement should be included in the serialized form .
|
781 |
private static boolean serialDocInclude ( Utils utils , Element element ) { if ( utils . isEnum ( element ) ) { return false ; } List < ? extends DocTree > serial = utils . getSerialTrees ( element ) ; if ( ! serial . isEmpty ( ) ) { CommentHelper ch = utils . getCommentHelper ( element ) ; String serialtext = Utils . toLowerCase ( ch . getText ( serial . get ( 0 ) ) ) ; if ( serialtext . contains ( "exclude" ) ) { return false ; } else if ( serialtext . contains ( "include" ) ) { return true ; } } return true ; }
|
Return true if the given Element should be included in the serialized form .
|
782 |
public Set < Deque < Archive > > inverseDependences ( ) throws IOException { DependencyFinder dependencyFinder = new DependencyFinder ( configuration , DEFAULT_FILTER ) ; try { Stream < Archive > archives = Stream . concat ( configuration . initialArchives ( ) . stream ( ) , configuration . classPathArchives ( ) . stream ( ) ) ; if ( apiOnly ) { dependencyFinder . parseExportedAPIs ( archives ) ; } else { dependencyFinder . parse ( archives ) ; } Graph . Builder < Archive > builder = new Graph . Builder < > ( ) ; targets ( ) . forEach ( builder :: addNode ) ; configuration . getModules ( ) . values ( ) . stream ( ) . forEach ( m -> { builder . addNode ( m ) ; m . descriptor ( ) . requires ( ) . stream ( ) . map ( Requires :: name ) . map ( configuration :: findModule ) . forEach ( v -> builder . addEdge ( v . get ( ) , m ) ) ; } ) ; Map < Archive , Set < Archive > > dependences = dependencyFinder . dependences ( ) ; dependences . entrySet ( ) . stream ( ) . forEach ( e -> { Archive u = e . getKey ( ) ; builder . addNode ( u ) ; e . getValue ( ) . forEach ( v -> builder . addEdge ( v , u ) ) ; } ) ; Graph < Archive > graph = builder . build ( ) ; trace ( "targets: %s%n" , targets ( ) ) ; return targets ( ) . stream ( ) . map ( t -> findPaths ( graph , t ) ) . flatMap ( Set :: stream ) . collect ( Collectors . toSet ( ) ) ; } finally { dependencyFinder . shutdown ( ) ; } }
|
Finds all inverse transitive dependencies using the given requires set as the targets if non - empty . If the given requires set is empty use the archives depending the packages specified in - regex or - p options .
|
783 |
private Set < Deque < Archive > > findPaths ( Graph < Archive > graph , Archive target ) { Deque < Archive > path = new LinkedList < > ( ) ; path . push ( target ) ; Set < Edge < Archive > > visited = new HashSet < > ( ) ; Deque < Edge < Archive > > deque = new LinkedList < > ( ) ; deque . addAll ( graph . edgesFrom ( target ) ) ; if ( deque . isEmpty ( ) ) { return makePaths ( path ) . collect ( Collectors . toSet ( ) ) ; } Set < Deque < Archive > > allPaths = new HashSet < > ( ) ; while ( ! deque . isEmpty ( ) ) { Edge < Archive > edge = deque . pop ( ) ; if ( visited . contains ( edge ) ) continue ; Archive node = edge . v ; path . addLast ( node ) ; visited . add ( edge ) ; Set < Edge < Archive > > unvisitedDeps = graph . edgesFrom ( node ) . stream ( ) . filter ( e -> ! visited . contains ( e ) ) . collect ( Collectors . toSet ( ) ) ; trace ( "visiting %s %s (%s)%n" , edge , path , unvisitedDeps ) ; if ( unvisitedDeps . isEmpty ( ) ) { makePaths ( path ) . forEach ( allPaths :: add ) ; path . removeLast ( ) ; } unvisitedDeps . stream ( ) . forEach ( deque :: push ) ; while ( ! path . isEmpty ( ) ) { if ( visited . containsAll ( graph . edgesFrom ( path . peekLast ( ) ) ) ) path . removeLast ( ) ; else break ; } } return allPaths ; }
|
Returns all paths reachable from the given targets .
|
784 |
private Stream < Deque < Archive > > makePaths ( Deque < Archive > path ) { Set < Archive > nodes = endPoints . get ( path . peekFirst ( ) ) ; if ( nodes == null || nodes . isEmpty ( ) ) { return Stream . of ( new LinkedList < > ( path ) ) ; } else { return nodes . stream ( ) . map ( n -> { Deque < Archive > newPath = new LinkedList < > ( ) ; newPath . addFirst ( n ) ; newPath . addAll ( path ) ; return newPath ; } ) ; } }
|
Prepend end point to the path
|
785 |
public void run ( String ... args ) throws BadArgs , IOException { PrintWriter out = new PrintWriter ( System . out ) ; try { run ( out , args ) ; } finally { out . flush ( ) ; } }
|
Simple API entry point .
|
786 |
protected Content getNavLinkClassUse ( ) { Content useLink = getHyperLink ( DocPaths . PACKAGE_USE , contents . useLabel , "" , "" ) ; Content li = HtmlTree . LI ( useLink ) ; return li ; }
|
Get Use link for this pacakge in the navigation bar .
|
787 |
protected Content getNavLinkPackage ( ) { Content li = HtmlTree . LI ( HtmlStyle . navBarCell1Rev , contents . packageLabel ) ; return li ; }
|
Highlight Package in the navigation bar as this is the package page .
|
788 |
public void hard ( String format , Object ... args ) { rawout ( prefix ( format ) , args ) ; }
|
Must show command output
|
789 |
String getResourceString ( String key ) { if ( outputRB == null ) { try { outputRB = ResourceBundle . getBundle ( L10N_RB_NAME , locale ) ; } catch ( MissingResourceException mre ) { error ( "Cannot find ResourceBundle: %s for locale: %s" , L10N_RB_NAME , locale ) ; return "" ; } } String s ; try { s = outputRB . getString ( key ) ; } catch ( MissingResourceException mre ) { error ( "Missing resource: %s in %s" , key , L10N_RB_NAME ) ; return "" ; } return s ; }
|
Resource bundle look - up
|
790 |
public void hardmsg ( String key , Object ... args ) { hard ( messageFormat ( key , args ) ) ; }
|
Print using resource bundle look - up MessageFormat and add prefix and postfix
|
791 |
public void errormsg ( String key , Object ... args ) { if ( isRunningInteractive ( ) ) { rawout ( prefixError ( messageFormat ( key , args ) ) ) ; } else { startmsg ( key , args ) ; } }
|
Print error using resource bundle look - up MessageFormat and add prefix and postfix
|
792 |
void startmsg ( String key , Object ... args ) { cmderr . println ( messageFormat ( key , args ) ) ; }
|
Print command - line error using resource bundle look - up MessageFormat
|
793 |
public void start ( String [ ] args ) throws Exception { OptionParserCommandLine commandLineArgs = new OptionParserCommandLine ( ) ; options = commandLineArgs . parse ( args ) ; if ( options == null ) { return ; } startup = commandLineArgs . startup ( ) ; configEditor ( ) ; try { resetState ( ) ; } catch ( IllegalStateException ex ) { cmderr . println ( ex . getMessage ( ) ) ; return ; } replayableHistoryPrevious = ReplayableHistory . fromPrevious ( prefs ) ; for ( String loadFile : commandLineArgs . nonOptions ( ) ) { runFile ( loadFile , "jshell" ) ; } if ( regenerateOnDeath ) { initFeedback ( commandLineArgs . feedbackMode ( ) ) ; } if ( regenerateOnDeath ) { if ( feedback . shouldDisplayCommandFluff ( ) ) { hardmsg ( "jshell.msg.welcome" , version ( ) ) ; } Thread shutdownHook = new Thread ( ) { public void run ( ) { replayableHistory . storeHistory ( prefs ) ; } } ; Runtime . getRuntime ( ) . addShutdownHook ( shutdownHook ) ; try ( IOContext in = new ConsoleIOContext ( this , cmdin , console ) ) { while ( regenerateOnDeath ) { if ( ! live ) { resetState ( ) ; } run ( in ) ; } } finally { replayableHistory . storeHistory ( prefs ) ; closeState ( ) ; try { Runtime . getRuntime ( ) . removeShutdownHook ( shutdownHook ) ; } catch ( Exception ex ) { } } } closeState ( ) ; }
|
The entry point into the JShell tool .
|
794 |
private CompletionProvider snippetCompletion ( Supplier < Stream < ? extends Snippet > > snippetsSupplier ) { return ( prefix , cursor , anchor ) -> { anchor [ 0 ] = 0 ; int space = prefix . lastIndexOf ( ' ' ) ; Set < String > prior = new HashSet < > ( Arrays . asList ( prefix . split ( " " ) ) ) ; if ( prior . contains ( "-all" ) || prior . contains ( "-history" ) ) { return Collections . emptyList ( ) ; } String argPrefix = prefix . substring ( space + 1 ) ; return snippetsSupplier . get ( ) . filter ( k -> ! prior . contains ( String . valueOf ( k . id ( ) ) ) && ( ! ( k instanceof DeclarationSnippet ) || ! prior . contains ( ( ( DeclarationSnippet ) k ) . name ( ) ) ) ) . flatMap ( k -> ( k instanceof DeclarationSnippet ) ? Stream . of ( String . valueOf ( k . id ( ) ) + " " , ( ( DeclarationSnippet ) k ) . name ( ) + " " ) : Stream . of ( String . valueOf ( k . id ( ) ) + " " ) ) . filter ( k -> k . startsWith ( argPrefix ) ) . map ( ArgSuggestion :: new ) . collect ( Collectors . toList ( ) ) ; } ; }
|
Completion based on snippet supplier
|
795 |
private CompletionProvider helpCompletion ( ) { return ( code , cursor , anchor ) -> { List < Suggestion > result ; int pastSpace = code . indexOf ( ' ' ) + 1 ; if ( pastSpace == 0 ) { boolean noslash = code . length ( ) > 0 && ! code . startsWith ( "/" ) ; result = new FixedCompletionProvider ( commands . values ( ) . stream ( ) . filter ( cmd -> cmd . kind . showInHelp || cmd . kind == CommandKind . HELP_SUBJECT ) . map ( c -> ( ( noslash && c . command . startsWith ( "/" ) ) ? c . command . substring ( 1 ) : c . command ) + " " ) . toArray ( String [ ] :: new ) ) . completionSuggestions ( code , cursor , anchor ) ; } else if ( code . startsWith ( "/se" ) || code . startsWith ( "se" ) ) { result = new FixedCompletionProvider ( SET_SUBCOMMANDS ) . completionSuggestions ( code . substring ( pastSpace ) , cursor - pastSpace , anchor ) ; } else { result = Collections . emptyList ( ) ; } anchor [ 0 ] += pastSpace ; return result ; } ; }
|
Completion of help commands and subjects
|
796 |
String subCommand ( String cmd , ArgTokenizer at , String [ ] subs ) { at . allowedOptions ( "-retain" ) ; String sub = at . next ( ) ; if ( sub == null ) { return at . hasOption ( "-retain" ) ? "_retain" : "_blank" ; } String [ ] matches = Arrays . stream ( subs ) . filter ( s -> s . startsWith ( sub ) ) . toArray ( String [ ] :: new ) ; if ( matches . length == 0 ) { errormsg ( "jshell.err.arg" , cmd , sub ) ; fluffmsg ( "jshell.msg.use.one.of" , Arrays . stream ( subs ) . collect ( Collectors . joining ( ", " ) ) ) ; return null ; } if ( matches . length > 1 ) { errormsg ( "jshell.err.sub.ambiguous" , cmd , sub ) ; fluffmsg ( "jshell.msg.use.one.of" , Arrays . stream ( matches ) . collect ( Collectors . joining ( ", " ) ) ) ; return null ; } return matches [ 0 ] ; }
|
Return null on error
|
797 |
private static < T extends Snippet > Stream < T > nonEmptyStream ( Supplier < Stream < T > > supplier , SnippetPredicate < T > ... filters ) { for ( SnippetPredicate < T > filt : filters ) { Iterator < T > iterator = supplier . get ( ) . filter ( filt ) . iterator ( ) ; if ( iterator . hasNext ( ) ) { return StreamSupport . stream ( Spliterators . spliteratorUnknownSize ( iterator , 0 ) , false ) ; } } return null ; }
|
Apply filters to a stream until one that is non - empty is found . Adapted from Stuart Marks
|
798 |
private < T extends Snippet > Stream < T > argsToSnippets ( Supplier < Stream < T > > snippetSupplier , List < String > args ) { Stream < T > result = null ; for ( String arg : args ) { Stream < T > st = layeredSnippetSearch ( snippetSupplier , arg ) ; if ( st == null ) { Stream < Snippet > est = layeredSnippetSearch ( state :: snippets , arg ) ; if ( est == null ) { errormsg ( "jshell.err.no.such.snippets" , arg ) ; } else { errormsg ( "jshell.err.the.snippet.cannot.be.used.with.this.command" , arg , est . findFirst ( ) . get ( ) . source ( ) ) ; } return null ; } if ( result == null ) { result = st ; } else { result = Stream . concat ( result , st ) ; } } return result ; }
|
Convert user arguments to a Stream of snippets referenced by those arguments .
|
799 |
private boolean builtInEdit ( String initialText , Consumer < String > saveHandler , Consumer < String > errorHandler ) { try { ServiceLoader < BuildInEditorProvider > sl = ServiceLoader . load ( BuildInEditorProvider . class ) ; BuildInEditorProvider provider = null ; for ( BuildInEditorProvider p : sl ) { if ( provider == null || p . rank ( ) > provider . rank ( ) ) { provider = p ; } } if ( provider != null ) { provider . edit ( getResourceString ( "jshell.label.editpad" ) , initialText , saveHandler , errorHandler ) ; return true ; } else { errormsg ( "jshell.err.no.builtin.editor" ) ; } } catch ( RuntimeException ex ) { errormsg ( "jshell.err.cant.launch.editor" , ex ) ; } fluffmsg ( "jshell.msg.try.set.editor" ) ; return false ; }
|
start the built - in editor
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.