use of com.intellij.psi.impl.PsiModificationTrackerImpl in project intellij-community by JetBrains.
the class SpellCheckerManager method acceptWordAsCorrect.
public void acceptWordAsCorrect(@NotNull String word, Project project) {
final String transformed = spellChecker.getTransformation().transform(word);
if (transformed != null) {
userDictionary.addToDictionary(transformed);
final PsiModificationTrackerImpl modificationTracker = (PsiModificationTrackerImpl) PsiManager.getInstance(project).getModificationTracker();
modificationTracker.incCounter();
}
}
use of com.intellij.psi.impl.PsiModificationTrackerImpl in project intellij-community by JetBrains.
the class ProjectRootManagerImpl method fireRootsChanged.
private boolean fireRootsChanged(boolean fileTypes) {
if (myProject.isDisposed())
return false;
ApplicationManager.getApplication().assertWriteAccessAllowed();
LOG.assertTrue(!isFiringEvent, "Do not use API that changes roots from roots events. Try using invoke later or something else.");
if (myMergedCallStarted) {
LOG.assertTrue(!fileTypes, "File types change is not supported inside merged call");
}
myRootsChangesDepth--;
if (myRootsChangesDepth > 0)
return false;
if (myRootsChangesDepth < 0) {
LOG.info("Restoring from roots change start/finish mismatch: ", new Throwable());
myRootsChangesDepth = 0;
}
clearScopesCaches();
incModificationCount();
PsiManager psiManager = PsiManager.getInstance(myProject);
psiManager.dropResolveCaches();
((PsiModificationTrackerImpl) psiManager.getModificationTracker()).incCounter();
fireRootsChangedEvent(fileTypes);
doSynchronizeRoots();
addRootsToWatch();
return true;
}
use of com.intellij.psi.impl.PsiModificationTrackerImpl in project intellij-community by JetBrains.
the class InjectLanguageAction method invokeImpl.
public static void invokeImpl(@NotNull Project project, Editor editor, final PsiFile file, Injectable injectable, @NotNull FixPresenter fixPresenter) {
final PsiLanguageInjectionHost host = findInjectionHost(editor, file);
if (host == null)
return;
if (defaultFunctionalityWorked(host, injectable.getId()))
return;
try {
host.putUserData(FIX_KEY, null);
Language language = injectable.toLanguage();
for (LanguageInjectionSupport support : InjectorUtils.getActiveInjectionSupports()) {
if (support.isApplicableTo(host) && support.addInjectionInPlace(language, host)) {
return;
}
}
if (TemporaryPlacesRegistry.getInstance(project).getLanguageInjectionSupport().addInjectionInPlace(language, host)) {
final Processor<PsiLanguageInjectionHost> data = host.getUserData(FIX_KEY);
String text = StringUtil.escapeXml(language.getDisplayName()) + " was temporarily injected.";
if (data != null) {
final SmartPsiElementPointer<PsiLanguageInjectionHost> pointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(host);
String fixText = text + "<br>Do you want to insert annotation? " + KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_SHOW_INTENTION_ACTIONS));
fixPresenter.showFix(editor, host.getTextRange(), pointer, fixText, data);
} else {
HintManager.getInstance().showInformationHint(editor, text);
}
}
} finally {
if (injectable.getLanguage() != null) {
// no need for reference injection
FileContentUtil.reparseFiles(project, Collections.<VirtualFile>emptyList(), true);
} else {
((PsiModificationTrackerImpl) PsiManager.getInstance(project).getModificationTracker()).incCounter();
DaemonCodeAnalyzer.getInstance(project).restart();
}
}
}
use of com.intellij.psi.impl.PsiModificationTrackerImpl in project intellij-community by JetBrains.
the class ReferenceInjectionTest method testSurviveSerialization.
public void testSurviveSerialization() throws Exception {
myFixture.configureByText("foo.xml", "<foo xmlns=\"http://foo.bar\" \n" + " xxx=\"ba<caret>r\"/>");
assertNull(myFixture.getReferenceAtCaretPosition());
InjectLanguageAction.invokeImpl(getProject(), myFixture.getEditor(), myFixture.getFile(), new FileReferenceInjector());
assertTrue(myFixture.getReferenceAtCaretPosition() instanceof FileReference);
Configuration configuration = Configuration.getInstance();
Element element = configuration.getState();
configuration.loadState(element);
((PsiModificationTrackerImpl) PsiManager.getInstance(getProject()).getModificationTracker()).incCounter();
assertTrue(myFixture.getReferenceAtCaretPosition() instanceof FileReference);
UnInjectLanguageAction.invokeImpl(getProject(), myFixture.getEditor(), myFixture.getFile());
assertNull(myFixture.getReferenceAtCaretPosition());
}
use of com.intellij.psi.impl.PsiModificationTrackerImpl in project intellij-community by JetBrains.
the class PsiModificationTrackerTreeChangesUpdatesTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
// since we want to test PsiModificationTrackerImpl in isolation, we create a separate instance:
// The existing PsiModificationTrackerImpl is affected by various components.
myTracker = new PsiModificationTrackerImpl(getProject());
((PsiManagerImpl) PsiManager.getInstance(getProject())).addTreeChangePreprocessor(myTracker);
}
Aggregations