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();
}
}
});
});
});
}
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);
}
}
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();
}
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;
}
};
}
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;
}
Aggregations