Skip to content

Commit

Permalink
Merge pull request oracle#126 from hpi-swa-lab/bugfix/124-annotation-…
Browse files Browse the repository at this point in the history
…at-end-of-line

Fix annotation to appear at end of line
  • Loading branch information
JakobEdding authored Feb 12, 2020
2 parents 307a533 + 8f4b5be commit 91f59ac
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public enum ProbeMode {
private List<AssertionDefinition> assertions;
private Object exampleResult;
private int exampleDefinitionLine;
private int exampleDefinitionEndColumn;
private String uri;
private String uniqueEmoji;

Expand Down Expand Up @@ -94,7 +93,6 @@ public ExampleDefinition(String exampleName,
int functionStartLine,
String functionName,
int exampleDefinitionLine,
int exampleDefinitionEndColumn,
String uri,
ProbeMode probeMode) {
this.exampleName = exampleName;
Expand All @@ -104,7 +102,6 @@ public ExampleDefinition(String exampleName,
this.probeMode = probeMode;
this.assertions = new ArrayList<>();
this.exampleDefinitionLine = exampleDefinitionLine;
this.exampleDefinitionEndColumn = exampleDefinitionEndColumn;
this.uri = uri;
}

Expand Down Expand Up @@ -171,10 +168,6 @@ public int getExampleDefinitionLine() {
return exampleDefinitionLine;
}

public int getExampleDefinitionEndColumn() {
return exampleDefinitionEndColumn;
}

public String getUri() {
return uri;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
public class ProbeDefinition {
private String uri;
private int line;
private int startColumn;
private int endColumn;
private Object result;

public ProbeDefinition(int line) {
Expand All @@ -23,22 +21,6 @@ public int getLine() {
return line;
}

public int getStartColumn() {
return startColumn;
}

public void setStartColumn(int startColumn) {
this.startColumn = startColumn;
}

public int getEndColumn() {
return endColumn;
}

public void setEndColumn(int endColumn) {
this.endColumn = endColumn;
}

public Object getResult() {
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public List<ExampleDefinition> parseExamples() {
lineNumber,
this.exampleInvocationCode,
this.getExampleDefinitionLine(example[0]),
this.getExampleDefinitionEndColumn(example[0]),
this.uri,
probeMode));
});
Expand Down Expand Up @@ -112,18 +111,6 @@ public int getExampleDefinitionLine(String exampleName) {
return -1;
}

public int getExampleDefinitionEndColumn(String exampleName) {
String pattern = exampleAnnotationPatternPrefix + exampleName;
Pattern m = Pattern.compile(pattern);

for (String line : this.annotatedSource.split("\n")) {
if (m.matcher(line).find())
return line.length();
}

return -1;
}

public String getExampleInvocationCode(Integer lineNumber, Map<String, Object> exampleParameters,
List<LanguageAgnosticFunctionDeclarationDefinition> functionsInSource) {
String functionNameForExample = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ private Map<String, List<Decoration>> getMapOfDecorationsForEvaluatedExample(Exa
List<Decoration> existingDecorations = uriToDecorationsMap.get(probe.getUri());
Decoration newDecoration = Decoration.create(
Range.create(
Position.create(probe.getLine(), probe.getStartColumn()),
Position.create(probe.getLine(), probe.getEndColumn())
Position.create(probe.getLine(), Integer.MAX_VALUE),
Position.create(probe.getLine(), Integer.MAX_VALUE)
),
example.getUniqueEmoji() + (probe.getResult() != null ? probe.getResult().toString() : "null"),
Decoration.PROBE_DECORATION_TYPE
Expand All @@ -360,8 +360,8 @@ private Map<String, List<Decoration>> getMapOfDecorationsForEvaluatedExample(Exa
List<Decoration> existingDecorations = uriToDecorationsMap.get(assertion.getUri());
Decoration newDecoration = Decoration.create(
Range.create(
Position.create(assertion.getLine(), assertion.getStartColumn()),
Position.create(assertion.getLine(), assertion.getEndColumn())
Position.create(assertion.getLine(), Integer.MAX_VALUE),
Position.create(assertion.getLine(), Integer.MAX_VALUE)
),
// \u2705 is a ✅ and \u274c is a ❌
example.getUniqueEmoji() + (assertion.isAssertionTrue() ? "\u2705" : "\u274c"),
Expand All @@ -379,8 +379,8 @@ private Map<String, List<Decoration>> getMapOfDecorationsForEvaluatedExample(Exa
List<Decoration> existingDecorations = uriToDecorationsMap.get(example.getUri());
Decoration newDecoration = Decoration.create(
Range.create(
Position.create(example.getExampleDefinitionLine(), 0),
Position.create(example.getExampleDefinitionLine(), example.getExampleDefinitionEndColumn())
Position.create(example.getExampleDefinitionLine(), Integer.MAX_VALUE),
Position.create(example.getExampleDefinitionLine(), Integer.MAX_VALUE)
),
example.getUniqueEmoji() + (example.getExampleResult() != null ? example.getExampleResult().toString() : "null"),
Decoration.EXAMPLE_DECORATION_TYPE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,6 @@ public void onReturnValue(EventContext context, VirtualFrame frame, Object resul
example.getProbes().add(probe);
probe.setResult(result);
probe.setUri(uri);
probe.setStartColumn(sourceSection.getStartColumn());
probe.setEndColumn(sourceSection.getEndColumn());
}

if (example.getProbeMode() == ExampleDefinition.ProbeMode.ALL || example.getProbeMode() == ExampleDefinition.ProbeMode.DEFAULT) {
Expand All @@ -286,8 +284,6 @@ public void onReturnValue(EventContext context, VirtualFrame frame, Object resul
example.getAssertions().add(assertion);
assertion.setResult(result);
assertion.setUri(uri);
assertion.setStartColumn(sourceSection.getStartColumn());
assertion.setEndColumn(sourceSection.getEndColumn());
}
}
}
Expand Down

0 comments on commit 91f59ac

Please sign in to comment.