Skip to content

Commit

Permalink
Method-declaration : separate lines when wrapped
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenbaker committed Dec 17, 2024
1 parent 1ccf1f6 commit f31de64
Show file tree
Hide file tree
Showing 211 changed files with 965 additions and 483 deletions.
3 changes: 2 additions & 1 deletion config/spotless/formatting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,8 @@
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration"
value="separate_lines_if_wrapped"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement" value="common_lines"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public Map<String, List<String>> updateSecurity(
Context<? extends Trait> context,
Shape shape,
SecuritySchemeConverter<? extends Trait> converter,
Map<String, List<String>> requirement) {
Map<String, List<String>> requirement
) {
// Only modify requirements that exactly match the updated scheme.
if (requirement.size() != 1
|| !requirement.keySet().iterator().next().equals(converter.getOpenApiAuthSchemeName())) {
Expand All @@ -87,7 +88,8 @@ public OperationObject updateOperation(
OperationShape shape,
OperationObject operation,
String httpMethodName,
String path) {
String path
) {
ServiceShape service = context.getService();
AuthorizerIndex authorizerIndex = AuthorizerIndex.of(context.getModel());

Expand Down Expand Up @@ -142,7 +144,8 @@ public OpenApi after(Context<? extends Trait> context, OpenApi openapi) {
private OpenApi addComputedAuthorizers(
Context<? extends Trait> context,
OpenApi openApi,
AuthorizersTrait trait) {
AuthorizersTrait trait
) {
OpenApi.Builder builder = openApi.toBuilder();
ComponentsObject.Builder components = openApi.getComponents().toBuilder();

Expand All @@ -167,7 +170,8 @@ private OpenApi addComputedAuthorizers(
private boolean isAuthConverterMatched(
Context<? extends Trait> context,
SecuritySchemeConverter<? extends Trait> converter,
ShapeId scheme) {
ShapeId scheme
) {
return converter.getAuthSchemeId().equals(scheme)
&& context.getService().hasTrait(converter.getAuthSchemeType());
}
Expand All @@ -176,7 +180,8 @@ private <T extends Trait> SecurityScheme convertAuthScheme(
Context<? extends Trait> context,
SecuritySchemeConverter<T> converter,
AuthorizerDefinition authorizer,
String authorizerName) {
String authorizerName
) {
T authTrait = context.getService().expectTrait(converter.getAuthSchemeType());
SecurityScheme createdScheme = converter.createSecurityScheme(context, authTrait);
SecurityScheme.Builder schemeBuilder = createdScheme.toBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ private static PathItem addPreflightIntegration(
Context<? extends Trait> context,
String path,
PathItem pathItem,
CorsTrait corsTrait) {
CorsTrait corsTrait
) {
// Filter out any path for which an OPTIONS handler has already been defined
if (pathItem.getOptions().isPresent()) {
LOGGER.fine(() -> path + " already defines an OPTIONS request, so no need to generate CORS-preflight");
Expand All @@ -99,7 +100,8 @@ private static <T extends Trait> Map<CorsHeader, String> deduceCorsHeaders(
Context<T> context,
String path,
PathItem pathItem,
CorsTrait corsTrait) {
CorsTrait corsTrait
) {
Map<CorsHeader, String> corsHeaders = new HashMap<>();
corsHeaders.put(CorsHeader.MAX_AGE, String.valueOf(corsTrait.getMaxAge()));
corsHeaders.put(CorsHeader.ALLOW_ORIGIN, corsTrait.getOrigin());
Expand Down Expand Up @@ -153,7 +155,8 @@ private static <T extends Trait> Map<CorsHeader, String> deduceCorsHeaders(

private static <T extends Trait> Set<String> getSecuritySchemeRequestHeaders(
Context<? extends Trait> context,
SecuritySchemeConverter<T> converter) {
SecuritySchemeConverter<T> converter
) {
T t = context.getService().expectTrait(converter.getAuthSchemeType());
return converter.getAuthRequestHeaders(context, t);
}
Expand All @@ -179,7 +182,8 @@ private static OperationObject createPreflightOperation(
Context<? extends Trait> context,
String path,
PathItem pathItem,
Map<CorsHeader, String> headers) {
Map<CorsHeader, String> headers
) {
return OperationObject.builder()
.tags(ListUtils.of("CORS"))
.security(Collections.emptyList())
Expand Down Expand Up @@ -226,7 +230,8 @@ private static ResponseObject createPreflightResponse(Map<CorsHeader, String> he
private static ObjectNode createPreflightIntegration(
Context<? extends Trait> context,
Map<CorsHeader, String> headers,
PathItem pathItem) {
PathItem pathItem
) {
IntegrationResponse.Builder responseBuilder = IntegrationResponse.builder().statusCode("200");

// Add each CORS header to the mock integration response.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public OperationObject postProcessOperation(
OperationShape shape,
OperationObject operation,
String method,
String path) {
String path
) {
return context.getService()
.getTrait(CorsTrait.class)
.map(trait -> addCorsHeadersToResponses(context, shape, operation, method, trait))
Expand All @@ -56,7 +57,8 @@ private OperationObject addCorsHeadersToResponses(
OperationShape shape,
OperationObject operationObject,
String method,
CorsTrait trait) {
CorsTrait trait
) {
OperationObject.Builder builder = operationObject.toBuilder();

for (Map.Entry<String, ResponseObject> entry : operationObject.getResponses().entrySet()) {
Expand All @@ -79,7 +81,8 @@ private ResponseObject createUpdatedResponseWithCorsHeaders(
OperationObject operationObject,
String method,
CorsTrait trait,
ResponseObject response) {
ResponseObject response
) {
// Determine which headers have been added to the response.
List<String> headers = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ private Node updateGatewayResponses(Context<? extends Trait> context, CorsTrait
private Node updateGatewayResponses(
Context<? extends Trait> context,
CorsTrait trait,
ObjectNode gatewayResponses) {
ObjectNode gatewayResponses
) {
Map<CorsHeader, String> corsHeaders = new HashMap<>();
corsHeaders.put(CorsHeader.ALLOW_ORIGIN, trait.getOrigin());

Expand All @@ -110,7 +111,8 @@ private ObjectNode updateGatewayResponse(
Context<? extends Trait> context,
CorsTrait trait,
Map<CorsHeader, String> sharedHeaders,
ObjectNode gatewayResponse) {
ObjectNode gatewayResponse
) {
ObjectNode responseParameters = gatewayResponse
.getObjectMember(RESPONSE_PARAMETERS_KEY)
.orElse(Node.objectNode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public OperationObject updateOperation(
OperationShape shape,
OperationObject operationObject,
String httpMethod,
String path) {
String path
) {
CorsTrait cors = context.getService().getTrait(CorsTrait.class).orElse(null);

if (cors == null) {
Expand All @@ -69,7 +70,8 @@ private OperationObject updateOperation(
OperationShape shape,
OperationObject operationObject,
CorsTrait cors,
ObjectNode integrationObject) {
ObjectNode integrationObject
) {
ObjectNode updated = updateIntegrationWithCors(
context,
operationObject,
Expand All @@ -87,7 +89,8 @@ private ObjectNode updateIntegrationWithCors(
OperationObject operationObject,
OperationShape shape,
ObjectNode integrationNode,
CorsTrait cors) {
CorsTrait cors
) {
ObjectNode responses = integrationNode.getObjectMember(RESPONSES_KEY).orElse(Node.objectNode());

// Always include a "default" response that has the same HTTP response code.
Expand Down Expand Up @@ -132,7 +135,8 @@ private ObjectNode updateIntegrationResponse(
OperationShape shape,
Map<CorsHeader, String> corsHeaders,
Set<String> deduced,
ObjectNode response) {
ObjectNode response
) {
Map<CorsHeader, String> responseHeaders = new HashMap<>(corsHeaders);
ObjectNode responseParams = response.getObjectMember(RESPONSE_PARAMETERS_KEY).orElseGet(Node::objectNode);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public OperationObject updateOperation(
OperationShape shape,
OperationObject operation,
String httpMethod,
String path) {
String path
) {
IntegrationTraitIndex index = IntegrationTraitIndex.of(context.getModel());
return index.getIntegrationTrait(context.getService(), shape)
.map(trait -> operation.toBuilder()
Expand All @@ -62,7 +63,8 @@ static ObjectNode createIntegration(MockIntegrationTrait integration) {
private static ObjectNode createIntegration(
Context<? extends Trait> context,
OperationShape shape,
Trait integration) {
Trait integration
) {
ObjectNode integrationNode;
if (integration instanceof MockIntegrationTrait) {
integrationNode = integration.toNode().expectObjectNode().withMember("type", Node.from("mock"));
Expand All @@ -86,7 +88,8 @@ private static ObjectNode createIntegration(
private static void validateTraitConfiguration(
IntegrationTrait trait,
Context<? extends Trait> context,
OperationShape operation) {
OperationShape operation
) {
// For HTTP APIs, API Gateway requires that the payloadFormatVersion is set on integrations.
// https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-integration.html
// If the payloadFormatVersion has not been set on an integration and the apiGatewayType has been set to "HTTP",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public OperationObject updateOperation(
OperationShape shape,
OperationObject operation,
String httpMethod,
String path) {
String path
) {
return shape.getTrait(RequestValidatorTrait.class)
.map(RequestValidatorTrait::getValue)
.map(value -> operation.toBuilder().putExtension(REQUEST_VALIDATOR, value).build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public OperationObject updateOperation(
OperationShape shape,
OperationObject operation,
String httpMethodName,
String path) {
String path
) {
return matchesApiType(context)
? delegate.updateOperation(context, shape, operation, httpMethodName, path)
: operation;
Expand All @@ -107,7 +108,8 @@ public OperationObject postProcessOperation(
OperationShape shape,
OperationObject operation,
String httpMethodName,
String path) {
String path
) {
return matchesApiType(context)
? delegate.postProcessOperation(context, shape, operation, httpMethodName, path)
: operation;
Expand All @@ -126,7 +128,8 @@ public ParameterObject updateParameter(
OperationShape operation,
String httpMethodName,
String path,
ParameterObject parameterObject) {
ParameterObject parameterObject
) {
return matchesApiType(context)
? delegate.updateParameter(context, operation, httpMethodName, path, parameterObject)
: parameterObject;
Expand All @@ -138,7 +141,8 @@ public RequestBodyObject updateRequestBody(
OperationShape operation,
String httpMethodName,
String path,
RequestBodyObject requestBody) {
RequestBodyObject requestBody
) {
return matchesApiType(context)
? delegate.updateRequestBody(context, operation, httpMethodName, path, requestBody)
: requestBody;
Expand All @@ -151,7 +155,8 @@ public ResponseObject updateResponse(
String status,
String httpMethodName,
String path,
ResponseObject response) {
ResponseObject response
) {
return matchesApiType(context)
? delegate.updateResponse(context, operation, status, httpMethodName, path, response)
: response;
Expand All @@ -168,7 +173,8 @@ public void before(Context<? extends Trait> context, OpenApi.Builder builder) {
public SecurityScheme updateSecurityScheme(
Context<? extends Trait> context,
Trait authTrait,
SecurityScheme securityScheme) {
SecurityScheme securityScheme
) {
return matchesApiType(context)
? delegate.updateSecurityScheme(context, authTrait, securityScheme)
: securityScheme;
Expand All @@ -179,7 +185,8 @@ public Map<String, List<String>> updateSecurity(
Context<? extends Trait> context,
Shape shape,
SecuritySchemeConverter<? extends Trait> converter,
Map<String, List<String>> requirement) {
Map<String, List<String>> requirement
) {
return matchesApiType(context)
? delegate.updateSecurity(context, shape, converter, requirement)
: requirement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ static <T extends Trait> Set<String> deduceOperationResponseHeaders(
Context<T> context,
OperationObject operationObject,
OperationShape shape,
CorsTrait cors) {
CorsTrait cors
) {
// The deduced response headers of an operation consist of any headers
// returned by security schemes, any headers returned by the protocol,
// and any headers explicitly modeled on the operation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ private List<ValidationEvent> validate(Model model, ServiceShape service) {
private Optional<ValidationEvent> validateAuthSchema(
Map<String, AuthorizerDefinition> authorizers,
Model model,
ServiceShape service) {
ServiceShape service
) {
Set<ShapeId> authSchemes = ServiceIndex.of(model).getAuthSchemes(service).keySet();

String invalidMappings = authorizers.entrySet()
Expand Down Expand Up @@ -89,7 +90,8 @@ private Optional<ValidationEvent> validateAuthSchema(
*/
private Optional<ValidationEvent> validateEnableSimpleResponsesConfig(
Map<String, AuthorizerDefinition> authorizers,
ServiceShape service) {
ServiceShape service
) {
String invalidConfigs = authorizers.entrySet()
.stream()
.filter(entry -> entry.getValue().getEnableSimpleResponses().isPresent())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ public Builder putPropertyDefinition(String propertyName, CfnResourceProperty de

public Builder updatePropertyDefinition(
String propertyName,
Function<CfnResourceProperty, CfnResourceProperty> updater) {
Function<CfnResourceProperty, CfnResourceProperty> updater
) {
CfnResourceProperty definition = propertyDefinitions.get(propertyName);

// Don't update if we don't have a property or it's already locked.
Expand Down
Loading

0 comments on commit f31de64

Please sign in to comment.