Search in sources :

Example 6 with AntDomProject

use of com.intellij.lang.ant.dom.AntDomProject in project intellij-community by JetBrains.

the class AntDomDocumentationProvider method getHelpFile.

@Nullable
private static VirtualFile getHelpFile(AntDomElement antElement, final VirtualFile documentationRoot) {
    final XmlTag xmlTag = antElement.getXmlTag();
    if (xmlTag == null) {
        return null;
    }
    @NonNls final String helpFileShortName = "/" + xmlTag.getName() + ".html";
    for (String folderName : DOC_FOLDER_NAMES) {
        final VirtualFile candidateHelpFile = documentationRoot.findFileByRelativePath(folderName + helpFileShortName);
        if (candidateHelpFile != null) {
            return candidateHelpFile;
        }
    }
    if (antElement instanceof AntDomTarget || antElement instanceof AntDomProject) {
        final VirtualFile candidateHelpFile = documentationRoot.findFileByRelativePath("using.html");
        if (candidateHelpFile != null) {
            return candidateHelpFile;
        }
    }
    return null;
}
Also used : NonNls(org.jetbrains.annotations.NonNls) AntDomTarget(com.intellij.lang.ant.dom.AntDomTarget) XmlTag(com.intellij.psi.xml.XmlTag) AntDomProject(com.intellij.lang.ant.dom.AntDomProject) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with AntDomProject

use of com.intellij.lang.ant.dom.AntDomProject in project intellij-community by JetBrains.

the class CustomTypesTest method doTest.

protected void doTest() throws Exception {
    String name = getTestName(false);
    String text = loadFile(name + ".ant");
    PsiFile file = myFixture.addFileToProject(name + ".ant", text);
    final AntDomProject antProject = AntSupport.getAntDomProject(file);
    final Ref<Boolean> found = new Ref<>(false);
    antProject.accept(new AntDomRecursiveVisitor() {

        @Override
        public void visitAntDomElement(AntDomElement element) {
            if (!found.get()) {
                super.visitAntDomElement(element);
            }
        }

        @Override
        public void visitAntDomCustomElement(AntDomCustomElement element) {
            final Class clazz = element.getDefinitionClass();
            if (clazz != null && AntCustomTask.class.getName().equals(clazz.getName())) {
                found.set(true);
            } else {
                super.visitAntDomElement(element);
            }
        }
    });
    assertTrue(found.get());
}
Also used : Ref(com.intellij.openapi.util.Ref) AntDomCustomElement(com.intellij.lang.ant.dom.AntDomCustomElement) AntDomElement(com.intellij.lang.ant.dom.AntDomElement) AntCustomTask(com.intellij.lang.ant.typedefs.AntCustomTask) AntDomRecursiveVisitor(com.intellij.lang.ant.dom.AntDomRecursiveVisitor) PsiFile(com.intellij.psi.PsiFile) AntDomProject(com.intellij.lang.ant.dom.AntDomProject)

Aggregations

AntDomProject (com.intellij.lang.ant.dom.AntDomProject)7 Nullable (org.jetbrains.annotations.Nullable)5 AntDomElement (com.intellij.lang.ant.dom.AntDomElement)3 AntDomTarget (com.intellij.lang.ant.dom.AntDomTarget)3 PsiFile (com.intellij.psi.PsiFile)3 AntDomRecursiveVisitor (com.intellij.lang.ant.dom.AntDomRecursiveVisitor)2 Ref (com.intellij.openapi.util.Ref)2 XmlFile (com.intellij.psi.xml.XmlFile)2 XmlTag (com.intellij.psi.xml.XmlTag)2 DomManager (com.intellij.util.xml.DomManager)2 NonNls (org.jetbrains.annotations.NonNls)2 AntInstallation (com.intellij.lang.ant.config.impl.AntInstallation)1 AntDomCustomElement (com.intellij.lang.ant.dom.AntDomCustomElement)1 TargetResolver (com.intellij.lang.ant.dom.TargetResolver)1 AntCustomTask (com.intellij.lang.ant.typedefs.AntCustomTask)1 File (java.io.File)1