use of com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference 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());
}
use of com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference in project intellij-community by JetBrains.
the class AnchorPathReferenceProvider method createReferences.
@Override
public boolean createReferences(@NotNull final PsiElement psiElement, @NotNull final List<PsiReference> references, final boolean soft) {
final TextRange range = ElementManipulators.getValueTextRange(psiElement);
final String elementText = psiElement.getText();
final int anchorOffset = elementText.indexOf('#');
if (anchorOffset == -1) {
return false;
}
final boolean dynamic = isDynamic(psiElement, anchorOffset + 1, elementText);
if (dynamic) {
return false;
}
FileReference fileReference = null;
if (range.getStartOffset() != anchorOffset) {
fileReference = findFileReference(references);
if (fileReference == null || fileReference.resolve() == null) {
return false;
}
}
final int pos = elementText.indexOf('?', anchorOffset);
final String anchor;
try {
int endIndex = pos != -1 ? pos : range.getEndOffset();
if (endIndex <= anchorOffset) {
endIndex = anchorOffset + 1;
}
anchor = elementText.substring(anchorOffset + 1, endIndex);
} catch (StringIndexOutOfBoundsException e) {
throw new RuntimeException(elementText, e);
}
final AnchorReferenceImpl anchorReference = new AnchorReferenceImpl(anchor, fileReference, psiElement, anchorOffset + 1, soft);
references.add(anchorReference);
return false;
}
Aggregations