Search in sources :

Example 1 with InjectLanguageAction

use of org.intellij.plugins.intelliLang.inject.InjectLanguageAction 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)

Aggregations

FileReference (com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference)1 InjectLanguageAction (org.intellij.plugins.intelliLang.inject.InjectLanguageAction)1 UnInjectLanguageAction (org.intellij.plugins.intelliLang.inject.UnInjectLanguageAction)1 FileReferenceInjector (org.intellij.plugins.intelliLang.references.FileReferenceInjector)1