Ejemplo n.º 1
0
  public static Map<String, PsiElement> getTemplateAnnotationFiles(PhpDocTag phpDocTag) {

    // find template name on annotation parameter
    // @Template("templatename")
    PhpPsiElement phpDocAttrList = phpDocTag.getFirstPsiChild();
    if (phpDocAttrList == null) {
      return null;
    }

    String tagValue = phpDocAttrList.getText();
    Matcher matcher = Pattern.compile("\\(\"(.*)\"").matcher(tagValue);

    Map<String, PsiElement> templateFiles = new HashMap<String, PsiElement>();

    if (matcher.find()) {
      // @TODO: only one should possible; refactor getTemplatePsiElements
      PsiElement[] psiElement =
          TwigHelper.getTemplatePsiElements(phpDocTag.getProject(), matcher.group(1));
      if (psiElement.length > 0) {
        templateFiles.put(matcher.group(1), psiElement[0]);
      }
    }

    return templateFiles;
  }
 protected List<PsiFile> templateGoto(PsiElement psiElement, String templateName) {
   return Arrays.asList(TwigHelper.getTemplatePsiElements(psiElement.getProject(), templateName));
 }