mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: add assertions instead of silently ignoring problems
This commit is contained in:
+4
-3
@@ -118,9 +118,10 @@ public abstract class BaseInspection extends BaseJavaBatchLocalInspectionTool {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public final PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder,
|
||||
boolean isOnTheFly) {
|
||||
if (!shouldInspect(holder.getFile())) {
|
||||
public final PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
final PsiFile file = holder.getFile();
|
||||
assert file.isPhysical();
|
||||
if (!shouldInspect(file)) {
|
||||
return new PsiElementVisitor() { };
|
||||
}
|
||||
final BaseInspectionVisitor visitor = buildVisitor();
|
||||
|
||||
+3
-10
@@ -96,10 +96,7 @@ public abstract class BaseInspectionVisitor extends JavaElementVisitor {
|
||||
else {
|
||||
nameIdentifier = aClass.getNameIdentifier();
|
||||
}
|
||||
if (nameIdentifier != null && !nameIdentifier.isPhysical()) {
|
||||
nameIdentifier = nameIdentifier.getNavigationElement();
|
||||
}
|
||||
if (nameIdentifier == null || !nameIdentifier.isPhysical()) {
|
||||
if (nameIdentifier == null) {
|
||||
registerError(aClass.getContainingFile(), infos);
|
||||
}
|
||||
else {
|
||||
@@ -182,9 +179,7 @@ public abstract class BaseInspectionVisitor extends JavaElementVisitor {
|
||||
protected final void registerError(@NotNull PsiElement location,
|
||||
final ProblemHighlightType highlightType,
|
||||
Object... infos) {
|
||||
if (!location.isPhysical() || location.getTextLength() == 0 && !(location instanceof PsiFile)) {
|
||||
return;
|
||||
}
|
||||
assert location.getTextLength() != 0 || location instanceof PsiFile;
|
||||
final LocalQuickFix[] fixes = createAndInitFixes(infos);
|
||||
final String description = inspection.buildErrorString(infos);
|
||||
holder.registerProblem(location, description, highlightType, fixes);
|
||||
@@ -197,9 +192,7 @@ public abstract class BaseInspectionVisitor extends JavaElementVisitor {
|
||||
protected final void registerErrorAtOffset(@NotNull PsiElement location, int offset, int length,
|
||||
ProblemHighlightType highlightType,
|
||||
Object... infos) {
|
||||
if (location.getTextLength() == 0 || length == 0) {
|
||||
return;
|
||||
}
|
||||
assert !(location.getTextLength() == 0 || length == 0);
|
||||
final LocalQuickFix[] fixes = createAndInitFixes(infos);
|
||||
final String description = inspection.buildErrorString(infos);
|
||||
final TextRange range = new TextRange(offset, offset + length);
|
||||
|
||||
Reference in New Issue
Block a user