use of com.intellij.psi.PsiReference in project intellij-community by JetBrains.
the class PyKnownDecoratorUtil method resolveDecorator.
@Nullable
private static PsiElement resolveDecorator(@NotNull PyDecorator decorator) {
final PyExpression callee = decorator.getCallee();
if (callee == null) {
return null;
}
final PsiReference reference = callee.getReference();
if (reference == null) {
return null;
}
return reference.resolve();
}
use of com.intellij.psi.PsiReference in project intellij-community by JetBrains.
the class PyInjectionResolveTest method doResolve.
@Override
protected PsiElement doResolve() {
myFixture.configureByFile("resolve/" + getTestName(false) + ".py");
final PsiFile psiFile = myFixture.getFile();
final int markerOffset = findMarkerOffset(psiFile);
final InjectedLanguageManager manager = InjectedLanguageManager.getInstance(myFixture.getProject());
final PsiElement injectedElement = manager.findInjectedElementAt(psiFile, markerOffset);
assertNotNull("no injected element found at <ref> position", injectedElement);
PsiReference reference = null;
final PyReferenceOwner referenceOwner = PsiTreeUtil.getParentOfType(injectedElement, PyReferenceOwner.class);
if (referenceOwner != null) {
reference = referenceOwner.getReference();
}
assertNotNull("no reference found at <ref> position", reference);
return reference.resolve();
}
use of com.intellij.psi.PsiReference in project intellij-community by JetBrains.
the class ResolveLabelTest method testLabelResolve.
public void testLabelResolve() throws Exception {
final PsiReference ref = configureByFile(getTestName(true) + "/" + getTestName(false) + ".groovy");
final PsiElement resolved = ref.resolve();
assertNotNull(resolved);
assertInstanceOf(resolved, GrLabeledStatement.class);
}
use of com.intellij.psi.PsiReference in project intellij-community by JetBrains.
the class MavenReferenceConverter method createReferences.
@NotNull
public PsiReference[] createReferences(GenericDomValue value, PsiElement element, ConvertContext context) {
String text = value.getStringValue();
TextRange range = ElementManipulators.getValueTextRange(element);
return new PsiReference[] { createReference(element, text, range) };
}
use of com.intellij.psi.PsiReference in project intellij-community by JetBrains.
the class MavenSmartCompletionContributor method getVariants.
@NotNull
private static Collection<?> getVariants(CompletionParameters parameters) {
if (!MavenDomUtil.isMavenFile(parameters.getOriginalFile()))
return Collections.emptyList();
SmartList<?> result = new SmartList<>();
for (PsiReference each : getReferences(parameters)) {
if (each instanceof TagNameReference)
continue;
if (each instanceof GenericDomValueReference) {
GenericDomValueReference reference = (GenericDomValueReference) each;
Converter converter = reference.getConverter();
if (converter instanceof MavenSmartConverter) {
Collection variants = ((MavenSmartConverter) converter).getSmartVariants(reference.getConvertContext());
if (converter instanceof ResolvingConverter) {
addVariants((ResolvingConverter) converter, variants, result);
} else {
result.addAll(variants);
}
} else if (converter instanceof ResolvingConverter) {
//noinspection unchecked
ResolvingConverter resolvingConverter = (ResolvingConverter) converter;
Collection variants = resolvingConverter.getVariants(reference.getConvertContext());
addVariants(resolvingConverter, variants, result);
}
} else {
//noinspection unchecked
Collections.addAll((Collection) result, each.getVariants());
}
}
return result;
}
Aggregations