private AntBuildFileBase addBuildFileImpl(final VirtualFile file) throws AntNoFileException { PsiFile xmlFile = myPsiManager.findFile(file); if (!(xmlFile instanceof XmlFile)) { throw new AntNoFileException("the file is not an xml file", file); } AntSupport.markFileAsAntFile(file, xmlFile.getProject(), true); if (!AntDomFileDescription.isAntFile(((XmlFile)xmlFile))) { throw new AntNoFileException("the file is not recognized as an ANT file", file); } final AntBuildFileImpl buildFile = new AntBuildFileImpl((XmlFile)xmlFile, this); synchronized (myBuildFiles) { myBuildFilesArray = null; myBuildFiles.add(buildFile); } return buildFile; }
@Nullable public XmlFile getContextFile(@Nullable final XmlFile file) { if (file == null) { return null; } final VirtualFile context = myAntFileToContextFileMap.get(file.getVirtualFile()); if (context == null) { return null; } final PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(context); if (!(psiFile instanceof XmlFile)) { return null; } final XmlFile xmlFile = (XmlFile)psiFile; return AntDomFileDescription.isAntFile(xmlFile)? xmlFile : null; }
@Nullable public XmlFile getAntFile() { final PsiFile psiFile = myVFile.isValid() ? PsiManager.getInstance(getProject()).findFile(myVFile) : null; if (!(psiFile instanceof XmlFile)) { return null; } final XmlFile xmlFile = (XmlFile)psiFile; return AntDomFileDescription.isAntFile(xmlFile) ? xmlFile : null; }
@Nullable private static PsiElement[] getElements(DataContext dataContext) { final PsiFile psiFile = CommonDataKeys.PSI_FILE.getData(dataContext); if (!(psiFile instanceof XmlFile && AntDomFileDescription.isAntFile((XmlFile)psiFile))) { return null; } final Editor editor = LangDataKeys.EDITOR.getData(dataContext); if (editor == null) { return null; } return getPsiElementsIn(editor, psiFile); }
@Nullable private static PsiElement[] getElements(DataContext dataContext) { final PsiFile psiFile = LangDataKeys.PSI_FILE.getData(dataContext); if (!(psiFile instanceof XmlFile && AntDomFileDescription.isAntFile((XmlFile)psiFile))) { return null; } final Editor editor = LangDataKeys.EDITOR.getData(dataContext); if (editor == null) { return null; } return getPsiElementsIn(editor, psiFile); }
@Override @Nullable public XmlFile getAntFile() { final PsiFile psiFile = myVFile.isValid() ? PsiManager.getInstance(getProject()).findFile(myVFile) : null; if(!(psiFile instanceof XmlFile)) { return null; } final XmlFile xmlFile = (XmlFile) psiFile; return AntDomFileDescription.isAntFile(xmlFile) ? xmlFile : null; }
@Nullable private static PsiElement[] getElements(DataContext dataContext) { final PsiFile psiFile = dataContext.getData(LangDataKeys.PSI_FILE); if (!(psiFile instanceof XmlFile && AntDomFileDescription.isAntFile((XmlFile)psiFile))) { return null; } final Editor editor = dataContext.getData(LangDataKeys.EDITOR); if (editor == null) { return null; } return getPsiElementsIn(editor, psiFile); }
@Override public boolean isProhibited(ExternalAnnotator annotator, PsiFile file) { return annotator instanceof XMLExternalAnnotator && file instanceof XmlFile && AntDomFileDescription.isAntFile((XmlFile)file); }
public HectorComponentPanel createConfigurable(@NotNull final PsiFile file) { if (file instanceof XmlFile && AntDomFileDescription.isAntFile(((XmlFile)file))) { return new AntHectorConfigurable(((XmlFile)file)); } return null; }