Skip to content

Commit

Permalink
Merge pull request #40 from awslabs/main
Browse files Browse the repository at this point in the history
  • Loading branch information
kubukoz committed Apr 27, 2023
2 parents 5c8b219 + 7112e29 commit d8aa2c5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
Expand Up @@ -274,7 +274,9 @@ private Boolean shapeWasDefinedInline(OperationShape operation, Shape shape, Mod
}
int boundary = Math.max(priorShapeLine, operation.getSourceLocation().getLine());
while (shapeStartLine >= boundary) {
String line = modelFile.lines.get(shapeStartLine);
String line = modelFile.lines.get(shapeStartLine - 1);

// note: this doesn't take code inside comments into account
if (line.contains(":=")) {
return true;
}
Expand Down
Expand Up @@ -15,9 +15,6 @@

package software.amazon.smithy.lsp.ext;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -43,6 +40,10 @@
import software.amazon.smithy.utils.ListUtils;
import software.amazon.smithy.utils.MapUtils;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;

public class SmithyProjectTest {

@Test
Expand Down Expand Up @@ -124,6 +125,30 @@ public void ignoresUnmodeledApplyStatements() throws Exception {
}
}

// https://github.com/awslabs/smithy-language-server/issues/100
@Test
public void allowsEmptyStructsWithMixins() throws Exception {
String fileText = "$version: \"2\"\n" +
"\n" +
"namespace demo\n" +
"\n" +
"operation MyOp {\n" +
" output: MyOpOutput\n" +
"}\n" +
"\n" +
"@output\n" +
"structure MyOpOutput {}\n";

Map<String, String> files = MapUtils.of("main.smithy", fileText);

try (Harness hs = Harness.create(SmithyBuildExtensions.builder().build(), files)) {
assertNotNull(hs.getProject());
Map<ShapeId, Location> locationMap = hs.getProject().getLocations();

correctLocation(locationMap, "demo#MyOpOutput", 9, 0, 9, 23);
}
}

@Test
public void definitionLocationsV1() throws Exception {
Path baseDir = Paths.get(SmithyProjectTest.class.getResource("models/v1").toURI());
Expand Down

0 comments on commit d8aa2c5

Please sign in to comment.