BaseInspectionVisitor () { return new BaseInspectionVisitor() { @Override public void visitPackageStatement(@NotNull PsiPackageStatement statement) { final PsiJavaCodeReferenceElement reference = statement.getPackageReference(); if (reference == null) { return; } final String text = reference.getText(); int start = 0; int index = text.indexOf('.', start); while (index > 0) { final String name = text.substring(start, index); if (!mySettingsDelegate.isValid(name)) { registerErrorAtOffset(reference, start, index - start, name); } start = index + 1; index = text.indexOf('.', start); } final String lastName = text.substring(start); if (!lastName.isEmpty() && !mySettingsDelegate.isValid(lastName)) { registerErrorAtOffset(reference, start, lastName.length(), lastName); } } }; }