Skip to content

Commit

Permalink
some class/ function code getting requests refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
diffitask committed Nov 15, 2023
1 parent 284d346 commit 9819287
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,22 @@ fun Routing.getFileClasses(logger: Logger, ideStateKeeper: IdeStateKeeper) {
return@get
}

val className = call.parameters[CLASS_NAME_REQUEST_PARAM]
if (className == null) {
call.respondJson(fileClasses.getClassesNames()!!)
logger.info("Server GET file classes request for the file '$fileName' is processed")
} else {
val classCode = try {
fileClasses.getClassCode(className)
} catch (e: Exception) {
e.message!!
when(val className = call.parameters[CLASS_NAME_REQUEST_PARAM]) {
null -> {
call.respondJson(fileClasses.getClassesNames()!!)
logger.info("Server GET file classes request for the file '$fileName' is processed")
}

else -> {
val classCode = try {
fileClasses.getClassCode(className)
} catch (e: Exception) {
e.message!!
}

call.respondJson(classCode)
logger.info("Server GET file class code request for the file '$fileName' and the class '$className' is processed")
}
call.respondJson(classCode)
logger.info("Server GET file class code request for the file '$fileName' and the class '$className' is processed")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fun Routing.getFileFunctions(logger: Logger, ideStateKeeper: IdeStateKeeper) {
call.respondJson(fileFunctions.getFunctionsNames()!!)
logger.info("Server GET file functions request for file '$fileName' is processed")
}

else -> {
val functionCode = try {
fileFunctions.getFunctionCode(functionName)
Expand Down

0 comments on commit 9819287

Please sign in to comment.