Search in sources :

Example 1 with DaemonCodeAnalyzer

use of com.intellij.codeInsight.daemon.DaemonCodeAnalyzer in project intellij-community by JetBrains.

the class BaseSpellChecker method doLoadDictionaryAsync.

private void doLoadDictionaryAsync(Loader loader, Consumer<Dictionary> consumer) {
    StartupManager.getInstance(myProject).runWhenProjectIsInitialized(() -> {
        LOG.debug("Loading " + loader.getName());
        Application app = ApplicationManager.getApplication();
        app.executeOnPooledThread(() -> {
            if (app.isDisposed())
                return;
            CompressedDictionary dictionary = CompressedDictionary.create(loader, transform);
            LOG.debug(loader.getName() + " loaded!");
            consumer.consume(dictionary);
            while (!myDictionariesToLoad.isEmpty()) {
                if (app.isDisposed())
                    return;
                Pair<Loader, Consumer<Dictionary>> nextDictionary = myDictionariesToLoad.remove(0);
                Loader nextDictionaryLoader = nextDictionary.getFirst();
                dictionary = CompressedDictionary.create(nextDictionaryLoader, transform);
                LOG.debug(nextDictionaryLoader.getName() + " loaded!");
                nextDictionary.getSecond().consume(dictionary);
            }
            LOG.debug("Loading finished, restarting daemon...");
            myLoadingDictionaries.set(false);
            UIUtil.invokeLaterIfNeeded(() -> {
                if (app.isDisposed())
                    return;
                for (final Project project : ProjectManager.getInstance().getOpenProjects()) {
                    if (project.isInitialized() && project.isOpen() && !project.isDefault()) {
                        DaemonCodeAnalyzer instance = DaemonCodeAnalyzer.getInstance(project);
                        if (instance != null)
                            instance.restart();
                    }
                }
            });
        });
    });
}
Also used : Project(com.intellij.openapi.project.Project) Consumer(com.intellij.util.Consumer) CompressedDictionary(com.intellij.spellchecker.compress.CompressedDictionary) DaemonCodeAnalyzer(com.intellij.codeInsight.daemon.DaemonCodeAnalyzer) Loader(com.intellij.spellchecker.dictionary.Loader) Application(com.intellij.openapi.application.Application)

Example 2 with DaemonCodeAnalyzer

use of com.intellij.codeInsight.daemon.DaemonCodeAnalyzer 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);
    }
}
Also used : Project(com.intellij.openapi.project.Project) InspectionProfileWrapper(com.intellij.codeInspection.ex.InspectionProfileWrapper) InspectionProfileImpl(com.intellij.codeInspection.ex.InspectionProfileImpl) DaemonCodeAnalyzer(com.intellij.codeInsight.daemon.DaemonCodeAnalyzer) PsiFile(com.intellij.psi.PsiFile)

Example 3 with DaemonCodeAnalyzer

use of com.intellij.codeInsight.daemon.DaemonCodeAnalyzer in project intellij-community by JetBrains.

the class HectorComponent method forceDaemonRestart.

private void forceDaemonRestart() {
    final FileViewProvider viewProvider = myFile.getViewProvider();
    for (Language language : mySliders.keySet()) {
        JSlider slider = mySliders.get(language);
        PsiElement root = viewProvider.getPsi(language);
        assert root != null : "No root in " + viewProvider + " for " + language;
        int value = slider.getValue();
        if (value == 1) {
            HighlightLevelUtil.forceRootHighlighting(root, FileHighlightingSetting.SKIP_HIGHLIGHTING);
        } else if (value == 2) {
            HighlightLevelUtil.forceRootHighlighting(root, FileHighlightingSetting.SKIP_INSPECTION);
        } else {
            HighlightLevelUtil.forceRootHighlighting(root, FileHighlightingSetting.FORCE_HIGHLIGHTING);
        }
    }
    final DaemonCodeAnalyzer analyzer = DaemonCodeAnalyzer.getInstance(myFile.getProject());
    analyzer.restart();
}
Also used : FileViewProvider(com.intellij.psi.FileViewProvider) Language(com.intellij.lang.Language) DaemonCodeAnalyzer(com.intellij.codeInsight.daemon.DaemonCodeAnalyzer) PsiElement(com.intellij.psi.PsiElement) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 4 with DaemonCodeAnalyzer

use of com.intellij.codeInsight.daemon.DaemonCodeAnalyzer in project intellij-community by JetBrains.

