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());
}
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());
}
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());
}
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());
}
Aggregations