Search in sources :

Example 76 with PsiReference

use of com.intellij.psi.PsiReference in project intellij-community by JetBrains.

the class AntResolveTest method testFailProperty1.

public void testFailProperty1() throws Exception {
    PsiReference ref = configure();
    PsiElement elem = ref.resolve();
    assertTrue(elem == null);
}
Also used : PsiReference(com.intellij.psi.PsiReference) PomTargetPsiElement(com.intellij.pom.PomTargetPsiElement) PsiElement(com.intellij.psi.PsiElement)

Example 77 with PsiReference

use of com.intellij.psi.PsiReference in project intellij-community by JetBrains.

the class AntResolveTest method testPropertyInMacrodefParam.

public void testPropertyInMacrodefParam() throws Exception {
    PsiReference ref = configure();
    final PsiElement result = ref.resolve();
    assertTrue(result instanceof PomTargetPsiElement);
    final PsiElement naviElem = ((DomTarget) ((PomTargetPsiElement) result).getTarget()).getNavigationElement();
    final DomElement domElement = DomUtil.getDomElement(naviElem);
    assertNotNull(domElement);
    assertNotNull(domElement.getParentOfType(AntDomMacrodefAttribute.class, false));
}
Also used : DomElement(com.intellij.util.xml.DomElement) AntDomMacrodefAttribute(com.intellij.lang.ant.dom.AntDomMacrodefAttribute) PsiReference(com.intellij.psi.PsiReference) DomTarget(com.intellij.util.xml.DomTarget) PomTargetPsiElement(com.intellij.pom.PomTargetPsiElement) PomTargetPsiElement(com.intellij.pom.PomTargetPsiElement) PsiElement(com.intellij.psi.PsiElement)

Example 78 with PsiReference

use of com.intellij.psi.PsiReference in project intellij-community by JetBrains.

the class AntResolveTest method testFailProperty.

public void testFailProperty() throws Exception {
    PsiReference ref = configure();
    PsiElement elem = ref.resolve();
    assertTrue(elem == null);
}
Also used : PsiReference(com.intellij.psi.PsiReference) PomTargetPsiElement(com.intellij.pom.PomTargetPsiElement) PsiElement(com.intellij.psi.PsiElement)

Example 79 with PsiReference

use of com.intellij.psi.PsiReference in project intellij-community by JetBrains.

the class AntResolveTest method testIndirectRefid.

public void testIndirectRefid() throws Exception {
    PsiReference ref = configure();
    assertNotNull(ref.resolve());
}
Also used : PsiReference(com.intellij.psi.PsiReference)

Example 80 with PsiReference

use of com.intellij.psi.PsiReference in project intellij-community by JetBrains.

the class AntDomTargetDependsListConverter method createReferences.

@NotNull
public PsiReference[] createReferences(GenericDomValue<TargetResolver.Result> value, PsiElement element, ConvertContext context) {
    final XmlElement xmlElement = value.getXmlElement();
    if (!(xmlElement instanceof XmlAttribute)) {
        return PsiReference.EMPTY_ARRAY;
    }
    final XmlAttributeValue valueElement = ((XmlAttribute) xmlElement).getValueElement();
    if (valueElement == null) {
        return PsiReference.EMPTY_ARRAY;
    }
    final String refsString = value.getStringValue();
    if (refsString == null) {
        return PsiReference.EMPTY_ARRAY;
    }
    final List<PsiReference> refs = new ArrayList<>();
    final AntDomTargetReference.ReferenceGroup group = new AntDomTargetReference.ReferenceGroup();
    final TextRange wholeStringRange = ElementManipulators.getValueTextRange(valueElement);
    final StringTokenizer tokenizer = new StringTokenizer(refsString, ",", false);
    while (tokenizer.hasMoreTokens()) {
        final String token = tokenizer.nextToken();
        int tokenStartOffset = tokenizer.getCurrentPosition() - token.length();
        final String ref = token.trim();
        if (ref.length() != token.length()) {
            for (int idx = 0; idx < token.length(); idx++) {
                if (Character.isWhitespace(token.charAt(idx))) {
                    tokenStartOffset++;
                } else {
                    break;
                }
            }
        }
        refs.add(new AntDomTargetReference(element, TextRange.from(wholeStringRange.getStartOffset() + tokenStartOffset, ref.length()), group));
    }
    return refs.toArray(new PsiReference[refs.size()]);
}
Also used : XmlAttribute(com.intellij.psi.xml.XmlAttribute) ArrayList(java.util.ArrayList) PsiReference(com.intellij.psi.PsiReference) TextRange(com.intellij.openapi.util.TextRange) XmlAttributeValue(com.intellij.psi.xml.XmlAttributeValue) StringTokenizer(com.intellij.util.text.StringTokenizer) XmlElement(com.intellij.psi.xml.XmlElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiReference (com.intellij.psi.PsiReference)564 PsiElement (com.intellij.psi.PsiElement)327 NotNull (org.jetbrains.annotations.NotNull)97 Nullable (org.jetbrains.annotations.Nullable)55 TextRange (com.intellij.openapi.util.TextRange)54 PsiFile (com.intellij.psi.PsiFile)52 ArrayList (java.util.ArrayList)46 Test (org.junit.Test)40 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)36 BuildFile (com.google.idea.blaze.base.lang.buildfile.psi.BuildFile)32 IdentifierPSINode (org.ballerinalang.plugins.idea.psi.IdentifierPSINode)25 LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)23 XmlTag (com.intellij.psi.xml.XmlTag)22 VirtualFile (com.intellij.openapi.vfs.VirtualFile)21 XmlAttributeValue (com.intellij.psi.xml.XmlAttributeValue)20 PsiClass (com.intellij.psi.PsiClass)17 XmlAttribute (com.intellij.psi.xml.XmlAttribute)17 LinkedList (java.util.LinkedList)17 LookupElement (com.intellij.codeInsight.lookup.LookupElement)16 Project (com.intellij.openapi.project.Project)16