Search in sources :

Example 1 with PsiModificationTrackerImpl

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();
    }
}
Also used : PsiModificationTrackerImpl(com.intellij.psi.impl.PsiModificationTrackerImpl)

Example 2 with PsiModificationTrackerImpl

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;
}
Also used : PsiModificationTrackerImpl(com.intellij.psi.impl.PsiModificationTrackerImpl) PsiManager(com.intellij.psi.PsiManager)

Example 3 with PsiModificationTrackerImpl

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();
        }
    }
}
Also used : Language(com.intellij.lang.Language) PlainTextLanguage(com.intellij.openapi.fileTypes.PlainTextLanguage) PsiModificationTrackerImpl(com.intellij.psi.impl.PsiModificationTrackerImpl)

Example 4 with PsiModificationTrackerImpl

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());
}
Also used : FileReferenceInjector(org.intellij.plugins.intelliLang.references.FileReferenceInjector) PsiElement(com.intellij.psi.PsiElement) Element(org.jdom.Element) PsiModificationTrackerImpl(com.intellij.psi.impl.PsiModificationTrackerImpl) FileReference(com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference)

Example 5 with PsiModificationTrackerImpl

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);
}
Also used : PsiManagerImpl(com.intellij.psi.impl.PsiManagerImpl) PsiModificationTrackerImpl(com.intellij.psi.impl.PsiModificationTrackerImpl)

Aggregations

PsiModificationTrackerImpl (com.intellij.psi.impl.PsiModificationTrackerImpl)8 Project (com.intellij.openapi.project.Project)2 PsiElement (com.intellij.psi.PsiElement)2 Language (com.intellij.lang.Language)1 Application (com.intellij.openapi.application.Application)1 PlainTextLanguage (com.intellij.openapi.fileTypes.PlainTextLanguage)1 PsiManager (com.intellij.psi.PsiManager)1 PsiManagerImpl (com.intellij.psi.impl.PsiManagerImpl)1 FileReference (com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference)1 PsiModificationTracker (com.intellij.psi.util.PsiModificationTracker)1 File (java.io.File)1 FileReferenceInjector (org.intellij.plugins.intelliLang.references.FileReferenceInjector)1 Element (org.jdom.Element)1