use of com.intellij.codeInspection.ex.InspectionProfileWrapper in project intellij-community by JetBrains.
the class SpellCheckingEditorCustomization method customize.
@Override
public void customize(@NotNull EditorEx editor) {
boolean apply = isEnabled();
if (!READY) {
return;
}
Project project = editor.getProject();
if (project == null) {
return;
}
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
if (file == null) {
return;
}
Function<InspectionProfileImpl, InspectionProfileWrapper> strategy = file.getUserData(InspectionProfileWrapper.CUSTOMIZATION_KEY);
if (strategy == null) {
file.putUserData(InspectionProfileWrapper.CUSTOMIZATION_KEY, strategy = new MyInspectionProfileStrategy());
}
if (!(strategy instanceof MyInspectionProfileStrategy)) {
return;
}
((MyInspectionProfileStrategy) strategy).setUseSpellCheck(apply);
if (apply) {
editor.putUserData(IntentionManager.SHOW_INTENTION_OPTIONS_KEY, false);
}
// Update representation.
DaemonCodeAnalyzer analyzer = DaemonCodeAnalyzer.getInstance(project);
if (analyzer != null) {
analyzer.restart(file);
}
}
use of com.intellij.codeInspection.ex.InspectionProfileWrapper in project intellij-community by JetBrains.
the class WholeFileLocalInspectionsPassFactory method createHighlightingPass.
@Override
@Nullable
public TextEditorHighlightingPass createHighlightingPass(@NotNull final PsiFile file, @NotNull final Editor editor) {
final Long appliedModificationCount = myPsiModificationCount.get(file);
if (appliedModificationCount != null && appliedModificationCount == PsiManager.getInstance(myProject).getModificationTracker().getModificationCount()) {
//optimization
return null;
}
if (!ProblemHighlightFilter.shouldHighlightFile(file)) {
return null;
}
if (myFileToolsCache.containsKey(file) && !myFileToolsCache.get(file)) {
return null;
}
ProperTextRange visibleRange = VisibleHighlightingPassFactory.calculateVisibleRange(editor);
return new LocalInspectionsPass(file, editor.getDocument(), 0, file.getTextLength(), visibleRange, true, new DefaultHighlightInfoProcessor()) {
@NotNull
@Override
List<LocalInspectionToolWrapper> getInspectionTools(@NotNull InspectionProfileWrapper profile) {
List<LocalInspectionToolWrapper> tools = super.getInspectionTools(profile);
List<LocalInspectionToolWrapper> result = tools.stream().filter(LocalInspectionToolWrapper::runForWholeFile).collect(Collectors.toList());
myFileToolsCache.put(file, !result.isEmpty());
return result;
}
@Override
protected String getPresentableName() {
return DaemonBundle.message("pass.whole.inspections");
}
@Override
void inspectInjectedPsi(@NotNull List<PsiElement> elements, boolean onTheFly, @NotNull ProgressIndicator indicator, @NotNull InspectionManager iManager, boolean inVisibleRange, @NotNull List<LocalInspectionToolWrapper> wrappers) {
// already inspected in LIP
}
@Override
protected void applyInformationWithProgress() {
super.applyInformationWithProgress();
myPsiModificationCount.put(file, PsiManager.getInstance(myProject).getModificationTracker().getModificationCount());
}
};
}
Aggregations