Search in sources :

Example 1 with WebDirectoryElement

use of com.intellij.psi.jsp.WebDirectoryElement in project intellij-plugins by JetBrains.

the class JamResultPathTest method testResolveActionValue.

/**
   * "value" resolving to web-dir.
   */
public void testResolveActionValue() throws Exception {
    myFixture.copyFileToProject("/WEB-INF/customContent/test.jsp");
    myFixture.copyFileToProject("jam/ActionValue.java");
    final JamResultPath jamResultPath = getClassJam("jam.ActionValue", JamResultPath.META_CLASS);
    final WebDirectoryElement webDirectoryElement = jamResultPath.getValue().getValue();
    assertNotNull(webDirectoryElement);
    assertEquals("/WEB-INF/customContent", webDirectoryElement.getPath());
}
Also used : WebDirectoryElement(com.intellij.psi.jsp.WebDirectoryElement)

Example 2 with WebDirectoryElement

use of com.intellij.psi.jsp.WebDirectoryElement in project intellij-plugins by JetBrains.

the class FileReferenceSetHelper method addWebDirectoryAndCurrentNamespaceAsRoots.

/**
   * Adds all {@link WebDirectoryElement}s as well as web-directory with name of given current namespace
   * (if not "root" namespace) as possible content roots.
   *
   * @param psiElement Current element.
   * @param namespace  Current namespace.
   * @param webFacet   Module.
   * @param set        FRS to patch.
   */
public static void addWebDirectoryAndCurrentNamespaceAsRoots(final PsiElement psiElement, final String namespace, final WebFacet webFacet, final FileReferenceSet set) {
    final WebDirectoryUtil directoryUtil = WebDirectoryUtil.getWebDirectoryUtil(psiElement.getProject());
    set.addCustomization(FileReferenceSet.DEFAULT_PATH_EVALUATOR_OPTION, file -> {
        final List<PsiFileSystemItem> basePathRoots = new ArrayList<>();
        final List<WebRoot> webRoots = webFacet.getWebRoots(true);
        for (final WebRoot webRoot : webRoots) {
            final String webRootPath = webRoot.getRelativePath();
            final WebDirectoryElement webRootBase = directoryUtil.findWebDirectoryElementByPath(webRootPath, webFacet);
            ContainerUtil.addIfNotNull(basePathRoots, webRootBase);
        }
        if (!Comparing.equal(namespace, StrutsPackage.DEFAULT_NAMESPACE)) {
            final WebDirectoryElement packageBase = directoryUtil.findWebDirectoryElementByPath(namespace, webFacet);
            ContainerUtil.addIfNotNull(basePathRoots, packageBase);
        }
        return basePathRoots;
    });
}
Also used : WebRoot(com.intellij.javaee.web.WebRoot) WebDirectoryUtil(com.intellij.psi.impl.source.jsp.WebDirectoryUtil) ArrayList(java.util.ArrayList) PsiFileSystemItem(com.intellij.psi.PsiFileSystemItem) WebDirectoryElement(com.intellij.psi.jsp.WebDirectoryElement)

Aggregations

WebDirectoryElement (com.intellij.psi.jsp.WebDirectoryElement)2 WebRoot (com.intellij.javaee.web.WebRoot)1 PsiFileSystemItem (com.intellij.psi.PsiFileSystemItem)1 WebDirectoryUtil (com.intellij.psi.impl.source.jsp.WebDirectoryUtil)1 ArrayList (java.util.ArrayList)1