diff --git a/spock-core/src/main/java/org/spockframework/compiler/SpecAnnotator.java b/spock-core/src/main/java/org/spockframework/compiler/SpecAnnotator.java index 25061a9e23..3a7a180112 100644 --- a/spock-core/src/main/java/org/spockframework/compiler/SpecAnnotator.java +++ b/spock-core/src/main/java/org/spockframework/compiler/SpecAnnotator.java @@ -191,8 +191,9 @@ private void addFeatureMetadata(FeatureMethod feature) { ann.setMember(FeatureMetadata.BLOCKS, blockAnnElems = new ListExpression()); ListExpression paramNames = new ListExpression(); - for (Parameter param : feature.getAst().getParameters()) + for (Parameter param : feature.getAst().getParameters()) { paramNames.addExpression(new ConstantExpression(param.getName())); + } ann.setMember(FeatureMetadata.PARAMETER_NAMES, paramNames); feature.getAst().addAnnotation(ann); @@ -203,12 +204,13 @@ private void addBlockMetadata(Block block, BlockKind kind) { blockAnn.setMember(BlockMetadata.KIND, new PropertyExpression( new ClassExpression(nodeCache.BlockKind), kind.name())); ListExpression textExprs = new ListExpression(); - for (String text : block.getDescriptions()) + for (String text : block.getDescriptions()) { textExprs.addExpression(new ConstantExpression(text)); + } blockAnn.setMember(BlockMetadata.TEXTS, textExprs); int index = blockAnnElems.getExpressions().size(); Assert.that(index == block.getBlockMetaDataIndex(), - () -> kind+" block mismatch of index: " + index + ", block.getBlockMetaDataIndex(): " + block.getBlockMetaDataIndex()); + () -> kind + " block mismatch of index: " + index + ", block.getBlockMetaDataIndex(): " + block.getBlockMetaDataIndex()); blockAnnElems.addExpression(new AnnotationConstantExpression(blockAnn)); } diff --git a/spock-core/src/main/java/org/spockframework/compiler/SpecRewriter.java b/spock-core/src/main/java/org/spockframework/compiler/SpecRewriter.java index 7a0c69c138..893c83e41a 100644 --- a/spock-core/src/main/java/org/spockframework/compiler/SpecRewriter.java +++ b/spock-core/src/main/java/org/spockframework/compiler/SpecRewriter.java @@ -34,7 +34,6 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.stream.Collectors; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; @@ -430,9 +429,9 @@ private void addBlockListeners(Block block) { || blockType == BlockParseInfo.COMBINED || blockType == BlockParseInfo.ANONYMOUS) return; - // SpockRuntime.enterBlock(getSpecificationContext(), new BlockInfo(blockKind, [blockTexts])) + // SpockRuntime.enterBlock(getSpecificationContext(), new BlockInfo(blockKind, blockMetaDataIndex)) MethodCallExpression enterBlockCall = createBlockListenerCall(block, blockType, nodeCache.SpockRuntime_CallEnterBlock); - // SpockRuntime.exitedBlock(getSpecificationContext(), new BlockInfo(blockKind, [blockTexts])) + // SpockRuntime.exitedBlock(getSpecificationContext(), new BlockInfo(blockKind, blockMetaDataIndex)) MethodCallExpression exitBlockCall = createBlockListenerCall(block, blockType, nodeCache.SpockRuntime_CallExitBlock); if (blockType == BlockParseInfo.CLEANUP) { @@ -447,7 +446,7 @@ private void addBlockListeners(Block block) { block.getAst().add(new ExpressionStatement(exitBlockCall)); } else { block.getAst().add(0, new ExpressionStatement(enterBlockCall)); - block.getAst().add( new ExpressionStatement(exitBlockCall)); + block.getAst().add(new ExpressionStatement(exitBlockCall)); } } @@ -559,7 +558,7 @@ private Statement createMockControllerCall(MethodNode method) { public void visitCleanupBlock(CleanupBlock block) { for (Block b : method.getBlocks()) { // call addBlockListeners() here, as this method will already copy the contents of the blocks, - // so we need to transform here as they won't be copied again in visitMethodAgain where we normally add them + // so we need to transform the block listeners here as they won't be copied in visitMethodAgain where we normally add them addBlockListeners(b); if (b == block) break; moveVariableDeclarations(b.getAst(), method.getStatements()); diff --git a/spock-core/src/main/java/org/spockframework/runtime/model/ErrorInfo.java b/spock-core/src/main/java/org/spockframework/runtime/model/ErrorInfo.java index 7a5c0f29b9..f9c4bf6f99 100644 --- a/spock-core/src/main/java/org/spockframework/runtime/model/ErrorInfo.java +++ b/spock-core/src/main/java/org/spockframework/runtime/model/ErrorInfo.java @@ -33,6 +33,11 @@ public Throwable getException() { return error; } + /** + * {@return the error context} + * + * @since 2.4 + */ public IErrorContext getErrorContext() { return errorContext; } diff --git a/spock-core/src/main/java/org/spockframework/runtime/model/IErrorContext.java b/spock-core/src/main/java/org/spockframework/runtime/model/IErrorContext.java index 3ddbf1a0df..7e11bbd882 100644 --- a/spock-core/src/main/java/org/spockframework/runtime/model/IErrorContext.java +++ b/spock-core/src/main/java/org/spockframework/runtime/model/IErrorContext.java @@ -6,6 +6,8 @@ * Provides context information for an error that occurred during the execution of a specification. *

* Depending on the context in which the error occurred, some of the methods may return {@code null}. + * + * @since 2.4 */ public interface IErrorContext { @Nullable