Search in sources :

Example 56 with PsiReference

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

the class MavenFilteredPropertiesCompletionAndResolutionTest method testCustomDelimiters.

public void testCustomDelimiters() throws Exception {
    createProjectSubDir("res");
    importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<build>" + "  <resources>" + "    <resource>" + "      <directory>res</directory>" + "      <filtering>true</filtering>" + "    </resource>" + "  </resources>" + "  <plugins>" + "    <plugin>" + "      <groupId>org.apache.maven.plugins</groupId>" + "      <artifactId>maven-resources-plugin</artifactId>" + "      <version>2.5</version>" + "      <configuration>" + "        <delimiters>" + "          <delimiter>|</delimiter>" + "          <delimiter>(*]</delimiter>" + "        </delimiters>" + "      </configuration>" + "    </plugin>" + "  </plugins>" + "</build>");
    VirtualFile f = createProjectSubFile("res/foo1.properties", "foo1=${basedir}\n" + "foo2=|pom.baseUri|\n" + "foo3=a(ve|rsion]");
    assertNotNull(resolveReference(f, "basedir"));
    assertNotNull(resolveReference(f, "pom.baseUri"));
    PsiReference ref = getReference(f, "ve|rsion");
    assertNotNull(ref);
    assertTrue(ref.isSoft());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenPropertyPsiReference(org.jetbrains.idea.maven.dom.references.MavenPropertyPsiReference) PsiReference(com.intellij.psi.PsiReference)

Example 57 with PsiReference

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

the class MavenPluginCompletionAndResolutionTest method testResolvingAbsentPlugins.

public void testResolvingAbsentPlugins() throws Exception {
    removeFromLocalRepository("org/apache/maven/plugins/maven-compiler-plugin");
    createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<build>" + "  <plugins>" + "    <plugin>" + "      <artifactId><caret>maven-compiler-plugin</artifactId>" + "    </plugin>" + "  </plugins>" + "</build>");
    PsiReference ref = getReferenceAtCaret(myProjectPom);
    assertNotNull(ref);
    // shouldn't throw;
    ref.resolve();
}
Also used : PsiReference(com.intellij.psi.PsiReference)

Example 58 with PsiReference

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

the class MavenPluginCompletionAndResolutionTest method testGoalsResolution.

public void testGoalsResolution() throws Throwable {
    createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<build>" + "  <plugins>" + "    <plugin>" + "      <artifactId>maven-compiler-plugin</artifactId>" + "      <executions>" + "        <execution>" + "          <goals>" + "            <goal><caret>compile</goal>" + "          </goals>" + "        </execution>" + "      </executions>" + "    </plugin>" + "  </plugins>" + "</build>");
    PsiReference ref = getReferenceAtCaret(myProjectPom);
    assertNotNull(ref);
    PsiElement resolved = ref.resolve();
    assertNotNull(resolved);
    assertTrue(resolved instanceof XmlTag);
    assertEquals("mojo", ((XmlTag) resolved).getName());
    assertEquals("compile", ((XmlTag) resolved).findFirstSubTag("goal").getValue().getText());
}
Also used : PsiReference(com.intellij.psi.PsiReference) PsiElement(com.intellij.psi.PsiElement) XmlTag(com.intellij.psi.xml.XmlTag)

Example 59 with PsiReference

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

the class MavenPluginCompletionAndResolutionTest method testResolvingParamaters.

public void testResolvingParamaters() throws Exception {
    createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<build>" + "  <plugins>" + "    <plugin>" + "      <artifactId>maven-compiler-plugin</artifactId>" + "      <configuration>" + "        <<caret>includes></includes>" + "      </configuration>" + "    </plugin>" + "  </plugins>" + "</build>");
    PsiReference ref = getReferenceAtCaret(myProjectPom);
    assertNotNull(ref);
    PsiElement resolved = ref.resolve();
    assertNotNull(resolved);
    assertTrue(resolved instanceof XmlTag);
    assertEquals("parameter", ((XmlTag) resolved).getName());
    assertEquals("includes", ((XmlTag) resolved).findFirstSubTag("name").getValue().getText());
}
Also used : PsiReference(com.intellij.psi.PsiReference) PsiElement(com.intellij.psi.PsiElement) XmlTag(com.intellij.psi.xml.XmlTag)

Example 60 with PsiReference

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

the class PyModuleFindUsagesHandler method findReferencesToHighlight.

@NotNull
@Override
public Collection<PsiReference> findReferencesToHighlight(@NotNull PsiElement target, @NotNull SearchScope searchScope) {
    if (target instanceof PyImportedModule) {
        target = ((PyImportedModule) target).resolve();
    }
    if (target instanceof PyFile && PyNames.INIT_DOT_PY.equals(((PyFile) target).getName())) {
        List<PsiReference> result = new ArrayList<>();
        result.addAll(super.findReferencesToHighlight(target, searchScope));
        PsiElement targetDir = PyUtil.turnInitIntoDir(target);
        if (targetDir != null) {
            result.addAll(ReferencesSearch.search(targetDir, searchScope, false).findAll());
        }
        return result;
    }
    return super.findReferencesToHighlight(target, searchScope);
}
Also used : PyImportedModule(com.jetbrains.python.psi.impl.PyImportedModule) ArrayList(java.util.ArrayList) PsiReference(com.intellij.psi.PsiReference) PyFile(com.jetbrains.python.psi.PyFile) PsiElement(com.intellij.psi.PsiElement) 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