コード例 #1
0
  public static ArrayList<String> getExtendedTypeClasses(Project project, String... formTypeNames) {

    List<String> formTypeNamesList = Arrays.asList(formTypeNames);

    ArrayList<String> extendedTypeClasses = new ArrayList<String>();

    FormExtensionServiceParser formExtensionServiceParser =
        ServiceXmlParserFactory.getInstance(project, FormExtensionServiceParser.class);
    for (String formClass : formExtensionServiceParser.getFormExtensions().keySet()) {

      PsiElement psiElements[] =
          PhpElementsUtil.getPsiElementsBySignature(
              project, "#M#C\\" + formClass + ".getExtendedType");
      for (PsiElement psiElement : psiElements) {
        PhpReturn phpReturn = PsiTreeUtil.findChildOfType(psiElement, PhpReturn.class);
        if (phpReturn != null) {
          PhpPsiElement returnValue = phpReturn.getFirstPsiChild();
          if (returnValue instanceof StringLiteralExpression
              && formTypeNamesList.contains(
                  ((StringLiteralExpression) returnValue).getContents())) {
            extendedTypeClasses.add(formClass);
          }
        }
      }
    }

    return extendedTypeClasses;
  }
コード例 #2
0
  private static HashMap<String, String> getFormDefaultKeys(
      Project project, String formTypeName, HashMap<String, String> defaultValues, int depth) {

    PhpClass phpClass = FormUtil.getFormTypeToClass(project, formTypeName);
    if (phpClass == null) {
      return defaultValues;
    }

    String typeClass = phpClass.getPresentableFQN();
    attachOnDefaultOptions(project, defaultValues, typeClass);

    // recursive search for parent form types
    PsiElement getParent =
        PhpElementsUtil.getPsiElementsBySignatureSingle(
            project, "#M#C\\" + phpClass.getPresentableFQN() + ".getParent");
    if (getParent != null && depth < 10) {
      PhpReturn phpReturn = PsiTreeUtil.findChildOfType(getParent, PhpReturn.class);
      if (phpReturn != null) {
        PhpPsiElement returnValue = phpReturn.getFirstPsiChild();
        if (returnValue instanceof StringLiteralExpression) {
          getFormDefaultKeys(
              project,
              ((StringLiteralExpression) returnValue).getContents(),
              defaultValues,
              depth++);
        }
      }
    }

    return defaultValues;
  }