Skip to content

Commit

Permalink
Fix incorrectly detected INDENTATION atoms SERG-Delft#54
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertSGS committed May 2, 2023
1 parent e77d2ab commit ef1a5f0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/github/GithubUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import github.exceptions.InvalidPrUrlException
import github.exceptions.NonexistentPRException
import github.exceptions.UsageLimitException
import input.Settings
import java.net.URI
import org.antlr.v4.runtime.CharStreams
import org.json.simple.JSONObject
import org.json.simple.parser.JSONParser
import parsing.ParsedFile
import java.net.URI

// for now its like this until a proper error handling system is in place
@SuppressWarnings("RethrowCaughtException", "ThrowsCount", "MagicNumber")
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/input/Cli.kt
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ class PRCommand : AtomsCommand("Analyze the provided github pull request for ato
// get the filenames of the .java files that were modified in the pr
val fromFiles = parsedDiff.fromFileNames.filter { it.endsWith(".java") }
val toFiles = parsedDiff.toFileNames.filter { it.endsWith(".java") }

val fromGraph = runDetector(fromFiles, pr.fromCommit, resultsDir, "from")
val toGraph = runDetector(toFiles, pr.toCommit, resultsDir, "to")

Expand Down
5 changes: 4 additions & 1 deletion src/main/kotlin/parsing/detectors/IndentationDetector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ class IndentationDetector(listener: AtomsListener, graph: ConfusionGraph) : Dete

override fun detect(ctx: JavaParser.StatIfElseContext) {
checkNextSiblingHasSameIndentation(ctx)
val startingIndentOfIf = ctx.IF().symbol.charPositionInLine
var startingIndentOfIf = ctx.IF().symbol.charPositionInLine
if (ctx.parent is JavaParser.StatIfElseContext) {
startingIndentOfIf = (ctx.parent as JavaParser.StatIfElseContext).ifBody.stop.charPositionInLine
}
if (ctx.ifBody is JavaParser.StatBlockContext) {
val closingBracket = (ctx.ifBody as JavaParser.StatBlockContext).block().RBRACE().symbol
val indentOfClosingBracket =
Expand Down

0 comments on commit ef1a5f0

Please sign in to comment.