Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated operation syntax support #373

Merged
merged 1 commit into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import static software.amazon.smithy.model.loader.SmithyModelLexer.TokenType.QUOTED;
import static software.amazon.smithy.model.loader.SmithyModelLexer.TokenType.RBRACE;
import static software.amazon.smithy.model.loader.SmithyModelLexer.TokenType.RBRACKET;
import static software.amazon.smithy.model.loader.SmithyModelLexer.TokenType.RETURN;
import static software.amazon.smithy.model.loader.SmithyModelLexer.TokenType.RPAREN;
import static software.amazon.smithy.model.loader.SmithyModelLexer.TokenType.UNQUOTED;

Expand Down Expand Up @@ -944,65 +943,21 @@ private void parseOperation() {
OperationShape.Builder builder = OperationShape.builder().id(id).source(sourceLocation);
visitor.onShape(builder);

Token opening = expect(LPAREN, LBRACE);
if (opening.type == LPAREN) {
parseDeprecatedOperationSyntax(builder);
} else {
ObjectNode node = parseObjectNode(opening.getSourceLocation(), RBRACE);
node.expectNoAdditionalProperties(OPERATION_PROPERTY_NAMES);
node.getStringMember("input").ifPresent(input -> {
onShapeTarget(input.getValue(), input, builder::input);
});
node.getStringMember("output").ifPresent(output -> {
onShapeTarget(output.getValue(), output, builder::output);
});
node.getArrayMember("errors").ifPresent(errors -> {
for (StringNode value : errors.getElementsAs(StringNode.class)) {
onShapeTarget(value.getValue(), value, builder::addError);
}
});
}
Token opening = expect(LBRACE);
ObjectNode node = parseObjectNode(opening.getSourceLocation(), RBRACE);
node.expectNoAdditionalProperties(OPERATION_PROPERTY_NAMES);
node.getStringMember("input").ifPresent(input -> {
onShapeTarget(input.getValue(), input, builder::input);
});
node.getStringMember("output").ifPresent(output -> {
onShapeTarget(output.getValue(), output, builder::output);
});
node.getArrayMember("errors").ifPresent(errors -> {
for (StringNode value : errors.getElementsAs(StringNode.class)) {
onShapeTarget(value.getValue(), value, builder::addError);
}
});

expectNewline();
}

private void parseDeprecatedOperationSyntax(OperationShape.Builder builder) {
visitor.onError(ValidationEvent.builder()
.eventId(Validator.MODEL_ERROR)
.sourceLocation(builder.getSourceLocation())
.shapeId(builder.getId())
.message("Deprecated IDL syntax detected for operation definition")
.severity(Severity.WARNING)
.build());

Token next = expect(RPAREN, UNQUOTED);
if (next.type == UNQUOTED) {
onShapeTarget(next.lexeme, next, builder::input);
expect(RPAREN);
}

// Parse the optionally present return value.
if (test(RETURN)) {
expect(RETURN);
Token returnToken = expect(UNQUOTED);
onShapeTarget(returnToken.lexeme, returnToken, builder::output);
}

// Parse the optionally present errors list.
if (peek().filter(token -> token.lexeme.equals("errors")).isPresent()) {
next(); // Skip the error.
expect(LBRACKET);
if (!test(RBRACKET)) {
while (true) {
Token errorToken = expect(UNQUOTED);
onShapeTarget(errorToken.lexeme, errorToken, builder::addError);
if (test(RBRACKET)) {
break;
}
expect(COMMA);
}
}
expect(RBRACKET);
}
}
}

This file was deleted.

This file was deleted.