idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
32,100
public static final < T extends Tree > Matcher < T > inSynchronized ( ) { return new Matcher < T > ( ) { public boolean matches ( T tree , VisitorState state ) { SynchronizedTree synchronizedTree = ASTHelpers . findEnclosingNode ( state . getPath ( ) , SynchronizedTree . class ) ; if ( synchronizedTree != null ) { retu...
Matches if this Tree is enclosed by either a synchronized block or a synchronized method .
32,101
public static Matcher < ExpressionTree > sameVariable ( final ExpressionTree expr ) { return new Matcher < ExpressionTree > ( ) { public boolean matches ( ExpressionTree tree , VisitorState state ) { return ASTHelpers . sameVariable ( tree , expr ) ; } } ; }
Matches if this ExpressionTree refers to the same variable as the one passed into the matcher .
32,102
public static Matcher < EnhancedForLoopTree > enhancedForLoop ( final Matcher < VariableTree > variableMatcher , final Matcher < ExpressionTree > expressionMatcher , final Matcher < StatementTree > statementMatcher ) { return new Matcher < EnhancedForLoopTree > ( ) { public boolean matches ( EnhancedForLoopTree t , Vis...
Matches an enhanced for loop if all the given matchers match .
32,103
public static < T extends Tree > Matcher < T > inLoop ( ) { return new Matcher < T > ( ) { public boolean matches ( Tree tree , VisitorState state ) { TreePath path = state . getPath ( ) . getParentPath ( ) ; Tree node = path . getLeaf ( ) ; while ( path != null ) { switch ( node . getKind ( ) ) { case METHOD : case CL...
Matches if the given tree is inside a loop .
32,104
public static Matcher < AssignmentTree > assignment ( final Matcher < ExpressionTree > variableMatcher , final Matcher < ? super ExpressionTree > expressionMatcher ) { return new Matcher < AssignmentTree > ( ) { public boolean matches ( AssignmentTree t , VisitorState state ) { return variableMatcher . matches ( t . ge...
Matches an assignment operator AST node if both of the given matchers match .
32,105
public static Matcher < TypeCastTree > typeCast ( final Matcher < Tree > typeMatcher , final Matcher < ExpressionTree > expressionMatcher ) { return new Matcher < TypeCastTree > ( ) { public boolean matches ( TypeCastTree t , VisitorState state ) { return typeMatcher . matches ( t . getType ( ) , state ) && expressionM...
Matches a type cast AST node if both of the given matchers match .
32,106
public static Matcher < AssertTree > assertionWithCondition ( final Matcher < ExpressionTree > conditionMatcher ) { return new Matcher < AssertTree > ( ) { public boolean matches ( AssertTree tree , VisitorState state ) { return conditionMatcher . matches ( tree . getCondition ( ) , state ) ; } } ; }
Matches an assertion AST node if the given matcher matches its condition .
32,107
public static < T extends Tree , V extends Tree > Matcher < T > contains ( Class < V > clazz , Matcher < V > treeMatcher ) { final Matcher < Tree > contains = new Contains ( toType ( clazz , treeMatcher ) ) ; return contains :: matches ; }
Applies the given matcher recursively to all descendants of an AST node and matches if any matching descendant node is found .
32,108
public static Matcher < MethodTree > methodHasArity ( final int arity ) { return new Matcher < MethodTree > ( ) { public boolean matches ( MethodTree methodTree , VisitorState state ) { return methodTree . getParameters ( ) . size ( ) == arity ; } } ; }
Matches if the method accepts the given number of arguments .
32,109
public static Matcher < ClassTree > isDirectImplementationOf ( String clazz ) { Matcher < Tree > isProvidedType = isSameType ( clazz ) ; return new IsDirectImplementationOf ( isProvidedType ) ; }
Matches any node that is directly an implementation but not extension of the given Class .
32,110
public static < T extends Tree > Matcher < T > packageMatches ( Pattern pattern ) { return ( tree , state ) -> pattern . matcher ( getPackageFullName ( state ) ) . matches ( ) ; }
Matches an AST node whose compilation unit s package name matches the given pattern .
32,111
public static < T extends Tree > Matcher < T > packageStartsWith ( String prefix ) { return ( tree , state ) -> getPackageFullName ( state ) . startsWith ( prefix ) ; }
Matches an AST node whose compilation unit starts with this prefix .
32,112
private JCBlock inlineFinallyBlock ( Inliner inliner ) throws CouldNotResolveImportException { if ( getFinallyBlock ( ) != null ) { JCBlock block = getFinallyBlock ( ) . inline ( inliner ) ; if ( ! block . getStatements ( ) . isEmpty ( ) ) { return block ; } } return null ; }
Skips the finally block if the result would be empty .
32,113
private static boolean isGeneratedFactoryType ( ClassSymbol symbol , VisitorState state ) { return GENERATED_BASE_TYPES . stream ( ) . anyMatch ( baseType -> isGeneratedBaseType ( symbol , state , baseType ) ) ; }
instead of checking for subtypes of generated code
32,114
Violation areFieldsImmutable ( Optional < ClassTree > tree , ImmutableSet < String > immutableTyParams , ClassType classType , ViolationReporter reporter ) { ClassSymbol classSym = ( ClassSymbol ) classType . tsym ; if ( classSym . members ( ) == null ) { return Violation . absent ( ) ; } Filter < Symbol > instanceFiel...
Check a single class fields for immutability .
32,115
private Violation isFieldImmutable ( Optional < Tree > tree , ImmutableSet < String > immutableTyParams , ClassSymbol classSym , ClassType classType , VarSymbol var , ViolationReporter reporter ) { if ( bugChecker . isSuppressed ( var ) ) { return Violation . absent ( ) ; } if ( ! var . getModifiers ( ) . contains ( Mo...
Check a single field for immutability .
32,116
public static Result compile ( DiagnosticListener < JavaFileObject > listener , String [ ] args ) { return ErrorProneCompiler . builder ( ) . listenToDiagnostics ( listener ) . build ( ) . run ( args ) ; }
Compiles in - process .
32,117
public static Result compile ( String [ ] args , PrintWriter out ) { return ErrorProneCompiler . builder ( ) . redirectOutputTo ( out ) . build ( ) . run ( args ) ; }
Programmatic interface to the error - prone Java compiler .
32,118
private static boolean functionalInterfaceReturnsExactlyVoid ( Type interfaceType , VisitorState state ) { return state . getTypes ( ) . findDescriptorType ( interfaceType ) . getReturnType ( ) . getKind ( ) == TypeKind . VOID ; }
Checks that the return value of a functional interface is void . Note we do not use ASTHelpers . isVoidType here return values of Void are actually type - checked . Only void - returning functions silently ignore return values of any type .
32,119
private Description matchInvocation ( ExpressionTree tree , MethodSymbol symbol , List < ? extends ExpressionTree > args , VisitorState state ) { if ( ! ASTHelpers . hasAnnotation ( symbol , FormatMethod . class , state ) ) { return Description . NO_MATCH ; } Type stringType = state . getSymtab ( ) . stringType ; List ...
Matches a method or constructor invocation . The input symbol should match the invoked method or contructor and the args should be the parameters in the invocation .
32,120
private static ImmutableSet < Symbol > lookup ( Symbol . TypeSymbol typeSym , Symbol . TypeSymbol start , Name identifier , Types types , Symbol . PackageSymbol pkg ) { if ( typeSym == null ) { return ImmutableSet . of ( ) ; } ImmutableSet . Builder < Symbol > members = ImmutableSet . builder ( ) ; members . addAll ( l...
to filter on method signature .
32,121
void invalidateAllAlternatives ( Parameter formal ) { for ( int actualIndex = 0 ; actualIndex < costMatrix [ formal . index ( ) ] . length ; actualIndex ++ ) { if ( actualIndex != formal . index ( ) ) { costMatrix [ formal . index ( ) ] [ actualIndex ] = Double . POSITIVE_INFINITY ; } } }
Set the cost of all the alternatives for this formal parameter to be Inf .
32,122
void updatePair ( ParameterPair p , double cost ) { costMatrix [ p . formal ( ) . index ( ) ] [ p . actual ( ) . index ( ) ] = cost ; }
Update the cost of the given pairing .
32,123
public static VisitorState createForUtilityPurposes ( Context context ) { return new VisitorState ( context , VisitorState :: nullListener , ImmutableMap . of ( ) , ErrorProneOptions . empty ( ) , StatisticsCollector . createNoOpCollector ( ) , null , null , SuppressedState . UNSUPPRESSED ) ; }
Return a VisitorState that has no Error Prone configuration and can t report results .
32,124
public static VisitorState createConfiguredForCompilation ( Context context , DescriptionListener listener , Map < String , SeverityLevel > severityMap , ErrorProneOptions errorProneOptions ) { return new VisitorState ( context , listener , severityMap , errorProneOptions , StatisticsCollector . createCollector ( ) , n...
Return a VisitorState configured for a new compilation including Error Prone configuration .
32,125
private static String inferBinaryName ( String classname ) { StringBuilder sb = new StringBuilder ( ) ; boolean first = true ; char sep = '.' ; for ( String bit : Splitter . on ( '.' ) . split ( classname ) ) { if ( ! first ) { sb . append ( sep ) ; } sb . append ( bit ) ; if ( Character . isUpperCase ( bit . charAt ( ...
so it may not end up being a performance win . )
32,126
public Type getType ( Type baseType , boolean isArray , List < Type > typeParams ) { boolean isGeneric = typeParams != null && ! typeParams . isEmpty ( ) ; if ( ! isArray && ! isGeneric ) { return baseType ; } else if ( isArray && ! isGeneric ) { ClassSymbol arraySymbol = getSymtab ( ) . arrayClass ; return new ArrayTy...
Build an instance of a Type .
32,127
@ SuppressWarnings ( "unchecked" ) public final < T extends Tree > T findEnclosing ( Class < ? extends T > ... classes ) { TreePath pathToEnclosing = findPathToEnclosing ( classes ) ; return ( pathToEnclosing == null ) ? null : ( T ) pathToEnclosing . getLeaf ( ) ; }
Find the first enclosing tree node of one of the given types .
32,128
public CharSequence getSourceCode ( ) { try { return getPath ( ) . getCompilationUnit ( ) . getSourceFile ( ) . getCharContent ( false ) ; } catch ( IOException e ) { return null ; } }
Gets the current source file .
32,129
public String getSourceForNode ( Tree tree ) { JCTree node = ( JCTree ) tree ; int start = node . getStartPosition ( ) ; int end = getEndPosition ( node ) ; if ( end < 0 ) { return null ; } return getSourceCode ( ) . subSequence ( start , end ) . toString ( ) ; }
Gets the original source code that represents the given node .
32,130
public int getEndPosition ( Tree node ) { JCCompilationUnit compilationUnit = ( JCCompilationUnit ) getPath ( ) . getCompilationUnit ( ) ; if ( compilationUnit . endPositions == null ) { return - 1 ; } return ( ( JCTree ) node ) . getEndPosition ( compilationUnit . endPositions ) ; }
Returns the end position of the node or - 1 if it is not available .
32,131
private static void validateTypeStr ( String typeStr ) { if ( typeStr . contains ( "[" ) || typeStr . contains ( "]" ) ) { throw new IllegalArgumentException ( String . format ( "Cannot convert array types (%s), please build them using getType()" , typeStr ) ) ; } if ( typeStr . contains ( "<" ) || typeStr . contains (...
Validates a type string ensuring it is not generic and not an array type .
32,132
public static boolean canCompleteNormally ( CaseTree caseTree ) { List < ? extends StatementTree > statements = caseTree . getStatements ( ) ; if ( statements . isEmpty ( ) ) { return true ; } return canCompleteNormally ( getLast ( statements ) ) ; }
Returns true if the given case tree can complete normally as defined by JLS 14 . 21 .
32,133
public static void setupMessageBundle ( Context context ) { ResourceBundle bundle = ResourceBundle . getBundle ( "com.google.errorprone.errors" ) ; JavacMessages . instance ( context ) . add ( l -> bundle ) ; }
Registers our message bundle .
32,134
static MatchedComment match ( Commented < ExpressionTree > actual , String formal ) { Optional < Comment > lastBlockComment = Streams . findLast ( actual . beforeComments ( ) . stream ( ) . filter ( c -> c . getStyle ( ) == CommentStyle . BLOCK ) ) ; if ( lastBlockComment . isPresent ( ) ) { Matcher m = PARAMETER_COMME...
Determine the kind of match we have between the comments on this argument and the formal parameter name .
32,135
public static boolean containsSyntheticParameterName ( MethodSymbol sym ) { return sym . getParameters ( ) . stream ( ) . anyMatch ( p -> SYNTHETIC_PARAMETER_NAME . matcher ( p . getSimpleName ( ) ) . matches ( ) ) ; }
Returns true if the method has synthetic parameter names indicating the real names are not available .
32,136
private Description checkAnnotations ( Tree tree , int treePos , List < ? extends AnnotationTree > annotations , Comment danglingJavadoc , int firstModifierPos , int lastModifierPos , VisitorState state ) { SuggestedFix . Builder builder = SuggestedFix . builder ( ) ; List < AnnotationTree > moveBefore = new ArrayList ...
Checks that annotations are on the right side of the modifiers .
32,137
public static ExpressionTree getArgument ( AnnotationTree annotationTree , String name ) { for ( ExpressionTree argumentTree : annotationTree . getArguments ( ) ) { if ( argumentTree . getKind ( ) != Tree . Kind . ASSIGNMENT ) { continue ; } AssignmentTree assignmentTree = ( AssignmentTree ) argumentTree ; if ( ! assig...
Gets the value for an argument or null if the argument does not exist .
32,138
public boolean isAcceptableChange ( Changes changes , Tree node , MethodSymbol symbol , VisitorState state ) { return findReverseWordsMatchInParentNodes ( state ) == null ; }
Return true if this call is not enclosed in a method call about reversing things
32,139
private static boolean ignore ( MethodTree method , VisitorState state ) { return firstNonNull ( new TreeScanner < Boolean , Void > ( ) { public Boolean visitBlock ( BlockTree tree , Void unused ) { switch ( tree . getStatements ( ) . size ( ) ) { case 0 : return true ; case 1 : return scan ( getOnlyElement ( tree . ge...
Don t flag methods that are empty or trivially delegate to a super - implementation .
32,140
private Fix buildFix ( Tree tree , List < ? extends Tree > arguments , VisitorState state ) { JCTree node = ( JCTree ) tree ; int startAbsolute = node . getStartPosition ( ) ; int lower = ( ( JCTree ) arguments . get ( 0 ) ) . getStartPosition ( ) - startAbsolute ; int upper = state . getEndPosition ( arguments . get (...
Constructor a fix that deletes the set of type arguments .
32,141
private String valueArgumentFromCompatibleWithAnnotation ( AnnotationTree tree ) { ExpressionTree argumentValue = Iterables . getOnlyElement ( tree . getArguments ( ) ) ; if ( argumentValue . getKind ( ) != Kind . ASSIGNMENT ) { return null ; } return ASTHelpers . constValue ( ( ( AssignmentTree ) argumentValue ) . get...
is required .
32,142
public static < T > Choice < T > fromOptional ( Optional < T > optional ) { return optional . isPresent ( ) ? of ( optional . get ( ) ) : Choice . < T > none ( ) ; }
Returns a choice of the optional value if it is present or the empty choice if it is absent .
32,143
public static < T > Choice < T > any ( final Collection < Choice < T > > choices ) { return from ( choices ) . thenChoose ( Functions . < Choice < T > > identity ( ) ) ; }
Returns a choice between any of the options from any of the specified choices .
32,144
public < R > Choice < R > transform ( final Function < ? super T , R > function ) { checkNotNull ( function ) ; final Choice < T > thisChoice = this ; return new Choice < R > ( ) { protected Iterator < R > iterator ( ) { return Iterators . transform ( thisChoice . iterator ( ) , function ) ; } } ; }
Maps the choices with the specified function .
32,145
public static ImmutableList < ErrorProneToken > getTokens ( String source , Context context ) { return new ErrorProneTokens ( source , context ) . getTokens ( ) ; }
Returns the tokens for the given source text including comments .
32,146
private static Matcher < AnnotationTree > hasAnyParameter ( String ... parameters ) { return anyOf ( transform ( asList ( parameters ) , new Function < String , Matcher < AnnotationTree > > ( ) { public Matcher < AnnotationTree > apply ( String parameter ) { return hasArgumentWithValue ( parameter , Matchers . < Expres...
Matches an annotation that has an argument for at least one of the given parameters .
32,147
static SuggestedFix . Builder makeConcreteClassAbstract ( ClassTree classTree , VisitorState state ) { Set < Modifier > flags = EnumSet . noneOf ( Modifier . class ) ; flags . addAll ( classTree . getModifiers ( ) . getFlags ( ) ) ; boolean wasFinal = flags . remove ( FINAL ) ; boolean wasAbstract = ! flags . add ( ABS...
Returns a fix that changes a concrete class to an abstract class .
32,148
public static Optional < SuggestedFix > addModifiers ( Tree tree , VisitorState state , Modifier ... modifiers ) { ModifiersTree originalModifiers = getModifiers ( tree ) ; if ( originalModifiers == null ) { return Optional . empty ( ) ; } return addModifiers ( tree , originalModifiers , state , new TreeSet < > ( Array...
Adds modifiers to the given class method or field declaration .
32,149
public static Optional < SuggestedFix > removeModifiers ( Tree tree , VisitorState state , Modifier ... modifiers ) { Set < Modifier > toRemove = ImmutableSet . copyOf ( modifiers ) ; ModifiersTree originalModifiers = getModifiers ( tree ) ; if ( originalModifiers == null ) { return Optional . empty ( ) ; } return remo...
Remove modifiers from the given class method or field declaration .
32,150
public static String qualifyType ( VisitorState state , SuggestedFix . Builder fix , TypeMirror type ) { return type . accept ( new SimpleTypeVisitor8 < String , SuggestedFix . Builder > ( ) { protected String defaultAction ( TypeMirror e , Builder builder ) { return e . toString ( ) ; } public String visitArray ( Arra...
Returns a human - friendly name of the given type for use in fixes .
32,151
public static SuggestedFix renameMethod ( MethodTree tree , final String replacement , VisitorState state ) { int basePos = ( ( JCTree ) tree ) . getStartPosition ( ) ; int endPos = tree . getBody ( ) != null ? ( ( JCTree ) tree . getBody ( ) ) . getStartPosition ( ) : state . getEndPosition ( tree ) ; List < ErrorPron...
Be warned only changes method name at the declaration .
32,152
public static Fix deleteExceptions ( MethodTree tree , final VisitorState state , List < ExpressionTree > toDelete ) { List < ? extends ExpressionTree > trees = tree . getThrows ( ) ; if ( toDelete . size ( ) == trees . size ( ) ) { return SuggestedFix . replace ( getThrowsPosition ( tree , state ) - 1 , state . getEnd...
Deletes the given exceptions from a method s throws clause .
32,153
public static boolean compilesWithFix ( Fix fix , VisitorState state ) { if ( fix . isEmpty ( ) ) { return true ; } JCCompilationUnit compilationUnit = ( JCCompilationUnit ) state . getPath ( ) . getCompilationUnit ( ) ; JavaFileObject modifiedFile = compilationUnit . getSourceFile ( ) ; BasicJavacTask javacTask = ( Ba...
Returns true if the current compilation would succeed with the given fix applied . Note that calling this method is very expensive as it requires rerunning the entire compile so it should be used with restraint .
32,154
public static Optional < SuggestedFix > suggestWhitelistAnnotation ( String whitelistAnnotation , TreePath where , VisitorState state ) { if ( whitelistAnnotation . equals ( "com.google.errorprone.annotations.DontSuggestFixes" ) ) { return Optional . empty ( ) ; } SuggestedFix . Builder builder = SuggestedFix . builder...
Create a fix to add a suppression annotation on the surrounding class .
32,155
public SuppressedState suppressedState ( Suppressible suppressible , boolean suppressedInGeneratedCode ) { if ( inGeneratedCode && suppressedInGeneratedCode ) { return SuppressedState . SUPPRESSED ; } if ( suppressible . supportsSuppressWarnings ( ) && ! Collections . disjoint ( suppressible . allNames ( ) , suppressWa...
Returns true if this checker should be considered suppressed given the signals present in this object .
32,156
public static TypePredicate isExactTypeAny ( Iterable < String > types ) { return new ExactAny ( Iterables . transform ( types , GET_TYPE ) ) ; }
Match types that are exactly equal to any of the given types .
32,157
public static TypePredicate isDescendantOfAny ( Iterable < String > types ) { return new DescendantOfAny ( Iterables . transform ( types , GET_TYPE ) ) ; }
Match types that are a sub - type of one of the given types .
32,158
private static ExpressionTree stripNullCheck ( ExpressionTree expression , VisitorState state ) { if ( expression != null && expression . getKind ( ) == METHOD_INVOCATION ) { MethodInvocationTree methodInvocation = ( MethodInvocationTree ) expression ; if ( NON_NULL_MATCHER . matches ( methodInvocation , state ) ) { re...
If the given expression is a call to a method checking the nullity of its first parameter and otherwise returns that parameter .
32,159
public List < String > getLines ( ) { try { return CharSource . wrap ( sourceBuilder ) . readLines ( ) ; } catch ( IOException e ) { throw new AssertionError ( "IOException not possible, as the string is in-memory" ) ; } }
Returns a copy of code as a list of lines .
32,160
public void replaceLines ( List < String > lines ) { sourceBuilder . replace ( 0 , sourceBuilder . length ( ) , Joiner . on ( "\n" ) . join ( lines ) + "\n" ) ; }
Replace the source code with the new lines of code .
32,161
public void replaceLines ( int startLine , int endLine , List < String > replacementLines ) { Preconditions . checkArgument ( startLine <= endLine ) ; List < String > originalLines = getLines ( ) ; List < String > newLines = new ArrayList < > ( ) ; for ( int i = 0 ; i < originalLines . size ( ) ; i ++ ) { int lineNum =...
Replace the source code between the start and end lines with some new lines of code .
32,162
public void replaceChars ( int startPosition , int endPosition , String replacement ) { try { sourceBuilder . replace ( startPosition , endPosition , replacement ) ; } catch ( StringIndexOutOfBoundsException e ) { throw new IndexOutOfBoundsException ( String . format ( "Replacement cannot be made. Source file %s has le...
Replace the source code between the start and end character positions with a new string .
32,163
boolean isAssignableTo ( Parameter target , VisitorState state ) { if ( state . getTypes ( ) . isSameType ( type ( ) , Type . noType ) || state . getTypes ( ) . isSameType ( target . type ( ) , Type . noType ) ) { return false ; } try { return state . getTypes ( ) . isAssignable ( type ( ) , target . type ( ) ) ; } cat...
Return true if this parameter is assignable to the target parameter . This will consider subclassing autoboxing and null .
32,164
static String getArgumentName ( ExpressionTree expressionTree ) { switch ( expressionTree . getKind ( ) ) { case MEMBER_SELECT : return ( ( MemberSelectTree ) expressionTree ) . getIdentifier ( ) . toString ( ) ; case NULL_LITERAL : return NAME_NULL ; case IDENTIFIER : IdentifierTree idTree = ( IdentifierTree ) express...
Extract the name from an argument .
32,165
private void buildFix ( Description . Builder builder , MethodInvocationTree tree , VisitorState state ) { MethodInvocationTree mockitoCall = tree ; List < ? extends ExpressionTree > args = mockitoCall . getArguments ( ) ; Tree mock = mockitoCall . getArguments ( ) . get ( 0 ) ; boolean isVerify = ASTHelpers . getSymbo...
Create fixes for invalid assertions .
32,166
public Description matchMethod ( MethodTree methodTree , VisitorState state ) { SuggestedFix . Builder fix = null ; if ( isInjectedConstructor ( methodTree , state ) ) { for ( AnnotationTree annotationTree : methodTree . getModifiers ( ) . getAnnotations ( ) ) { if ( OPTIONAL_INJECTION_MATCHER . matches ( annotationTre...
Matches injected constructors annotated with
32,167
private static List < TypeVariableSymbol > typeVariablesEnclosing ( Symbol sym ) { List < TypeVariableSymbol > typeVarScopes = new ArrayList < > ( ) ; outer : while ( ! sym . isStatic ( ) ) { sym = sym . owner ; switch ( sym . getKind ( ) ) { case PACKAGE : break outer ; case METHOD : case CLASS : typeVarScopes . addAl...
Get list of type params of every enclosing class
32,168
protected List < Type > actualTypes ( Inliner inliner ) { ArrayList < Type > result = new ArrayList < > ( ) ; ImmutableList < String > argNames = expressionArgumentTypes ( ) . keySet ( ) . asList ( ) ; for ( int i = 0 ; i < expressionArgumentTypes ( ) . size ( ) ; i ++ ) { String argName = argNames . get ( i ) ; Option...
Returns a list of the actual types to be matched . This consists of the types of the expressions bound to the
32,169
private Type infer ( Warner warner , Inliner inliner , List < Type > freeTypeVariables , List < Type > expectedArgTypes , Type returnType , List < Type > actualArgTypes ) throws InferException { Symtab symtab = inliner . symtab ( ) ; Type methodType = new MethodType ( expectedArgTypes , returnType , List . < Type > nil...
Returns the inferred method type of the template based on the given actual argument types .
32,170
private boolean populateTypesToEnforce ( MethodSymbol declaredMethod , Type calledMethodType , Type calledReceiverType , List < RequiredType > argumentTypeRequirements , VisitorState state ) { boolean foundAnyTypeToEnforce = false ; List < VarSymbol > params = declaredMethod . params ( ) ; for ( int i = 0 ; i < params ...
caller should explore super - methods .
32,171
public static String classDescriptor ( Type type , Types types ) { SigGen sig = new SigGen ( types ) ; sig . assembleClassSig ( types . erasure ( type ) ) ; return sig . toString ( ) ; }
Returns the binary names of the class .
32,172
public static String descriptor ( Type type , Types types ) { SigGen sig = new SigGen ( types ) ; sig . assembleSig ( types . erasure ( type ) ) ; return sig . toString ( ) ; }
Returns a JVMS 4 . 3 . 3 method descriptor .
32,173
public static String prettyMethodSignature ( ClassSymbol origin , MethodSymbol m ) { StringBuilder sb = new StringBuilder ( ) ; if ( m . isConstructor ( ) ) { Name name = m . owner . enclClass ( ) . getSimpleName ( ) ; if ( name . isEmpty ( ) ) { name = m . owner . enclClass ( ) . getSuperclass ( ) . asElement ( ) . ge...
Pretty - prints a method signature for use in diagnostics .
32,174
private static char [ ] asUnicodeHexEscape ( char c ) { char [ ] r = new char [ 6 ] ; r [ 0 ] = '\\' ; r [ 1 ] = 'u' ; r [ 5 ] = HEX_DIGITS [ c & 0xF ] ; c >>>= 4 ; r [ 4 ] = HEX_DIGITS [ c & 0xF ] ; c >>>= 4 ; r [ 3 ] = HEX_DIGITS [ c & 0xF ] ; c >>>= 4 ; r [ 2 ] = HEX_DIGITS [ c & 0xF ] ; return r ; }
Helper for common case of escaping a single char .
32,175
private static String identifyBadCast ( Type lhs , Type rhs , Types types ) { if ( ! lhs . isPrimitive ( ) ) { return null ; } if ( types . isConvertible ( rhs , lhs ) ) { return null ; } return String . format ( "Compound assignments from %s to %s hide lossy casts" , prettyType ( rhs ) , prettyType ( lhs ) ) ; }
Classifies bad casts .
32,176
private static Optional < Fix > rewriteCompoundAssignment ( CompoundAssignmentTree tree , VisitorState state ) { CharSequence var = state . getSourceForNode ( tree . getVariable ( ) ) ; CharSequence expr = state . getSourceForNode ( tree . getExpression ( ) ) ; if ( var == null || expr == null ) { return Optional . abs...
Desugars a compound assignment making the cast explicit .
32,177
public static Supplier < Type > typeFromString ( final String typeString ) { requireNonNull ( typeString ) ; return new Supplier < Type > ( ) { public Type get ( VisitorState state ) { return state . getTypeFromString ( typeString ) ; } } ; }
Given the string representation of a type supplies the corresponding type .
32,178
public static < T > Supplier < T > identitySupplier ( final T toSupply ) { return new Supplier < T > ( ) { public T get ( VisitorState state ) { return toSupply ; } } ; }
Supplies what was given . Useful for adapting to methods that require a supplier .
32,179
public boolean isAcceptableChange ( Changes changes , Tree node , MethodSymbol symbol , VisitorState state ) { return findArgumentsForOtherInstances ( symbol , node , state ) . stream ( ) . allMatch ( arguments -> ! anyArgumentsMatch ( changes . changedPairs ( ) , arguments ) ) ; }
Returns true if there are no other calls to this method which already have an actual parameter in the position we are moving this one too .
32,180
private static boolean anyArgumentsMatch ( List < ParameterPair > changedPairs , List < Parameter > arguments ) { return changedPairs . stream ( ) . anyMatch ( change -> Objects . equals ( change . actual ( ) . text ( ) , arguments . get ( change . formal ( ) . index ( ) ) . text ( ) ) ) ; }
Return true if the replacement name is equal to the argument name for any replacement position .
32,181
private String methodReferenceDescriptor ( Types types , MethodSymbol sym ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( sym . getSimpleName ( ) ) . append ( '(' ) ; if ( ! sym . isStatic ( ) ) { sb . append ( Signatures . descriptor ( sym . owner . type , types ) ) ; } sym . params ( ) . stream ( ) . map...
Returns a string descriptor of a method s reference type .
32,182
private static boolean localVariableMatches ( VariableTree tree , VisitorState state ) { ExpressionTree expression = tree . getInitializer ( ) ; if ( expression == null ) { Tree leaf = state . getPath ( ) . getParentPath ( ) . getLeaf ( ) ; if ( ! ( leaf instanceof EnhancedForLoopTree ) ) { return true ; } EnhancedForL...
Check to see if the local variable should be considered for replacement i . e .
32,183
ToStringKind isToString ( Tree parent , ExpressionTree tree , VisitorState state ) { if ( isStringConcat ( parent , state ) ) { return ToStringKind . IMPLICIT ; } if ( parent instanceof ExpressionTree ) { ExpressionTree parentExpression = ( ExpressionTree ) parent ; if ( PRINT_STRING . matches ( parentExpression , stat...
Classifies expressions that are converted to strings by their enclosing expression .
32,184
private static boolean newFluentChain ( ExpressionTree tree , VisitorState state ) { while ( tree instanceof MethodInvocationTree && FLUENT_CHAIN . matches ( tree , state ) ) { tree = getReceiver ( tree ) ; } return tree != null && FLUENT_CONSTRUCTOR . matches ( tree , state ) ; }
Whether this is a chain of method invocations terminating in a new proto or collection builder .
32,185
public static boolean isAnnotation ( VisitorState state , Type type ) { return isAssignableTo ( type , Suppliers . ANNOTATION_TYPE , state ) ; }
Returns true if the type is an annotation .
32,186
public String getMessageWithoutCheckName ( ) { return linkUrl != null ? String . format ( "%s\n%s" , rawMessage , linkTextForDiagnostic ( linkUrl ) ) : String . format ( "%s" , rawMessage ) ; }
Returns the message not including the check name but including the link .
32,187
public Description applySeverityOverride ( SeverityLevel severity ) { return new Description ( position , checkName , rawMessage , linkUrl , fixes , severity ) ; }
Internal - only . Has no effect if applied to a Description within a BugChecker .
32,188
public boolean isAcceptableChange ( Changes changes , Tree node , MethodSymbol symbol , VisitorState state ) { int numberOfChanges = changes . changedPairs ( ) . size ( ) ; return changes . totalOriginalCost ( ) - changes . totalAssignmentCost ( ) >= threshold * numberOfChanges ; }
Return true if the change is sufficiently different .
32,189
private static ImmutableList < ImportTree > getWildcardImports ( List < ? extends ImportTree > imports ) { ImmutableList . Builder < ImportTree > result = ImmutableList . builder ( ) ; for ( ImportTree tree : imports ) { Tree ident = tree . getQualifiedIdentifier ( ) ; if ( ! ( ident instanceof MemberSelectTree ) ) { c...
Collect all on demand imports .
32,190
public ImmutableMap < TypeVariableSymbol , Nullness > getNullnessGenerics ( MethodInvocationTree callsite ) { ImmutableMap . Builder < TypeVariableSymbol , Nullness > result = ImmutableMap . builder ( ) ; for ( TypeVariableSymbol tvs : TreeInfo . symbol ( ( JCTree ) callsite . getMethodSelect ( ) ) . getTypeParameters ...
Get inferred nullness qualifiers for method - generic type variables at a callsite . When inference is not possible for a given type variable that type variable is not included in the resulting map .
32,191
public Optional < Nullness > getExprNullness ( ExpressionTree exprTree ) { InferenceVariable iv = TypeArgInferenceVar . create ( ImmutableList . of ( ) , exprTree ) ; return constraintGraph . nodes ( ) . contains ( iv ) ? getNullness ( iv ) : Optional . empty ( ) ; }
Get inferred nullness qualifier for an expression if possible .
32,192
@ SuppressWarnings ( "unchecked" ) public static < T > T fromXml ( Class < T > clazz , String xml ) { T object = ( T ) CLASS_2_XSTREAM_INSTANCE . get ( clazz ) . fromXML ( xml ) ; return object ; }
xml - > pojo
32,193
public static < T > String toXml ( Class < T > clazz , T object ) { return CLASS_2_XSTREAM_INSTANCE . get ( clazz ) . toXML ( object ) ; }
pojo - > xml
32,194
public void processExpires ( ) { long timeNow = System . currentTimeMillis ( ) ; InternalSession sessions [ ] = findSessions ( ) ; int expireHere = 0 ; if ( log . isDebugEnabled ( ) ) log . debug ( "Start expire sessions {} at {} sessioncount {}" , getName ( ) , timeNow , sessions . length ) ; for ( int i = 0 ; i < ses...
Invalidate all sessions that have expired .
32,195
public String getString ( final String key , final Object ... args ) { String value = getString ( key ) ; if ( value == null ) { value = key ; } MessageFormat mf = new MessageFormat ( value ) ; mf . setLocale ( locale ) ; return mf . format ( args , new StringBuffer ( ) , null ) . toString ( ) ; }
Get a string from the underlying resource bundle and format it with the given set of arguments .
32,196
public int lookupIndex ( long entry ) { int ret = map . get ( entry ) ; if ( ret <= 0 && ! growthStopped ) { numEntries ++ ; ret = numEntries ; map . put ( entry , ret ) ; } return ret - 1 ; }
Return - 1 if entry isn t present .
32,197
public void init ( Path configFile ) { String abspath = configFile . toAbsolutePath ( ) . toString ( ) ; System . out . println ( "initialize user dictionary:" + abspath ) ; synchronized ( WordDictionary . class ) { if ( loadedPath . contains ( abspath ) ) return ; DirectoryStream < Path > stream ; try { stream = Files...
for ES to initialize the user dictionary .
32,198
public void wrap ( ImmutableRoaringBitmap r ) { this . roaringBitmap = r ; this . hs = 0 ; this . pos = ( short ) ( this . roaringBitmap . highLowContainer . size ( ) - 1 ) ; this . nextContainer ( ) ; }
Prepares a bitmap for iteration
32,199
protected void appendCopy ( RoaringArray sa , int index ) { extendArray ( 1 ) ; this . keys [ this . size ] = sa . keys [ index ] ; this . values [ this . size ] = sa . values [ index ] . clone ( ) ; this . size ++ ; }
Append copy of the one value from another array