Search in sources :

Example 1 with FileReferenceInjector

use of org.intellij.plugins.intelliLang.references.FileReferenceInjector in project intellij-community by JetBrains.

the class ReferenceInjectionTest method testInjectReference.

public void testInjectReference() throws Exception {
    myFixture.configureByText("foo.xml", "<foo xmlns=\"http://foo.bar\" \n" + "     xxx=\"ba<caret>r\"/>");
    assertNull(myFixture.getReferenceAtCaretPosition());
    assertTrue(new InjectLanguageAction().isAvailable(getProject(), myFixture.getEditor(), myFixture.getFile()));
    assertFalse(new UnInjectLanguageAction().isAvailable(getProject(), myFixture.getEditor(), myFixture.getFile()));
    InjectLanguageAction.invokeImpl(getProject(), myFixture.getEditor(), myFixture.getFile(), new FileReferenceInjector());
    assertTrue(myFixture.getReferenceAtCaretPosition() instanceof FileReference);
    assertFalse(new InjectLanguageAction().isAvailable(getProject(), myFixture.getEditor(), myFixture.getFile()));
    assertTrue(new UnInjectLanguageAction().isAvailable(getProject(), myFixture.getEditor(), myFixture.getFile()));
    myFixture.configureByText("bar.xml", "<foo xmlns=\"<error descr=\"URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs)\">http://foo.bar</error>\" \n" + "     xxx=\"<error descr=\"Cannot resolve file 'bar'\">b<caret>ar</error>\"/>");
    myFixture.testHighlighting();
    UnInjectLanguageAction.invokeImpl(getProject(), myFixture.getEditor(), myFixture.getFile());
    assertNull(myFixture.getReferenceAtCaretPosition());
}
Also used : FileReferenceInjector(org.intellij.plugins.intelliLang.references.FileReferenceInjector) InjectLanguageAction(org.intellij.plugins.intelliLang.inject.InjectLanguageAction) UnInjectLanguageAction(org.intellij.plugins.intelliLang.inject.UnInjectLanguageAction) FileReference(com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference) UnInjectLanguageAction(org.intellij.plugins.intelliLang.inject.UnInjectLanguageAction)

Example 2 with FileReferenceInjector

use of org.intellij.plugins.intelliLang.references.FileReferenceInjector in project intellij-community by JetBrains.

the class ReferenceInjectionTest method testInjectIntoJava.

public void testInjectIntoJava() throws Exception {
    myFixture.configureByText("Foo.java", "class Foo {\n" + "    String bar() {\n" + "        return \"ba<caret>r.xml\";\n" + "    }    \n" + "}");
    assertNull(getInjectedReferences());
    InjectLanguageAction.invokeImpl(getProject(), myFixture.getEditor(), myFixture.getFile(), new FileReferenceInjector());
    PsiReference[] references = getInjectedReferences();
    PsiReference reference = assertOneElement(references);
    assertTrue(reference instanceof FileReference);
    UnInjectLanguageAction.invokeImpl(getProject(), myFixture.getEditor(), myFixture.getFile());
    assertNull(getInjectedReferences());
}
Also used : FileReferenceInjector(org.intellij.plugins.intelliLang.references.FileReferenceInjector) PsiReference(com.intellij.psi.PsiReference) FileReference(com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference)

Example 3 with FileReferenceInjector

use of org.intellij.plugins.intelliLang.references.FileReferenceInjector 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 4 with FileReferenceInjector

use of org.intellij.plugins.intelliLang.references.FileReferenceInjector in project intellij-community by JetBrains.

the class ReferenceInjectionTest method testInjectIntoTagValue.

public void testInjectIntoTagValue() throws Exception {
    myFixture.configureByText("foo.xml", "<foo xmlns=\"http://foo.bar\" <bar>x<caret>xx</bar>/>");
    assertNull(myFixture.getReferenceAtCaretPosition());
    InjectLanguageAction.invokeImpl(getProject(), myFixture.getEditor(), myFixture.getFile(), new FileReferenceInjector());
    assertTrue(myFixture.getReferenceAtCaretPosition() instanceof FileReference);
    UnInjectLanguageAction.invokeImpl(getProject(), myFixture.getEditor(), myFixture.getFile());
    assertNull(myFixture.getReferenceAtCaretPosition());
}
Also used : FileReferenceInjector(org.intellij.plugins.intelliLang.references.FileReferenceInjector) FileReference(com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference)

Aggregations

FileReference (com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference)4 FileReferenceInjector (org.intellij.plugins.intelliLang.references.FileReferenceInjector)4 PsiElement (com.intellij.psi.PsiElement)1 PsiReference (com.intellij.psi.PsiReference)1 PsiModificationTrackerImpl (com.intellij.psi.impl.PsiModificationTrackerImpl)1 InjectLanguageAction (org.intellij.plugins.intelliLang.inject.InjectLanguageAction)1 UnInjectLanguageAction (org.intellij.plugins.intelliLang.inject.UnInjectLanguageAction)1 Element (org.jdom.Element)1