Skip to content

Commit

Permalink
only highlight first line for switches #486
Browse files Browse the repository at this point in the history
  • Loading branch information
Luro02 committed May 16, 2024
1 parent 56ceb71 commit 4789717
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.firemage.autograder.core.file.SourceInfo;
import de.firemage.autograder.core.file.SourcePath;
import spoon.reflect.code.CtAbstractSwitch;
import spoon.reflect.code.CtLoop;
import spoon.reflect.cu.SourcePosition;
import spoon.reflect.declaration.CtElement;
Expand Down Expand Up @@ -33,7 +34,7 @@ public static CodePosition fromSourcePosition(
// Instead of highlighting all lines of a class or method, only highlight the first line.
//
// Someone might explicitly specify a source position, in which case it will differ from the element's position.
if ((ctElement instanceof CtType<?> || ctElement instanceof CtMethod<?> || ctElement instanceof CtLoop) && ctElement.getPosition().equals(sourcePosition)) {
if ((ctElement instanceof CtType<?> || ctElement instanceof CtMethod<?> || ctElement instanceof CtLoop || ctElement instanceof CtAbstractSwitch<?>) && ctElement.getPosition().equals(sourcePosition)) {
return new CodePosition(
sourceInfo,
relativePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Test.java:10
Test.java:47
Test.java:50-51
Test.java:51-52
Test.java:54-55
Test.java:54
Test.java:65
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
oop.ShouldBeEnumAttribute
Switch value should be enum attribute.
Test.java:15-19
Test.java:23-28
Test.java:33-41
Test.java:46-62
Test.java:15
Test.java:23
Test.java:33
Test.java:46

0 comments on commit 4789717

Please sign in to comment.