idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
35,300
private Environment checkVariableDeclaration ( Decl . Variable decl , Environment environment ) { // Check type is sensible checkNonEmpty ( decl , environment ) ; // Check type of initialiser. if ( decl . hasInitialiser ( ) ) { SemanticType type = checkExpression ( decl . getInitialiser ( ) , environment ) ; checkIsSub...
Type check a variable declaration statement . In particular when an initialiser is given we must check it is well - formed and that it is a subtype of the declared type .
101
35
35,301
private Environment checkAssign ( Stmt . Assign stmt , Environment environment , EnclosingScope scope ) throws IOException { Tuple < LVal > lvals = stmt . getLeftHandSide ( ) ; Type [ ] types = new Type [ lvals . size ( ) ] ; for ( int i = 0 ; i != lvals . size ( ) ; ++ i ) { types [ i ] = checkLVal ( lvals . get ( i )...
Type check an assignment statement .
134
6
35,302
private Environment checkBreak ( Stmt . Break stmt , Environment environment , EnclosingScope scope ) { // FIXME: need to check environment to the break destination return FlowTypeUtils . BOTTOM ; }
Type check a break statement . This requires propagating the current environment to the block destination to ensure that the actual types of all variables at that point are precise .
45
32
35,303
private Environment checkContinue ( Stmt . Continue stmt , Environment environment , EnclosingScope scope ) { // FIXME: need to check environment to the continue destination return FlowTypeUtils . BOTTOM ; }
Type check a continue statement . This requires propagating the current environment to the block destination to ensure that the actual types of all variables at that point are precise .
45
32
35,304
private Environment checkDebug ( Stmt . Debug stmt , Environment environment , EnclosingScope scope ) { // FIXME: want to refine integer type here Type std_ascii = new Type . Array ( Type . Int ) ; SemanticType type = checkExpression ( stmt . getOperand ( ) , environment ) ; checkIsSubtype ( std_ascii , type , environm...
Type check an assume statement . This requires checking that the expression being printed is well - formed and has string type .
99
23
35,305
private Environment checkDoWhile ( Stmt . DoWhile stmt , Environment environment , EnclosingScope scope ) { // Type check loop body environment = checkBlock ( stmt . getBody ( ) , environment , scope ) ; // Type check invariants checkConditions ( stmt . getInvariant ( ) , true , environment ) ; // Determine and update ...
Type check a do - while statement .
182
8
35,306
public Type checkLVal ( LVal lval , Environment environment ) { Type type ; switch ( lval . getOpcode ( ) ) { case EXPR_variablecopy : type = checkVariableLVal ( ( Expr . VariableAccess ) lval , environment ) ; break ; case EXPR_staticvariable : type = checkStaticVariableLVal ( ( Expr . StaticVariableAccess ) lval , en...
Type check a given lval assuming an initial environment . This returns the largest type which can be safely assigned to the lval . Observe that this type is determined by the declared type of the variable being assigned .
288
43
35,307
public final void checkMultiExpressions ( Tuple < Expr > expressions , Environment environment , Tuple < Type > expected ) { for ( int i = 0 , j = 0 ; i != expressions . size ( ) ; ++ i ) { Expr expression = expressions . get ( i ) ; switch ( expression . getOpcode ( ) ) { case EXPR_invoke : { Tuple < Type > results = ...
Type check a sequence of zero or more multi - expressions assuming a given initial environment . A multi - expression is one which may have multiple return values . There are relatively few situations where this can arise particular assignments and return statements . This returns a sequence of one or more pairs each o...
459
79
35,308
private SemanticType checkConstant ( Expr . Constant expr , Environment env ) { Value item = expr . getValue ( ) ; switch ( item . getOpcode ( ) ) { case ITEM_null : return Type . Null ; case ITEM_bool : return Type . Bool ; case ITEM_int : return Type . Int ; case ITEM_byte : return Type . Byte ; case ITEM_utf8 : // F...
Check the type of a given constant expression . This is straightforward since the determine is fully determined by the kind of constant we have .
167
26
35,309
private SemanticType checkVariable ( Expr . VariableAccess expr , Environment environment ) { Decl . Variable var = expr . getVariableDeclaration ( ) ; return environment . getType ( var ) ; }
Check the type of a given variable access . This is straightforward since the determine is fully determined by the declared type for the variable in question .
42
28
35,310
private SemanticType checkIntegerOperator ( Expr . BinaryOperator expr , Environment environment ) { checkOperand ( Type . Int , expr . getFirstOperand ( ) , environment ) ; checkOperand ( Type . Int , expr . getSecondOperand ( ) , environment ) ; return Type . Int ; }
Check the type for a given arithmetic operator . Such an operator has the type int and all children should also produce values of type int .
67
27
35,311
private void checkNonEmpty ( Tuple < Decl . Variable > decls , LifetimeRelation lifetimes ) { for ( int i = 0 ; i != decls . size ( ) ; ++ i ) { checkNonEmpty ( decls . get ( i ) , lifetimes ) ; } }
Check a given set of variable declarations are not empty . That is their declared type is not equivalent to void .
61
22
35,312
private void checkNonEmpty ( Decl . Variable d , LifetimeRelation lifetimes ) { if ( relaxedSubtypeOperator . isVoid ( d . getType ( ) , lifetimes ) ) { syntaxError ( d . getType ( ) , EMPTY_TYPE ) ; } }
Check that a given variable declaration is not empty . That is the declared type is not equivalent to void . This is an important sanity check .
60
28
35,313
public SemanticType . Array extractArrayType ( SemanticType type , Environment environment , ReadWriteTypeExtractor . Combinator < SemanticType . Array > combinator , SyntacticItem item ) { // if ( type != null ) { SemanticType . Array sourceArrayT = rwTypeExtractor . apply ( type , environment , combinator ) ; // if (...
From an arbitrary type extract the array type it represents which is either readable or writeable depending on the context .
113
22
35,314
public SemanticType extractElementType ( SemanticType . Array type , SyntacticItem item ) { if ( type == null ) { return null ; } else { return type . getElement ( ) ; } }
Extract the element type from an array . The array type can be null if some earlier part of type checking generated an error message and we are just continuing after that .
44
34
35,315
public SemanticType . Record extractRecordType ( SemanticType type , Environment environment , ReadWriteTypeExtractor . Combinator < SemanticType . Record > combinator , SyntacticItem item ) { // if ( type != null ) { SemanticType . Record recordT = rwTypeExtractor . apply ( type , environment , combinator ) ; // if ( ...
From an arbitrary type extract the record type it represents which is either readable or writeable depending on the context .
110
22
35,316
public SemanticType extractFieldType ( SemanticType . Record type , Identifier field ) { if ( type == null ) { return null ; } else { SemanticType fieldType = type . getField ( field ) ; if ( fieldType == null ) { // Indicates an invalid field selection syntaxError ( field , INVALID_FIELD ) ; } return fieldType ; } }
From a given record type extract type for a given field .
81
12
35,317
public SemanticType . Reference extractReferenceType ( SemanticType type , Environment environment , ReadWriteTypeExtractor . Combinator < SemanticType . Reference > combinator , SyntacticItem item ) { // if ( type != null ) { SemanticType . Reference refT = rwTypeExtractor . apply ( type , environment , combinator ) ;...
From an arbitrary type extract the reference type it represents which is either readable or writeable depending on the context .
112
22
35,318
public SemanticType extractElementType ( SemanticType . Reference type , SyntacticItem item ) { if ( type == null ) { return null ; } else { return type . getElement ( ) ; } }
Extract the element type from a reference . The array type can be null if some earlier part of type checking generated an error message and we are just continuing after that .
44
34
35,319
public Type . Callable extractLambdaType ( SemanticType type , Environment environment , ReadWriteTypeExtractor . Combinator < Type . Callable > combinator , SyntacticItem item ) { // if ( type != null ) { Type . Callable refT = rwTypeExtractor . apply ( type , environment , combinator ) ; // if ( refT == null ) { synt...
From an arbitrary type extract the lambda type it represents which is either readable or writeable depending on the context .
111
22
35,320
public List < Token > scan ( ) { ArrayList < Token > tokens = new ArrayList <> ( ) ; pos = 0 ; while ( pos < input . length ( ) ) { char c = input . charAt ( pos ) ; if ( isDigit ( c ) ) { tokens . add ( scanNumericLiteral ( ) ) ; } else if ( c == ' ' ) { tokens . add ( scanStringLiteral ( ) ) ; } else if ( c == ' ' ) ...
Scan all characters from the input stream and generate a corresponding list of tokens whilst discarding all whitespace and comments .
214
23
35,321
public Token scanIndent ( ) { int start = pos ; while ( pos < input . length ( ) && ( input . charAt ( pos ) == ' ' || input . charAt ( pos ) == ' ' ) ) { pos ++ ; } return new Token ( Token . Kind . Indent , input . substring ( start , pos ) , start ) ; }
Scan one or more spaces or tab characters combining them to form an indent .
77
15
35,322
public void skipWhitespace ( List < Token > tokens ) { while ( pos < input . length ( ) && ( input . charAt ( pos ) == ' ' || input . charAt ( pos ) == ' ' ) ) { pos ++ ; } }
Skip over any whitespace at the current index position in the input string .
54
15
35,323
private static WyilFile compile ( List < Path . Entry < WhileyFile > > sources , Path . Entry < WyilFile > target ) throws IOException { // Read target WyilFile. This may have already been compiled in a previous run // and, in such case, we are invalidating some or all of the existing file. WyilFile wyil = target . rea...
Compile one or more WhileyFiles into a given WyilFile
204
14
35,324
public boolean contains ( QualifiedName name ) { Name unit = name . getUnit ( ) ; // Get information associated with this unit SymbolTable . Group group = symbolTable . get ( unit ) ; return group != null && group . isValid ( name . getName ( ) ) ; }
Check whether a given name is registered . That is whether or not there is a corresponding name or not .
60
21
35,325
public boolean isAvailable ( QualifiedName name ) { SymbolTable . Group group = symbolTable . get ( name . getUnit ( ) ) ; return group != null && group . isAvailable ( name . getName ( ) ) ; }
Check whether a given symbol is currently external to the enclosing WyilFile . Specifically this indicates whether or not a stub is available for it .
49
29
35,326
public List < Decl . Named > getRegisteredDeclarations ( QualifiedName name ) { Group g = symbolTable . get ( name . getUnit ( ) ) ; if ( g != null ) { return g . getRegisteredDeclarations ( name . getName ( ) ) ; } else { return Collections . EMPTY_LIST ; } }
Get the actual declarations associated with a given symbol .
70
10
35,327
public void addAvailable ( QualifiedName name , List < Decl . Named > available ) { ExternalGroup group = ( ExternalGroup ) symbolTable . get ( name . getUnit ( ) ) ; // for ( int i = 0 ; i != available . size ( ) ; ++ i ) { group . addAvailable ( available . get ( i ) ) ; } }
Make available declarations for an external symbol . This makes those declarations available within the target for linking .
75
19
35,328
public void consolidate ( ) { Decl . Module module = target . getModule ( ) ; for ( ExternalGroup group : consolidations ) { // TODO: this could be made way more efficient by collecting all consolidate // units into one batch module . putExtern ( group . consolidate ( ) ) ; } consolidations . clear ( ) ; }
Consolidate the status of external symbols . For example this will ensure all external units which have imported symbols are made available . Likewise it may garbage collect available symbols and units which are no longer required .
70
40
35,329
private Type . Field [ ] determinePivotFields ( Tuple < Type . Field > lhsFields , Tuple < Type . Field > rhsFields , LifetimeRelation lifetimes , LinkageStack stack ) { Type . Field [ ] pivots = new Type . Field [ lhsFields . size ( ) ] ; // for ( int i = 0 ; i != lhsFields . size ( ) ; ++ i ) { Type . Field lhsField ...
Find all pivots between the lhs and rhs fields and calculate their types .
294
17
35,330
@ Override public ControlFlow visitBlock ( Stmt . Block block , DefinitelyAssignedSet environment ) { DefinitelyAssignedSet nextEnvironment = environment ; DefinitelyAssignedSet breakEnvironment = null ; for ( int i = 0 ; i != block . size ( ) ; ++ i ) { Stmt s = block . get ( i ) ; ControlFlow nf = visitStatement ( s ...
Check that all variables used in a given list of statements are definitely assigned . Furthermore update the set of definitely assigned variables to include any which are definitely assigned at the end of these statements .
146
37
35,331
public static void syntaxError ( SyntacticItem e , int code , SyntacticItem ... context ) { WyilFile wf = ( WyilFile ) e . getHeap ( ) ; // Allocate syntax error in the heap)); SyntacticItem . Marker m = wf . allocate ( new WyilFile . SyntaxError ( code , e , new Tuple <> ( context ) ) ) ; // Record marker to ensure it...
Report an error message . This may additionally sanity check the supplied context .
111
14
35,332
private RValue [ ] packReturns ( CallStack frame , Decl . Callable decl ) { if ( decl instanceof Decl . Property ) { return new RValue [ ] { RValue . True } ; } else { Tuple < Decl . Variable > returns = decl . getReturns ( ) ; RValue [ ] values = new RValue [ returns . size ( ) ] ; for ( int i = 0 ; i != values . leng...
Given an execution frame extract the return values from a given function or method . The parameters of the function or method are located first in the frame followed by the return values .
124
34
35,333
private Status executeBlock ( Stmt . Block block , CallStack frame , EnclosingScope scope ) { for ( int i = 0 ; i != block . size ( ) ; ++ i ) { Stmt stmt = block . get ( i ) ; Status r = executeStatement ( stmt , frame , scope ) ; // Now, see whether we are continuing or not if ( r != Status . NEXT ) { return r ; } } ...
Execute a given block of statements starting from the beginning . Control may terminate prematurely in a number of situations . For example when a return or break statement is encountered .
97
33
35,334
private Status executeStatement ( Stmt stmt , CallStack frame , EnclosingScope scope ) { switch ( stmt . getOpcode ( ) ) { case WyilFile . STMT_assert : return executeAssert ( ( Stmt . Assert ) stmt , frame , scope ) ; case WyilFile . STMT_assume : return executeAssume ( ( Stmt . Assume ) stmt , frame , scope ) ; case ...
Execute a statement at a given point in the function or method body
578
14
35,335
private Status executeBreak ( Stmt . Break stmt , CallStack frame , EnclosingScope scope ) { // TODO: the break bytecode supports a non-nearest exit and eventually // this should be supported. return Status . BREAK ; }
Execute a break statement . This transfers to control out of the nearest enclosing loop .
53
18
35,336
private Status executeContinue ( Stmt . Continue stmt , CallStack frame , EnclosingScope scope ) { return Status . CONTINUE ; }
Execute a continue statement . This transfers to control back to the start the nearest enclosing loop .
30
20
35,337
private Status executeDebug ( Stmt . Debug stmt , CallStack frame , EnclosingScope scope ) { // // FIXME: need to do something with this RValue . Array arr = executeExpression ( ARRAY_T , stmt . getOperand ( ) , frame ) ; for ( RValue item : arr . getElements ( ) ) { RValue . Int i = ( RValue . Int ) item ; char c = ( ...
Execute a Debug statement at a given point in the function or method body . This will write the provided string out to the debug stream .
118
28
35,338
private Status executeFail ( Stmt . Fail stmt , CallStack frame , EnclosingScope scope ) { throw new AssertionError ( "Runtime fault occurred" ) ; }
Execute a fail statement at a given point in the function or method body . This will generate a runtime fault .
38
23
35,339
private Status executeIf ( Stmt . IfElse stmt , CallStack frame , EnclosingScope scope ) { RValue . Bool operand = executeExpression ( BOOL_T , stmt . getCondition ( ) , frame ) ; if ( operand == RValue . True ) { // branch taken, so execute true branch return executeBlock ( stmt . getTrueBranch ( ) , frame , scope ) ;...
Execute an if statement at a given point in the function or method body . This will proceed done either the true or false branch .
143
27
35,340
private Status executeNamedBlock ( Stmt . NamedBlock stmt , CallStack frame , EnclosingScope scope ) { return executeBlock ( stmt . getBlock ( ) , frame , scope ) ; }
Execute a named block which is simply a block of statements .
44
13
35,341
private Status executeWhile ( Stmt . While stmt , CallStack frame , EnclosingScope scope ) { Status r ; do { RValue . Bool operand = executeExpression ( BOOL_T , stmt . getCondition ( ) , frame ) ; if ( operand == RValue . False ) { return Status . NEXT ; } // Keep executing the loop body until we exit it somehow. r = ...
Execute a While statement at a given point in the function or method body . This will loop over the body zero or more times .
166
27
35,342
private Status executeReturn ( Stmt . Return stmt , CallStack frame , EnclosingScope scope ) { // We know that a return statement can only appear in either a function // or method declaration. It cannot appear, for example, in a type // declaration. Therefore, the enclosing declaration is a function or // method. Decl ...
Execute a Return statement at a given point in the function or method body
182
15
35,343
private Status executeSkip ( Stmt . Skip stmt , CallStack frame , EnclosingScope scope ) { // skip ! return Status . NEXT ; }
Execute a skip statement at a given point in the function or method body
32
15
35,344
private Status executeSwitch ( Stmt . Switch stmt , CallStack frame , EnclosingScope scope ) { Tuple < Stmt . Case > cases = stmt . getCases ( ) ; // Object value = executeExpression ( ANY_T , stmt . getCondition ( ) , frame ) ; for ( int i = 0 ; i != cases . size ( ) ; ++ i ) { Stmt . Case c = cases . get ( i ) ; Stmt...
Execute a Switch statement at a given point in the function or method body
216
15
35,345
private Status executeVariableDeclaration ( Decl . Variable stmt , CallStack frame ) { // We only need to do something if this has an initialiser if ( stmt . hasInitialiser ( ) ) { RValue value = executeExpression ( ANY_T , stmt . getInitialiser ( ) , frame ) ; frame . putLocal ( stmt . getName ( ) , value ) ; } return...
Execute a variable declaration statement at a given point in the function or method body
90
16
35,346
private RValue executeConst ( Expr . Constant expr , CallStack frame ) { Value v = expr . getValue ( ) ; switch ( v . getOpcode ( ) ) { case ITEM_null : return RValue . Null ; case ITEM_bool : { Value . Bool b = ( Value . Bool ) v ; if ( b . get ( ) ) { return RValue . True ; } else { return RValue . False ; } } case I...
Execute a Constant expression at a given point in the function or method body
295
15
35,347
private RValue executeConvert ( Expr . Cast expr , CallStack frame ) { RValue operand = executeExpression ( ANY_T , expr . getOperand ( ) , frame ) ; return operand . convert ( expr . getType ( ) ) ; }
Execute a type conversion at a given point in the function or method body
57
15
35,348
private boolean executeQuantifier ( int index , Expr . Quantifier expr , CallStack frame ) { Tuple < Decl . Variable > vars = expr . getParameters ( ) ; if ( index == vars . size ( ) ) { // This is the base case where we evaluate the condition itself. RValue . Bool r = executeExpression ( BOOL_T , expr . getOperand ( )...
Execute one range of the quantifier or the body if no ranges remain .
258
16
35,349
private RValue executeVariableAccess ( Expr . VariableAccess expr , CallStack frame ) { Decl . Variable decl = expr . getVariableDeclaration ( ) ; return frame . getLocal ( decl . getName ( ) ) ; }
Execute a variable access expression at a given point in the function or method body . This simply loads the value of the given variable from the frame .
48
30
35,350
private RValue [ ] executeExpressions ( Tuple < Expr > expressions , CallStack frame ) { RValue [ ] [ ] results = new RValue [ expressions . size ( ) ] [ ] ; int count = 0 ; for ( int i = 0 ; i != expressions . size ( ) ; ++ i ) { results [ i ] = executeMultiReturnExpression ( expressions . get ( i ) , frame ) ; count ...
Execute one or more expressions . This is slightly more complex than for the single expression case because of the potential to encounter positional operands . That is severals which arise from executing the same expression .
174
40
35,351
private RValue [ ] executeMultiReturnExpression ( Expr expr , CallStack frame ) { switch ( expr . getOpcode ( ) ) { case WyilFile . EXPR_indirectinvoke : return executeIndirectInvoke ( ( Expr . IndirectInvoke ) expr , frame ) ; case WyilFile . EXPR_invoke : return executeInvoke ( ( Expr . Invoke ) expr , frame ) ; case...
Execute an expression which has the potential to return more than one result . Thus the return type must accommodate this by allowing zero or more returned values .
201
30
35,352
private RValue [ ] executeIndirectInvoke ( Expr . IndirectInvoke expr , CallStack frame ) { RValue . Lambda src = executeExpression ( LAMBDA_T , expr . getSource ( ) , frame ) ; RValue [ ] arguments = executeExpressions ( expr . getArguments ( ) , frame ) ; // Here we have to use the enclosing frame when the lambda was...
Execute an IndirectInvoke bytecode instruction at a given point in the function or method body . This first checks the operand is a function reference and then generates a recursive call to execute the given function . If the function does not exist or is provided with the wrong number of arguments then a runtime fault...
253
65
35,353
private RValue [ ] executeInvoke ( Expr . Invoke expr , CallStack frame ) { // Resolve function or method being invoked to a concrete declaration Decl . Callable decl = expr . getLink ( ) . getTarget ( ) ; // Evaluate argument expressions RValue [ ] arguments = executeExpressions ( expr . getOperands ( ) , frame ) ; //...
Execute an Invoke bytecode instruction at a given point in the function or method body . This generates a recursive call to execute the given function . If the function does not exist or is provided with the wrong number of arguments then a runtime fault will occur .
119
52
35,354
private LValue constructLVal ( Expr expr , CallStack frame ) { switch ( expr . getOpcode ( ) ) { case EXPR_arrayborrow : case EXPR_arrayaccess : { Expr . ArrayAccess e = ( Expr . ArrayAccess ) expr ; LValue src = constructLVal ( e . getFirstOperand ( ) , frame ) ; RValue . Int index = executeExpression ( INT_T , e . ge...
This method constructs a mutable representation of the lval . This is a bit strange but is necessary because values in the frame are currently immutable .
321
29
35,355
@ SafeVarargs public static < T extends RValue > T checkType ( RValue operand , SyntacticItem context , Class < T > ... types ) { // Got through each type in turn checking for a match for ( int i = 0 ; i != types . length ; ++ i ) { if ( types [ i ] . isInstance ( operand ) ) { // Matched! return ( T ) operand ; } } //...
Check that a given operand value matches an expected type .
164
12
35,356
public String getCompileTargetVersion ( ) { // TODO: Add support for maven.compiler.release // maven-plugin-compiler default is 1.5 String javaVersion = "1.5" ; if ( mavenProject != null ) { // check the maven.compiler.target property first String mavenCompilerTargetProperty = mavenProject . getProperties ( ) . getProp...
Determines the Java compiler target version by inspecting the project s maven - compiler - plugin configuration .
237
21
35,357
public void run ( ) throws MojoExecutionException { try { runMojo . getAppEngineFactory ( ) . devServerRunSync ( ) . run ( configBuilder . buildRunConfiguration ( processServices ( ) , processProjectId ( ) ) ) ; } catch ( AppEngineException ex ) { throw new MojoExecutionException ( "Failed to run devappserver" , ex ) ;...
Run the dev appserver .
86
6
35,358
public void runAsync ( int startSuccessTimeout ) throws MojoExecutionException { runMojo . getLog ( ) . info ( "Waiting " + startSuccessTimeout + " seconds for the Dev App Server to start." ) ; try { runMojo . getAppEngineFactory ( ) . devServerRunAsync ( startSuccessTimeout ) . run ( configBuilder . buildRunConfigurat...
Run the dev appserver in async mode .
163
9
35,359
public String getProjectId ( ) { if ( project != null ) { if ( projectId != null ) { throw new IllegalArgumentException ( "Configuring <project> and <projectId> is not allowed, please use only <projectId>" ) ; } getLog ( ) . warn ( "Configuring <project> is deprecated," + " use <projectId> to set your Google Cloud Proj...
Return projectId from either projectId or project . Show deprecation message if configured as project and throw error if both specified .
97
26
35,360
public String getProjectId ( ) { try { String gcloudProject = gcloud . getConfig ( ) . getProject ( ) ; if ( gcloudProject == null || gcloudProject . trim ( ) . isEmpty ( ) ) { throw new RuntimeException ( "Project was not found in gcloud config" ) ; } return gcloudProject ; } catch ( CloudSdkNotFoundException | CloudS...
Return gcloud config property for project or error out if not found .
129
14
35,361
public void checkCloudSdk ( CloudSdk cloudSdk , String version ) throws CloudSdkVersionFileException , CloudSdkNotFoundException , CloudSdkOutOfDateException { if ( ! version . equals ( cloudSdk . getVersion ( ) . toString ( ) ) ) { throw new RuntimeException ( "Specified Cloud SDK version (" + version + ") does not ma...
Validates the cloud SDK installation
113
6
35,362
public Gcloud getGcloud ( ) { return Gcloud . builder ( buildCloudSdkMinimal ( ) ) . setMetricsEnvironment ( mojo . getArtifactId ( ) , mojo . getArtifactVersion ( ) ) . setCredentialFile ( mojo . getServiceAccountKeyFile ( ) ) . build ( ) ; }
Return a Gcloud instance using global configuration .
74
9
35,363
public List < Path > getServices ( ) { return ( services == null ) ? null : services . stream ( ) . map ( File :: toPath ) . collect ( Collectors . toList ( ) ) ; }
Return a list of Paths but can return also return an empty list or null .
45
17
35,364
public void deployAll ( ) throws MojoExecutionException { stager . stage ( ) ; ImmutableList . Builder < Path > computedDeployables = ImmutableList . builder ( ) ; // Look for app.yaml Path appYaml = deployMojo . getStagingDirectory ( ) . resolve ( "app.yaml" ) ; if ( ! Files . exists ( appYaml ) ) { throw new MojoExec...
Deploy a single application and any found yaml configuration files .
353
12
35,365
public void deployCron ( ) throws MojoExecutionException { stager . stage ( ) ; try { deployMojo . getAppEngineFactory ( ) . deployment ( ) . deployCron ( configBuilder . buildDeployProjectConfigurationConfiguration ( appengineDirectory ) ) ; } catch ( AppEngineException ex ) { throw new MojoExecutionException ( "Faile...
Deploy only cron . yaml .
86
8
35,366
static Function < String , ManagedCloudSdk > newManagedSdkFactory ( ) { return ( version ) - > { try { if ( Strings . isNullOrEmpty ( version ) ) { return ManagedCloudSdk . newManagedSdk ( ) ; } else { return ManagedCloudSdk . newManagedSdk ( new Version ( version ) ) ; } } catch ( UnsupportedOsException | BadCloudSdkV...
for delayed instantiation because it can error unnecessarily
111
9
35,367
public List < Path > getExtraFilesDirectories ( ) { return extraFilesDirectories == null ? null : extraFilesDirectories . stream ( ) . map ( File :: toPath ) . collect ( Collectors . toList ( ) ) ; }
Returns a nullable list of Path to user configured extra files directories .
52
14
35,368
@ Nullable public String getUrl ( ) { if ( getRepositoryUrl ( ) == null ) return null ; return getRepositoryUrl ( ) + "/" + getGroupId ( ) . replace ( ' ' , ' ' ) + "/" + getArtifactId ( ) + "/" + getVersion ( ) + "/" + getFileNameWithBaseVersion ( ) ; }
URL of the artifact on the maven repository on which it has been deployed if it has been deployed .
81
21
35,369
@ Override public void stop ( Throwable cause ) throws Exception { stopping = true ; if ( task != null ) { task . cancel ( true ) ; } super . stop ( cause ) ; }
If the computation is going synchronously try to cancel that .
41
12
35,370
@ Nonnull public static List < MavenArtifact > isSameCause ( MavenDependencyCause newMavenCause , Cause oldMavenCause ) { if ( ! ( oldMavenCause instanceof MavenDependencyCause ) ) { return Collections . emptyList ( ) ; } List < MavenArtifact > newCauseArtifacts = Preconditions . checkNotNull ( newMavenCause . getMaven...
Return matching artifact if the given causes refer to common Maven artifact . Empty list if there are no matching artifact
462
22
35,371
private void setupJDK ( ) throws AbortException , IOException , InterruptedException { String jdkInstallationName = step . getJdk ( ) ; if ( StringUtils . isEmpty ( jdkInstallationName ) ) { console . println ( "[withMaven] using JDK installation provided by the build agent" ) ; return ; } if ( withContainer ) { // see...
Setup the selected JDK . If none is provided nothing is done .
369
14
35,372
@ Nullable private String readFromProcess ( String ... args ) throws InterruptedException { try ( ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ) { ProcStarter ps = launcher . launch ( ) ; Proc p = launcher . launch ( ps . cmds ( args ) . stdout ( baos ) ) ; int exitCode = p . join ( ) ; if ( exitCode == 0...
Executes a command and reads the result to a string . It uses the launcher to run the command to make sure the launcher decorator is used ie . docker . image step
198
35
35,373
private FilePath createWrapperScript ( FilePath tempBinDir , String name , String content ) throws IOException , InterruptedException { FilePath scriptFile = tempBinDir . child ( name ) ; envOverride . put ( MVN_CMD , scriptFile . getRemote ( ) ) ; scriptFile . write ( content , getComputer ( ) . getDefaultCharset ( ) ...
Creates the actual wrapper script file and sets the permissions .
104
12
35,374
@ Nullable private String setupMavenLocalRepo ( ) throws IOException , InterruptedException { String expandedMavenLocalRepo ; if ( StringUtils . isEmpty ( step . getMavenLocalRepo ( ) ) ) { expandedMavenLocalRepo = null ; } else { // resolve relative/absolute with workspace as base String expandedPath = envOverride . e...
Sets the maven repo location according to the provided parameter on the agent
228
15
35,375
private void globalSettingsFromConfig ( String mavenGlobalSettingsConfigId , FilePath mavenGlobalSettingsFile , Collection < Credentials > credentials ) throws AbortException { Config c = ConfigFiles . getByIdOrNull ( build , mavenGlobalSettingsConfigId ) ; if ( c == null ) { throw new AbortException ( "Could not find ...
Reads the global config file from Config File Provider expands the credentials and stores it in a file on the temp folder to use it with the maven wrapper script
706
32
35,376
@ Nonnull private Computer getComputer ( ) throws AbortException { if ( computer != null ) { return computer ; } String node = null ; Jenkins j = Jenkins . getInstance ( ) ; for ( Computer c : j . getComputers ( ) ) { if ( c . getChannel ( ) == launcher . getChannel ( ) ) { node = c . getName ( ) ; break ; } } if ( nod...
Gets the computer for the current launcher .
232
9
35,377
protected DialectFactory createDialectFactory ( ) { DialectFactoryImpl factory = new DialectFactoryImpl ( ) ; factory . injectServices ( new ServiceRegistryImplementor ( ) { @ Override public < R extends Service > R getService ( Class < R > serviceRole ) { if ( serviceRole == DialectResolver . class ) { return ( R ) ne...
should be using the ServiceRegistry but getting it from the SessionFactory at startup fails in Spring
243
19
35,378
protected boolean matchesFilter ( MetadataReader reader , MetadataReaderFactory readerFactory ) throws IOException { for ( TypeFilter filter : ENTITY_TYPE_FILTERS ) { if ( filter . match ( reader , readerFactory ) ) { return true ; } } return false ; }
Check whether any of the configured entity type filters matches the current class descriptor contained in the metadata reader .
59
20
35,379
public long deleteAll ( final QueryableCriteria criteria ) { return getHibernateTemplate ( ) . execute ( ( GrailsHibernateTemplate . HibernateCallback < Integer > ) session -> { JpaQueryBuilder builder = new JpaQueryBuilder ( criteria ) ; builder . setConversionService ( getMappingContext ( ) . getConversionService ( )...
Deletes all objects matching the given criteria .
362
9
35,380
public long updateAll ( final QueryableCriteria criteria , final Map < String , Object > properties ) { return getHibernateTemplate ( ) . execute ( ( GrailsHibernateTemplate . HibernateCallback < Integer > ) session -> { JpaQueryBuilder builder = new JpaQueryBuilder ( criteria ) ; builder . setConversionService ( getMa...
Updates all objects matching the given criteria and property values .
489
12
35,381
public static boolean isAtLeastVersion ( String required ) { String hibernateVersion = Hibernate . class . getPackage ( ) . getImplementationVersion ( ) ; if ( hibernateVersion != null ) { return GrailsVersion . isAtLeast ( hibernateVersion , required ) ; } else { return false ; } }
Check the current hibernate version
74
7
35,382
@ Deprecated public static Query createQuery ( Session session , String query ) { return session . createQuery ( query ) ; }
Creates a query
26
4
35,383
private static PersistentProperty getGrailsDomainClassProperty ( AbstractHibernateDatastore datastore , Class < ? > targetClass , String propertyName ) { PersistentEntity grailsClass = datastore != null ? datastore . getMappingContext ( ) . getPersistentEntity ( targetClass . getName ( ) ) : null ; if ( grailsClass == ...
Get hold of the GrailsDomainClassProperty represented by the targetClass propertyName assuming targetClass corresponds to a GrailsDomainClass .
129
27
35,384
public static void cacheCriteriaByMapping ( Class < ? > targetClass , Criteria criteria ) { Mapping m = GrailsDomainBinder . getMapping ( targetClass ) ; if ( m != null && m . getCache ( ) != null && m . getCache ( ) . getEnabled ( ) ) { criteria . setCacheable ( true ) ; } }
Configures the criteria instance to cache based on the configured mapping .
79
13
35,385
public static FetchMode getFetchMode ( Object object ) { String name = object != null ? object . toString ( ) : "default" ; if ( name . equalsIgnoreCase ( FetchMode . JOIN . toString ( ) ) || name . equalsIgnoreCase ( "eager" ) ) { return FetchMode . JOIN ; } if ( name . equalsIgnoreCase ( FetchMode . SELECT . toString...
Retrieves the fetch mode for the specified instance ; otherwise returns the default FetchMode .
129
19
35,386
public static void setObjectToReadyOnly ( Object target , SessionFactory sessionFactory ) { Object resource = TransactionSynchronizationManager . getResource ( sessionFactory ) ; if ( resource != null ) { Session session = sessionFactory . getCurrentSession ( ) ; if ( canModifyReadWriteState ( session , target ) ) { if...
Sets the target object to read - only using the given SessionFactory instance . This avoids Hibernate performing any dirty checking on the object
145
29
35,387
public static void setObjectToReadWrite ( final Object target , SessionFactory sessionFactory ) { Session session = sessionFactory . getCurrentSession ( ) ; if ( ! canModifyReadWriteState ( session , target ) ) { return ; } SessionImplementor sessionImpl = ( SessionImplementor ) session ; EntityEntry ee = sessionImpl ....
Sets the target object to read - write allowing Hibernate to dirty check it and auto - flush changes .
201
24
35,388
public static void incrementVersion ( Object target ) { MetaClass metaClass = GroovySystem . getMetaClassRegistry ( ) . getMetaClass ( target . getClass ( ) ) ; if ( metaClass . hasProperty ( target , GormProperties . VERSION ) != null ) { Object version = metaClass . getProperty ( target , GormProperties . VERSION ) ;...
Increments the entities version number in order to force an update
123
12
35,389
@ Deprecated public static void ensureCorrectGroovyMetaClass ( Object target , Class < ? > persistentClass ) { if ( target instanceof GroovyObject ) { GroovyObject go = ( ( GroovyObject ) target ) ; if ( ! go . getMetaClass ( ) . getTheClass ( ) . equals ( persistentClass ) ) { go . setMetaClass ( GroovySystem . getMet...
Ensures the meta class is correct for a given class
102
12
35,390
public static HibernateProxy getAssociationProxy ( Object obj , String associationName ) { return proxyHandler . getAssociationProxy ( obj , associationName ) ; }
Returns the proxy for a given association or null if it is not proxied
36
15
35,391
public void enableMultiTenancyFilter ( ) { Serializable currentId = Tenants . currentId ( this ) ; if ( ConnectionSource . DEFAULT . equals ( currentId ) ) { disableMultiTenancyFilter ( ) ; } else { getHibernateTemplate ( ) . getSessionFactory ( ) . getCurrentSession ( ) . enableFilter ( GormProperties . TENANT_IDENTIT...
Enable the tenant id filter for the given datastore and entity
108
13
35,392
public static void configureNamingStrategy ( final Object strategy ) throws ClassNotFoundException , InstantiationException , IllegalAccessException { configureNamingStrategy ( ConnectionSource . DEFAULT , strategy ) ; }
Override the default naming strategy for the default datasource given a Class or a full class name .
43
19
35,393
public static void configureNamingStrategy ( final String datasourceName , final Object strategy ) throws ClassNotFoundException , InstantiationException , IllegalAccessException { Class < ? > namingStrategyClass = null ; NamingStrategy namingStrategy ; if ( strategy instanceof Class < ? > ) { namingStrategyClass = ( C...
Override the default naming strategy given a Class or a full class name or an instance of a NamingStrategy .
186
23
35,394
protected boolean isUnidirectionalOneToMany ( PersistentProperty property ) { return ( ( property instanceof org . grails . datastore . mapping . model . types . OneToMany ) && ! ( ( Association ) property ) . isBidirectional ( ) ) ; }
Checks whether a property is a unidirectional non - circular one - to - many
61
19
35,395
protected void bindDependentKeyValue ( PersistentProperty property , DependantValue key , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "[GrailsDomainBinder] binding [" + property . getName ( ) + "] with dependant key" ) ; } PersistentEntity refDo...
Binds the primary key value column
259
7
35,396
protected DependantValue createPrimaryKeyValue ( InFlightMetadataCollector mappings , PersistentProperty property , Collection collection , Map < ? , ? > persistentClasses ) { KeyValue keyValue ; DependantValue key ; String propertyRef = collection . getReferencedPropertyName ( ) ; // this is to support mapping by a pr...
Creates the DependentValue object that forms a primary key reference for the collection .
235
17
35,397
protected void bindUnidirectionalOneToMany ( org . grails . datastore . mapping . model . types . OneToMany property , InFlightMetadataCollector mappings , Collection collection ) { Value v = collection . getElement ( ) ; v . createForeignKey ( ) ; String entityName ; if ( v instanceof ManyToOne ) { ManyToOne manyToOne...
Binds a unidirectional one - to - many creating a psuedo back reference property in the process .
299
24
35,398
protected void linkBidirectionalOneToMany ( Collection collection , PersistentClass associatedClass , DependantValue key , PersistentProperty otherSide ) { collection . setInverse ( true ) ; // Iterator mappedByColumns = associatedClass.getProperty(otherSide.getName()).getValue().getColumnIterator(); Iterator < ? > map...
Links a bidirectional one - to - many configuring the inverse side and using a column copy to perform the link
151
24
35,399
protected void bindCollection ( ToMany property , Collection collection , PersistentClass owner , InFlightMetadataCollector mappings , String path , String sessionFactoryBeanName ) { // set role String propertyName = getNameForPropertyAndPath ( property , path ) ; collection . setRole ( qualify ( property . getOwner ( ...
First pass to bind collection to Hibernate metamodel sets up second pass
594
18