Skip to content

Commit

Permalink
refactor(code-highlighting): simplify null checks and return statements
Browse files Browse the repository at this point in the history
The changes streamline the logic in `CodeBlockHighlightingFilter` and `CodeBlockHighlightErrorFilter` by reducing the number of lines and simplifying the null checks. This results in more concise code that improves readability and maintainability. Specifically, the null checks and early returns have been optimized for better efficiency.
  • Loading branch information
phodal committed Nov 24, 2024
1 parent 5430590 commit 2685135
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import com.intellij.psi.PsiErrorElement

class CodeBlockHighlightErrorFilter : HighlightErrorFilter() {
override fun shouldHighlightErrorElement(element: PsiErrorElement): Boolean {
val containingFile = element.containingFile
val highlightedFile = containingFile?.virtualFile ?: return true
val highlightedFile = element.containingFile?.virtualFile ?: return true
return !AutoDevSnippetFile.isSnippet(highlightedFile)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@ import com.intellij.psi.PsiFile
class CodeBlockHighlightingFilter : HighlightInfoFilter {
override fun accept(highlightInfo: HighlightInfo, file: PsiFile?): Boolean {
val hasError = highlightInfo.severity >= HighlightSeverity.GENERIC_SERVER_ERROR_OR_WARNING;
if (file == null || !hasError) return true
val virtualFile = file.virtualFile ?: return true

if (file == null || !hasError) {
return true;
}

val virtualFile = file.virtualFile;

return !(virtualFile != null && AutoDevSnippetFile.isSnippet(virtualFile));
return !(AutoDevSnippetFile.isSnippet(virtualFile))
}
}

0 comments on commit 2685135

Please sign in to comment.