Skip to content

Commit

Permalink
refactor(analyzer): remove nullable return from collectProblems
Browse files Browse the repository at this point in the history
The commit updates the `collectProblems` function by removing the nullable return type, ensuring a non-nullable string is always returned. This change also includes the removal of the safe call operator and the use of `let` for consistent function chaining.
  • Loading branch information
phodal committed Nov 21, 2024
1 parent ac99c93 commit 5430590
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ fun getCanonicalName(input: String): List<String> {
* @param element The PsiElement for which the problems are to be collected.
* @return A string containing all the problems found, separated by new lines, or `null` if no problems were found.
*/
fun collectProblems(project: Project, editor: Editor, element: PsiElement): String? {
fun collectProblems(project: Project, editor: Editor, element: PsiElement): String {
val range = element.textRange
val document = editor.document
var errors: MutableList<String> = mutableListOf()
val errors: MutableList<String> = mutableListOf()
DaemonCodeAnalyzerEx.processHighlights(document, project, null, range.startOffset, range.endOffset) {
if (it.description != null) {
errors.add(it.description)
Expand Down Expand Up @@ -59,7 +59,7 @@ fun collectElementProblemAsSting(
): String {
val commentSymbol = commentPrefix(element)

return collectProblems(project, editor, element)?.let { problem ->
return collectProblems(project, editor, element).let { problem ->
var relatedCode = ""
getCanonicalName(problem).map {
val classContext = PsiElementDataBuilder.forLanguage(element.language)?.lookupElement(project, it)
Expand Down

0 comments on commit 5430590

Please sign in to comment.