public String getTypeName() {

    return clazz.getName();
  }
예제 #2
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;
 }
  @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;
  }