@Override
  public boolean visit(TypeDeclaration s) throws Exception {

    if (!isSymfonySource) return false;

    if (s instanceof ClassDeclaration) {
      currentClass = (ClassDeclaration) s;
      for (Object o : currentClass.getSuperClasses().getChilds()) {

        if (o instanceof FullyQualifiedReference) {

          FullyQualifiedReference superReference = (FullyQualifiedReference) o;

          // TODO: find a way to check against the FQCN
          // via the UseStatement
          if (
          /*superReference.getNamespace().equals(SymfonyCoreConstants.CONTROLLER_NS)
          && */ superReference.getName().equals(SymfonyCoreConstants.CONTROLLER_CLASS)) {

            // the ControllerIndexer does the actual work of parsing the
            // the relevant elements inside the controller
            // which are then being collected in the endVisit() method
            inController = true;
          }
        }
      }
    }

    return true;
  }
  @Override
  public boolean visit(TypeDeclaration s) throws Exception {
    if (s instanceof ClassDeclaration) {

      inTwigExtension = false;
      currentClass = (ClassDeclaration) s;

      for (String superclass : currentClass.getSuperClassNames()) {
        if (superclass.equals(TwigCoreConstants.TWIG_EXTENSION)) {
          inTwigExtension = true;
        } else if (superclass.equals(TwigCoreConstants.TWIG_TOKEN_PARSER)) {
          tag = new Tag();
          inTokenParser = true;
        }
      }
      return true;
    }
    return false;
  }
Ejemplo n.º 3
0
 public boolean visit(ClassDeclaration s) throws Exception {
   Map<String, String> parameters = createInitialParameters(s);
   parameters.put("name", s.getName());
   xmlWriter.startTag("ClassDeclaration", parameters);
   return true;
 }
  public String getTypeName() {

    return clazz.getName();
  }
  public int getInjectionOffset() {

    return clazz.getBodyEnd() - 2;
  }
  public int getEnd() {

    return clazz.getNameEnd();
  }
  public int getStart() {

    return clazz.getNameStart();
  }
  @SuppressWarnings("unchecked")
  @Override
  public boolean endvisit(TypeDeclaration s) throws Exception {
    if (s instanceof ClassDeclaration) {
      if (tag != null) {
        if (tag.getStartTag() != null) {

          int length = currentClass.sourceEnd() - currentClass.sourceStart();
          PHPDocBlock block = currentClass.getPHPDoc();
          String desc = "";
          if (block != null) {
            String shortDesc =
                block.getShortDescription() != null ? block.getShortDescription() : "";
            String longDesc = block.getLongDescription() != null ? block.getLongDescription() : "";
            desc = shortDesc + longDesc;
          }

          String endTag = tag.getEndTag();

          JSONObject metadata = new JSONObject();
          metadata.put(TwigType.PHPCLASS, currentClass.getName());
          metadata.put(TwigType.DOC, desc);
          metadata.put(TwigType.IS_OPEN_CLOSE, endTag != null);

          Logger.debugMSG(
              "indexing twig tag: "
                  + tag.getStartTag()
                  + " : "
                  + tag.getEndTag()
                  + " with metadata: "
                  + metadata.toString());

          ReferenceInfo info =
              new ReferenceInfo(
                  ITwigModelElement.START_TAG,
                  currentClass.sourceStart(),
                  length,
                  tag.getStartTag(),
                  metadata.toString(),
                  null);
          addReferenceInfo(info);

          if (endTag != null) {
            ReferenceInfo endIinfo =
                new ReferenceInfo(
                    ITwigModelElement.END_TAG,
                    currentClass.sourceStart(),
                    length,
                    tag.getEndTag(),
                    metadata.toString(),
                    null);
            addReferenceInfo(endIinfo);
          }
        }
        tag = null;
      }

      inTwigExtension = false;
      inTokenParser = false;
      currentClass = null;
    }

    return false;
  }