private < T extends Snippet > Stream < T > argsToSnippets ( Supplier < Stream < T > > snippetSupplier , List < String > args ) { Stream < T > result = null ; for ( String arg : args ) { // Find the best match 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 .