the class ImportPopupHectorComponentProvider method createConfigurable.

@Override
public HectorComponentPanel createConfigurable(@NotNull final PsiFile file) {
    final Project project = file.getProject();
    final DaemonCodeAnalyzer analyzer = DaemonCodeAnalyzer.getInstance(project);
    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
    final VirtualFile virtualFile = file.getVirtualFile();
    assert virtualFile != null;
    final boolean notInLibrary = !fileIndex.isInLibrarySource(virtualFile) && !fileIndex.isInLibraryClasses(virtualFile) || fileIndex.isInContent(virtualFile);
    return new HectorComponentPanel() {

        private JCheckBox myImportPopupCheckBox = new JCheckBox(EditorBundle.message("hector.import.popup.checkbox"));

        @Override
        public JComponent createComponent() {
            DialogUtil.registerMnemonic(myImportPopupCheckBox);
            return myImportPopupCheckBox;
        }

        @Override
        public boolean isModified() {
            return myImportPopupCheckBox.isSelected() != analyzer.isImportHintsEnabled(file);
        }

        @Override
        public void apply() throws ConfigurationException {
            analyzer.setImportHintsEnabled(file, myImportPopupCheckBox.isSelected());
        }

        @Override
        public void reset() {
            myImportPopupCheckBox.setSelected(analyzer.isImportHintsEnabled(file));
            myImportPopupCheckBox.setEnabled(analyzer.isAutohintsAvailable(file));
            myImportPopupCheckBox.setVisible(notInLibrary);
        }

        @Override
        public void disposeUIResources() {
            myImportPopupCheckBox = null;
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) HectorComponentPanel(com.intellij.openapi.editor.HectorComponentPanel) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) DaemonCodeAnalyzer(com.intellij.codeInsight.daemon.DaemonCodeAnalyzer)

Example 5 with DaemonCodeAnalyzer

use of com.intellij.codeInsight.daemon.DaemonCodeAnalyzer in project intellij-community by JetBrains.

the class UseConsoleInputAction method setSelected.

@Override
public void setSelected(AnActionEvent event, boolean state) {
    useProcessStdIn = !state;
    LanguageConsoleView consoleView = (LanguageConsoleView) event.getData(LangDataKeys.CONSOLE_VIEW);
    assert consoleView != null;
    DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(consoleView.getProject());
    PsiFile file = consoleView.getFile();
    daemonCodeAnalyzer.setHighlightingEnabled(file, state);
    daemonCodeAnalyzer.restart(file);
    PropertiesComponent.getInstance().setValue(processInputStateKey, useProcessStdIn);
    List<AnAction> actions = ActionUtil.getActions(consoleView.getConsoleEditor().getComponent());
    ConsoleExecuteAction action = ContainerUtil.findInstance(actions, ConsoleExecuteAction.class);
    action.myExecuteActionHandler.myUseProcessStdIn = !state;
}
Also used : DaemonCodeAnalyzer(com.intellij.codeInsight.daemon.DaemonCodeAnalyzer) PsiFile(com.intellij.psi.PsiFile) AnAction(com.intellij.openapi.actionSystem.AnAction)

Aggregations

DaemonCodeAnalyzer (com.intellij.codeInsight.daemon.DaemonCodeAnalyzer)12 Project (com.intellij.openapi.project.Project)5 PsiFile (com.intellij.psi.PsiFile)4 Document (com.intellij.openapi.editor.Document)2 Editor (com.intellij.openapi.editor.Editor)2 PsiElement (com.intellij.psi.PsiElement)2 DaemonCodeAnalyzerImpl (com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl)1 HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)1 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)1 IntentionHintComponent (com.intellij.codeInsight.intention.impl.IntentionHintComponent)1 InspectionProfileImpl (com.intellij.codeInspection.ex.InspectionProfileImpl)1 InspectionProfileWrapper (com.intellij.codeInspection.ex.InspectionProfileWrapper)1 Language (com.intellij.lang.Language)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 Application (com.intellij.openapi.application.Application)1 HectorComponentPanel (com.intellij.openapi.editor.HectorComponentPanel)1 DocumentEx (com.intellij.openapi.editor.ex.DocumentEx)1 MarkupModelEx (com.intellij.openapi.editor.ex.MarkupModelEx)1 RangeHighlighterEx (com.intellij.openapi.editor.ex.RangeHighlighterEx)1 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)1