Skip to content
Merged
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
8 changes: 7 additions & 1 deletion server/src/main/kotlin/org/javacs/kt/SourceFiles.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ class SourceFiles(private val sp: SourcePath) {
private fun readFromDisk(file: Path): SourceVersion? {
if (!Files.exists(file)) return null

val content = Files.readAllLines(file).joinToString("\n")
var content = ""

try {
content = Files.readAllLines(file).joinToString("\n")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be cleaner if you return from this line instead of saving the file contents to a variable

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Storing the contents in a variable is fine IMO. Since the string is going to be wrapped into a SourceVersion anyway, having two returns would entail some code duplication.

} catch(exception: IOException) {
LOG.warn("Exception while parsing source file : ${file.toFile().absolutePath}")
}

return SourceVersion(content, -1)
}
Expand Down