offline inspections: more detailed logging for unresolved roots

This commit is contained in:
Anna Kozlova
2019-01-15 19:38:41 +01:00
parent dcd069e43c
commit b88c26f320
2 changed files with 14 additions and 1 deletions
@@ -25,6 +25,7 @@ import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.javadoc.PsiDocComment;
@@ -139,10 +140,21 @@ public class GlobalJavaInspectionContextImpl extends GlobalJavaInspectionContext
else if (entry instanceof LibraryOrderEntry) {
final LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry)entry;
final Library library = libraryOrderEntry.getLibrary();
if (library == null || library.getFiles(OrderRootType.CLASSES).length < library.getUrls(OrderRootType.CLASSES).length) {
if (library == null) {
System.err.println(InspectionsBundle.message("offline.inspections.library.was.not.resolved",
libraryOrderEntry.getPresentableName(), module.getName()));
}
else {
Set<String> detectedUrls =
Arrays.stream(library.getFiles(OrderRootType.CLASSES)).map(file -> file.getUrl()).collect(Collectors.toSet());
HashSet<String> declaredUrls = new HashSet<>(Arrays.asList(library.getUrls(OrderRootType.CLASSES)));
declaredUrls.removeAll(detectedUrls);
if (!declaredUrls.isEmpty()) {
System.err.println(InspectionsBundle.message("offline.inspections.library.urls.were.not.resolved",
StringUtil.join(declaredUrls, ", "),
libraryOrderEntry.getPresentableName(), module.getName()));
}
}
}
}
}
@@ -743,6 +743,7 @@ nullable.stuff.problems.overridden.method.parameters.are.not.annotated=Overridde
annotate.overridden.methods.parameters=Annotate overridden method parameters as ''@{0}''
annotate.overridden.methods.parameters.family.name=Annotate overridden method parameters
offline.inspections.library.was.not.resolved=Please configure library ''{0}'' which is used in module ''{1}''
offline.inspections.library.urls.were.not.resolved=Roots {0} of the library ''{1}'' from module ''{2}'' were not resolved
report.suspicious.but.possibly.correct.method.calls=&Report suspicious but possibly correct method calls
unused.library.display.name=Unused library
unused.library.problem.descriptor=Unused library ''{0}''