Package org.eclipse.php.internal.core.compiler.ast.nodes

Examples of org.eclipse.php.internal.core.compiler.ast.nodes.PHPDocBlock


              byte[] code = pdttFile.getFile().trim().getBytes();
              InputStreamReader reader = new InputStreamReader(
                  new ByteArrayInputStream(code));
              DocumentorLexer lexer = new DocumentorLexer(reader);
              PHPDocBlock phpDocBlock = lexer.parse();
              assertContents(pdttFile.getExpected(),
                  ASTPrintVisitor.toXMLString(phpDocBlock));
            }
          });
        } catch (final Exception e) {
View Full Code Here


   * ()
   */
  public ITypeBinding[] getExceptionTypes() {
    // Get an array of PHPDocFields
    ArrayList<ITypeBinding> exeptions = new ArrayList<ITypeBinding>();
    PHPDocBlock docBlock = PHPModelUtils.getDocBlock(modelElement);
    PHPDocTag[] docTags = docBlock.getTags();
    for (PHPDocTag tag : docTags) {
      if (tag.getTagKind() == PHPDocTag.THROWS) {
        SimpleReference[] references = tag.getReferences();
        // TODO - create ITypeBinding array from this SimpleReference
        // array
View Full Code Here

    if (parent.getElementType() != IModelElement.TYPE) {
      return;
    }

    IType type = (IType) parent;
    final PHPDocBlock docBlock = PHPModelUtils.getDocBlock(type);
    if (docBlock != null) {
      IType currentNamespace = PHPModelUtils.getCurrentNamespace(type);
      for (PHPDocTag tag : docBlock.getTags()) {
        final int tagKind = tag.getTagKind();
        if (tagKind == PHPDocTag.METHOD) {
          final String typeName = getTypeBinding(methodName, tag);
          if (typeName != null) {
            Matcher m = PHPDocClassVariableEvaluator.ARRAY_TYPE_PATTERN
View Full Code Here

          IType[] superTypes = superHierarchy.getAllTypes();
          for (IType superType : superTypes) {
            IField[] typeField = PHPModelUtils.getTypeField(
                superType, variableName, true);
            if (typeField.length > 0) {
              PHPDocBlock docBlock = PHPModelUtils
                  .getDocBlock(typeField[0]);
              if (docBlock != null) {
                docs.put(docBlock, typeField[0]);
              }
            }
          }
        } catch (ModelException e) {
          if (DLTKCore.DEBUG) {
            e.printStackTrace();
          }
        }
      }
    }

    for (Entry<PHPDocBlock, IField> entry : docs.entrySet()) {
      PHPDocBlock doc = entry.getKey();
      IField typeField = entry.getValue();
      IType currentNamespace = PHPModelUtils
          .getCurrentNamespace(typeField);
      for (PHPDocTag tag : doc.getTags()) {
        if (tag.getTagKind() == PHPDocTag.VAR) {
          SimpleReference[] references = tag.getReferences();
          for (SimpleReference ref : references) {
            String typeName = ref.getName();
            Matcher m = ARRAY_TYPE_PATTERN.matcher(typeName);
            if (m.find()) {
              evaluated.add(getArrayType(m.group(),
                  currentNamespace, doc.sourceStart()));
            } else if (typeName.endsWith(BRACKETS)
                && typeName.length() > 2) {
              offset = 0;
              try {
                offset = typeField.getSourceRange().getOffset();
              } catch (ModelException e) {
              }
              evaluated.add(getArrayType(typeName.substring(0,
                  typeName.length() - 2), currentNamespace,
                  offset));

            } else {
              if (currentNamespace != null) {
                ModuleDeclaration moduleDeclaration = SourceParserUtil
                    .getModuleDeclaration(currentNamespace
                        .getSourceModule());
                if (typeName.indexOf(SPLASH) > 0) {
                  // check if the first part is an
                  // alias,then get the full name
                  String prefix = typeName.substring(0,
                      typeName.indexOf(SPLASH));
                  final Map<String, UsePart> result = PHPModelUtils
                      .getAliasToNSMap(prefix,
                          moduleDeclaration,
                          doc.sourceStart(),
                          currentNamespace, true);
                  if (result.containsKey(prefix)) {
                    String fullName = result.get(prefix)
                        .getNamespace()
                        .getFullyQualifiedName();
                    typeName = typeName.replace(prefix,
                        fullName);
                    if (typeName.charAt(0) != NamespaceReference.NAMESPACE_SEPARATOR) {
                      typeName = NamespaceReference.NAMESPACE_SEPARATOR
                          + typeName;
                    }
                  }
                } else if (typeName.indexOf(SPLASH) < 0) {
                  String prefix = typeName;
                  final Map<String, UsePart> result = PHPModelUtils
                      .getAliasToNSMap(prefix,
                          moduleDeclaration,
                          doc.sourceStart(),
                          currentNamespace, true);
                  if (result.containsKey(prefix)) {
                    String fullName = result.get(prefix)
                        .getNamespace()
                        .getFullyQualifiedName();
View Full Code Here

    * Check if the class is tagged to be used as an annotation.
    *
    */
    private void parseAnnotation(ClassDeclaration clazz) {

        PHPDocBlock block = clazz.getPHPDoc();
       
        if (block == null) {
            return;
        }

        boolean isAnnotation = false;
        if (block.getCommentType() == Comment.TYPE_PHPDOC) {
           
            List<Annotation> annotations = null;
            if (org.apache.commons.lang.StringUtils.isNotBlank(block.getLongDescription())) {
              annotations = parser.parse(block.getLongDescription());
            } else if (org.apache.commons.lang.StringUtils.isNotBlank(block.getShortDescription())) {
              annotations = parser.parse(block.getShortDescription());
            }
           
            if (annotations != null) {
              for (Annotation annotation : annotations) {
                if (annotation.getClassName().equals("Annotation")) {
View Full Code Here

            return false;

        if (s instanceof PHPMethodDeclaration) {

            PHPMethodDeclaration method = (PHPMethodDeclaration) s;
            PHPDocBlock docBlock = method.getPHPDoc();

            if (docBlock != null) {

                PHPDocTag[] tags = docBlock.getTags();

                for (PHPDocTag tag : tags) {

                    String value = tag.getValue();
View Full Code Here

     */
    public static List<Annotation> extractAnnotations(AnnotationCommentParser parser,
                                                      IPHPDocAwareDeclaration declaration,
                                                      ISourceModule sourceModule) {
        try {
            PHPDocBlock comment = declaration.getPHPDoc();
            if (comment == null || comment.getCommentType() != Comment.TYPE_PHPDOC) {
                return EMPTY_ANNOTATIONS;
            }

            int commentStartOffset = comment.sourceStart();
            String commentSource;
            if (sourceModule != null) {
                commentSource = getCommentSource(sourceModule, commentStartOffset, comment.sourceEnd());
            } else {
                commentSource = comment.getShortDescription() + comment.getLongDescription();
            }

            return parser.parse(commentSource, commentStartOffset);
        } catch (Exception exception) {
            Logger.logException("Unable to extract annotations from declaration " + getDeclarationName(declaration), exception);
View Full Code Here

           
            if (namespaceDeclaration == null || !namespaceDeclaration.getName().endsWith("\\Controller")) {
                return false;
            }
           
            PHPDocBlock phpDoc = methodDeclaration.getPHPDoc();
           
            if (phpDoc == null || (phpDoc.sourceStart() > offset || phpDoc.sourceEnd() < offset)) {
                return false;
            }
           
            List<Annotation> annotations = AnnotationUtils.extractAnnotations(parser, methodDeclaration);
            if (annotations.size() < 1) {
View Full Code Here

        }

        @Override
        public boolean visit(PHPMethodDeclaration s) throws Exception {
            if (s.getName().equals(method)) {
                PHPDocBlock docs = s.getPHPDoc();
                PHPDocTag[] returnTags = docs.getTags(PHPDocTagKinds.RETURN);
                if (returnTags.length == 1) {
                    PHPDocTag tag = returnTags[0];

                    if (tag.getReferences().length == 1) {
                        SimpleReference ref = tag.getReferences()[0];
View Full Code Here

        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();
View Full Code Here

TOP

Related Classes of org.eclipse.php.internal.core.compiler.ast.nodes.PHPDocBlock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.