void () { LOG.debug("updating " + getFile().getVirtualFile()); PsiClassOwner javaFile = (PsiClassOwner)getFile(); PsiElement pkg = getPackageStatement(); PsiElement[] imports = getImportsList(); PsiClass topClass = null; PsiClass[] classes = javaFile.getClasses(); if (classes.length > 0) { topClass = classes[0]; } PsiElement first = javaFile.getFirstChild(); int location = getLanguageOptions().getFileLocation(); if (pkg != null) { checkComments(first, pkg, location == JavaOptions.LOCATION_BEFORE_PACKAGE); first = pkg; } else if (location == JavaOptions.LOCATION_BEFORE_PACKAGE) { location = JavaOptions.LOCATION_BEFORE_IMPORT; } if (imports != null && imports.length > 0) { checkComments(first, imports[0], location == JavaOptions.LOCATION_BEFORE_IMPORT); first = imports[0]; } else if (location == JavaOptions.LOCATION_BEFORE_IMPORT) { location = JavaOptions.LOCATION_BEFORE_CLASS; } if (topClass != null) { final List<PsiComment> comments = new ArrayList<>(); collectComments(first, topClass, comments); collectComments(topClass.getFirstChild(), topClass.getModifierList(), comments); checkCommentsForTopClass(topClass, location, comments); } else if (location == JavaOptions.LOCATION_BEFORE_CLASS) { // no package, no imports, no top level class } }