Search in sources :

Example 1 with FileHighlightingSetting

use of com.intellij.codeInsight.daemon.impl.analysis.FileHighlightingSetting in project intellij-community by JetBrains.

the class TrafficLightRenderer method getDaemonCodeAnalyzerStatus.

@NotNull
protected DaemonCodeAnalyzerStatus getDaemonCodeAnalyzerStatus(@NotNull SeverityRegistrar severityRegistrar) {
    DaemonCodeAnalyzerStatus status = new DaemonCodeAnalyzerStatus();
    if (myFile == null) {
        status.reasonWhyDisabled = "No file";
        status.errorAnalyzingFinished = true;
        return status;
    }
    if (myProject != null && myProject.isDisposed()) {
        status.reasonWhyDisabled = "Project is disposed";
        status.errorAnalyzingFinished = true;
        return status;
    }
    if (!myDaemonCodeAnalyzer.isHighlightingAvailable(myFile)) {
        if (!myFile.isPhysical()) {
            status.reasonWhyDisabled = "File is generated";
            status.errorAnalyzingFinished = true;
            return status;
        } else if (myFile instanceof PsiCompiledElement) {
            status.reasonWhyDisabled = "File is decompiled";
            status.errorAnalyzingFinished = true;
            return status;
        }
        final FileType fileType = myFile.getFileType();
        if (fileType.isBinary()) {
            status.reasonWhyDisabled = "File is binary";
            status.errorAnalyzingFinished = true;
            return status;
        }
        status.reasonWhyDisabled = "Highlighting is disabled for this file";
        status.errorAnalyzingFinished = true;
        return status;
    }
    FileViewProvider provider = myFile.getViewProvider();
    Set<Language> languages = provider.getLanguages();
    HighlightingSettingsPerFile levelSettings = HighlightingSettingsPerFile.getInstance(myProject);
    boolean shouldHighlight = languages.isEmpty();
    for (Language language : languages) {
        PsiFile root = provider.getPsi(language);
        FileHighlightingSetting level = levelSettings.getHighlightingSettingForRoot(root);
        shouldHighlight |= level != FileHighlightingSetting.SKIP_HIGHLIGHTING;
    }
    if (!shouldHighlight) {
        status.reasonWhyDisabled = "Highlighting level is None";
        status.errorAnalyzingFinished = true;
        return status;
    }
    if (HeavyProcessLatch.INSTANCE.isRunning()) {
        status.reasonWhySuspended = StringUtil.defaultIfEmpty(HeavyProcessLatch.INSTANCE.getRunningOperationName(), "Heavy operation is running");
        status.errorAnalyzingFinished = true;
        return status;
    }
    status.errorCount = errorCount.clone();
    List<TextEditorHighlightingPass> passes = myDaemonCodeAnalyzer.getPassesToShowProgressFor(myDocument);
    status.passStati = passes.isEmpty() ? Collections.emptyList() : new ArrayList<>(passes.size());
    //noinspection ForLoopReplaceableByForEach
    for (int i = 0; i < passes.size(); i++) {
        TextEditorHighlightingPass tepass = passes.get(i);
        if (!(tepass instanceof ProgressableTextEditorHighlightingPass))
            continue;
        ProgressableTextEditorHighlightingPass pass = (ProgressableTextEditorHighlightingPass) tepass;
        if (pass.getProgress() < 0)
            continue;
        status.passStati.add(pass);
    }
    status.errorAnalyzingFinished = myDaemonCodeAnalyzer.isAllAnalysisFinished(myFile);
    status.reasonWhySuspended = myDaemonCodeAnalyzer.isUpdateByTimerEnabled() ? null : "Highlighting is paused temporarily";
    fillDaemonCodeAnalyzerErrorsStatus(status, severityRegistrar);
    return status;
}
Also used : HighlightingSettingsPerFile(com.intellij.codeInsight.daemon.impl.analysis.HighlightingSettingsPerFile) TIntArrayList(gnu.trove.TIntArrayList) PsiCompiledElement(com.intellij.psi.PsiCompiledElement) FileHighlightingSetting(com.intellij.codeInsight.daemon.impl.analysis.FileHighlightingSetting) TextEditorHighlightingPass(com.intellij.codeHighlighting.TextEditorHighlightingPass) FileViewProvider(com.intellij.psi.FileViewProvider) Language(com.intellij.lang.Language) FileType(com.intellij.openapi.fileTypes.FileType) PsiFile(com.intellij.psi.PsiFile) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with FileHighlightingSetting

use of com.intellij.codeInsight.daemon.impl.analysis.FileHighlightingSetting in project intellij-community by JetBrains.

the class UnusedImportsTest method testWithHighlightingOff.

public void testWithHighlightingOff() throws Exception {
    configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
    final PsiFile file = getFile();
    final HighlightingSettingsPerFile settingsPerFile = HighlightingSettingsPerFile.getInstance(myProject);
    final FileHighlightingSetting oldSetting = settingsPerFile.getHighlightingSettingForRoot(file);
    try {
        settingsPerFile.setHighlightingSettingForRoot(file, FileHighlightingSetting.NONE);
        doDoTest(true, false, false);
    } finally {
        settingsPerFile.setHighlightingSettingForRoot(file, oldSetting);
    }
}
Also used : HighlightingSettingsPerFile(com.intellij.codeInsight.daemon.impl.analysis.HighlightingSettingsPerFile) PsiFile(com.intellij.psi.PsiFile) FileHighlightingSetting(com.intellij.codeInsight.daemon.impl.analysis.FileHighlightingSetting)

Aggregations

FileHighlightingSetting (com.intellij.codeInsight.daemon.impl.analysis.FileHighlightingSetting)2 HighlightingSettingsPerFile (com.intellij.codeInsight.daemon.impl.analysis.HighlightingSettingsPerFile)2 PsiFile (com.intellij.psi.PsiFile)2 TextEditorHighlightingPass (com.intellij.codeHighlighting.TextEditorHighlightingPass)1 Language (com.intellij.lang.Language)1 FileType (com.intellij.openapi.fileTypes.FileType)1 FileViewProvider (com.intellij.psi.FileViewProvider)1 PsiCompiledElement (com.intellij.psi.PsiCompiledElement)1 TIntArrayList (gnu.trove.TIntArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1