mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
Spellchecker: from anonymous to inner[IDEA-CR-24731]
This commit is contained in:
@@ -75,39 +75,7 @@ public class SpellCheckerManager implements Disposable {
|
||||
|
||||
Disposer.register(project, this);
|
||||
|
||||
myVirtualFileListener = new VirtualFileListener() {
|
||||
@Override
|
||||
public void fileDeleted(@NotNull VirtualFileEvent event) {
|
||||
final String path = toSystemDependentName(event.getFile().getPath());
|
||||
if (spellChecker.isDictionaryLoad(path)) {
|
||||
spellChecker.removeDictionary(path);
|
||||
restartInspections();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileCreated(@NotNull VirtualFileEvent event) {
|
||||
final String path = toSystemDependentName(event.getFile().getPath());
|
||||
boolean customDic = FileUtilRt.extensionEquals(path, "dic") &&
|
||||
settings.getDictionaryFoldersPaths().stream().anyMatch(dicFolderPath -> isAncestor(dicFolderPath, path, true));
|
||||
if (customDic) {
|
||||
spellChecker.loadDictionary(new FileLoader(path));
|
||||
restartInspections();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contentsChanged(@NotNull VirtualFileEvent event) {
|
||||
final String path = toSystemDependentName(event.getFile().getPath());
|
||||
if (settings.getDisabledDictionariesPaths().contains(path)) return;
|
||||
|
||||
if (spellChecker.isDictionaryLoad(path)) {
|
||||
spellChecker.removeDictionary(path);
|
||||
spellChecker.loadDictionary(new FileLoader(path));
|
||||
restartInspections();
|
||||
}
|
||||
}
|
||||
};
|
||||
myVirtualFileListener = new CustomDictVirtualFileListener(settings);
|
||||
LocalFileSystem.getInstance().addVirtualFileListener(myVirtualFileListener);
|
||||
}
|
||||
|
||||
@@ -274,4 +242,42 @@ public class SpellCheckerManager implements Disposable {
|
||||
public void dispose() {
|
||||
LocalFileSystem.getInstance().removeVirtualFileListener(myVirtualFileListener);
|
||||
}
|
||||
|
||||
private class CustomDictVirtualFileListener implements VirtualFileListener {
|
||||
private final SpellCheckerSettings mySettings;
|
||||
|
||||
public CustomDictVirtualFileListener(SpellCheckerSettings settings) {mySettings = settings;}
|
||||
|
||||
@Override
|
||||
public void fileDeleted(@NotNull VirtualFileEvent event) {
|
||||
final String path = toSystemDependentName(event.getFile().getPath());
|
||||
if (spellChecker.isDictionaryLoad(path)) {
|
||||
spellChecker.removeDictionary(path);
|
||||
restartInspections();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileCreated(@NotNull VirtualFileEvent event) {
|
||||
final String path = toSystemDependentName(event.getFile().getPath());
|
||||
boolean customDic = FileUtilRt.extensionEquals(path, "dic") &&
|
||||
mySettings.getDictionaryFoldersPaths().stream().anyMatch(dicFolderPath -> isAncestor(dicFolderPath, path, true));
|
||||
if (customDic) {
|
||||
spellChecker.loadDictionary(new FileLoader(path));
|
||||
restartInspections();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contentsChanged(@NotNull VirtualFileEvent event) {
|
||||
final String path = toSystemDependentName(event.getFile().getPath());
|
||||
if (mySettings.getDisabledDictionariesPaths().contains(path)) return;
|
||||
|
||||
if (spellChecker.isDictionaryLoad(path)) {
|
||||
spellChecker.removeDictionary(path);
|
||||
spellChecker.loadDictionary(new FileLoader(path));
|
||||
restartInspections();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user