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

Avoid substring if not suffixed #133

Merged
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 @@ -240,7 +240,10 @@ private Optional<OperationShape> getOperationForInlinedInputOrOutput(Shape shape
String suffix = getOperationInputOrOutputSuffix(shape, preamble);
String shapeName = shape.getId().getName();

String matchingOperationName = shapeName.substring(0, shapeName.length() - suffix.length());
String matchingOperationName =
shapeName.endsWith(suffix)
? shapeName.substring(0, shapeName.length() - suffix.length())
: shapeName;
ShapeId matchingOperationId = ShapeId.fromParts(shape.getId().getNamespace(), matchingOperationName);

return model.shapes(OperationShape.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,14 @@ public void shapeIdFromLocationV2() throws Exception {
new Position(160,8)).get());
assertEquals(ShapeId.from("com.example#OtherStructure"), project.getShapeIdFromLocation(testUri,
new Position(7, 15)).get());
assertEquals(ShapeId.from("com.foo#ShortI"), project.getShapeIdFromLocation(uri,
new Position(210,5)).get());
assertEquals(ShapeId.from("com.foo#ShortI$c"), project.getShapeIdFromLocation(uri,
new Position(211,6)).get());
assertEquals(ShapeId.from("com.foo#ShortO"), project.getShapeIdFromLocation(uri,
new Position(215,5)).get());
assertEquals(ShapeId.from("com.foo#ShortO$d"), project.getShapeIdFromLocation(uri,
new Position(216,6)).get());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,18 @@ structure FalseInlinedReversedBarOutput {

@trait
structure emptyTraitStruct {}

operation ShortInputOutput {
output: ShortO
input: ShortI
}

@input
structure ShortI {
c: String
}

@output
structure ShortO {
d: String
}
Loading