fix: переход диагностики BadExceptionCategory на TypeService.resolve (#1935)#4128
Conversation
📝 WalkthroughWalkthroughRefactors ChangesBadExceptionCategoryDiagnostic Refactor
EventHandler Diagnostics Schema and Docs Registration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
2d8e868 to
00ac51d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadExceptionCategoryDiagnostic.java`:
- Around line 61-67: The English alias for the raised-from-script exception
category in the errors.addAll() method call in BadExceptionCategoryDiagnostic is
incorrect. Replace "ScriptRaisedException" with "ExceptionRaisedFromScript" to
match the documented 1C forbidden category name. This will ensure that
ErrorCategory.ExceptionRaisedFromScript is properly recognized and not missed by
the token matching logic at line 90.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a45cf8e7-cafe-4b36-8108-4708f51b0b14
⛔ Files ignored due to path filters (1)
src/test/resources/diagnostics/BadExceptionCategoryDiagnostic.bslis excluded by!src/test/resources/**
📒 Files selected for processing (2)
src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadExceptionCategoryDiagnostic.javasrc/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadExceptionCategoryDiagnosticTest.java
| errors.addAll(List.of( | ||
| "ВсеОшибки", "AllErrors", | ||
| "ПрочаяОшибка", "OtherError", | ||
| "ОшибкаКомпиляцииВстроенногоЯзыка", "ScriptCompileError", | ||
| "ОшибкаВоВремяВыполненияВстроенногоЯзыка", "ScriptRuntimeError", | ||
| "ИсключениеВызванноеИзВстроенногоЯзыка", "ScriptRaisedException" | ||
| )); |
There was a problem hiding this comment.
Use the documented English alias for the raised-from-script category.
ScriptRaisedException does not match the 1C documentation’s forbidden English category name, ExceptionRaisedFromScript; because Line 90 rejects unknown token text before memberAt(), ErrorCategory.ExceptionRaisedFromScript is currently missed. The referenced 1C developer guide lists the forbidden categories as AllErrors, OtherError, ScriptCompileError, ScriptRuntimeError, and ExceptionRaisedFromScript. (kb.1ci.com)
🐛 Proposed fix
errors.addAll(List.of(
"ВсеОшибки", "AllErrors",
"ПрочаяОшибка", "OtherError",
"ОшибкаКомпиляцииВстроенногоЯзыка", "ScriptCompileError",
"ОшибкаВоВремяВыполненияВстроенногоЯзыка", "ScriptRuntimeError",
- "ИсключениеВызванноеИзВстроенногоЯзыка", "ScriptRaisedException"
+ "ИсключениеВызванноеИзВстроенногоЯзыка", "ExceptionRaisedFromScript"
));🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadExceptionCategoryDiagnostic.java`
around lines 61 - 67, The English alias for the raised-from-script exception
category in the errors.addAll() method call in BadExceptionCategoryDiagnostic is
incorrect. Replace "ScriptRaisedException" with "ExceptionRaisedFromScript" to
match the documented 1C forbidden category name. This will ensure that
ErrorCategory.ExceptionRaisedFromScript is properly recognized and not missed by
the token matching logic at line 90.
|
| } | ||
| private boolean isForbiddenCategoryParam(CallParamContext param) { | ||
| String lastTokenText = param.getStop().getText(); | ||
| if (!FORBIDDEN_CATEGORIES.contains(lastTokenText)) { |
There was a problem hiding this comment.
Там может лежать переменная, в которую сохранена категория ошибки. В общем случае, думаю, можно удалить эту проверку



Описание
В рамках решения задачи #1935 алгоритм диагностики
BadExceptionCategoryDiagnosticпереведен на использование семантического анализа черезTypeService.resolve(). Новый подход черезresolveигнорирует форматирование, исправляя отсутствие срабатывания теста в случаях когда элементы AST-дерева дополнительно разделены пробелами.Связанные задачи
Closes #1935
Чеклист
Общие
gradlew precommit)Для диагностик
Дополнительно
Summary by CodeRabbit
Documentation
New Features
Improvements
Tests