use of com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl in project intellij-community by JetBrains.
the class HighlightVisitorInternalInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
final PsiFile file = holder.getFile();
if (InjectedLanguageManager.getInstance(file.getProject()).isInjectedFragment(file)) {
return PsiElementVisitor.EMPTY_VISITOR;
}
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(file);
if (virtualFile == null || virtualFile.getFileType() != StdFileTypes.JAVA || CompilerConfiguration.getInstance(holder.getProject()).isExcludedFromCompilation(virtualFile)) {
return PsiElementVisitor.EMPTY_VISITOR;
}
return new HighlightVisitorImpl(JavaPsiFacade.getInstance(holder.getProject()).getResolveHelper()) {
{
prepareToRunAsInspection(new HighlightInfoHolder(file) {
@Override
public boolean add(@Nullable HighlightInfo info) {
if (super.add(info)) {
if (info != null && info.getSeverity() == HighlightSeverity.ERROR) {
final int startOffset = info.getStartOffset();
final PsiElement element = file.findElementAt(startOffset);
if (element != null) {
holder.registerProblem(element, info.getDescription());
}
}
return true;
}
return false;
}
@Override
public boolean hasErrorResults() {
//accept multiple errors per file
return false;
}
});
}
};
}
Aggregations