Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.ArrayType


     *
     * @param fieldDeclaration - field declaration
     * @return an ArrayTypeFieldMetadata, that contains information about an array type.
     */
    protected FieldMetadata processArrayTypeFrom( FieldDeclaration fieldDeclaration ) {
        ArrayType arrayType = (ArrayType)fieldDeclaration.getType();
        FieldMetadata arrayTypeFieldMetadata = null;
        // the element type is never an array type
        Type type = arrayType.getElementType();
        if (type.isPrimitiveType()) {
            PrimitiveType primitiveType = (PrimitiveType)type;
            arrayTypeFieldMetadata = FieldMetadata.arrayType(primitiveType.getPrimitiveTypeCode().toString());
            processModifiersAndVariablesOfFieldDeclaration(fieldDeclaration, arrayTypeFieldMetadata);
            arrayTypeFieldMetadata.setName(getFieldName(fieldDeclaration));
View Full Code Here


   * Appends to the given buffer the fully qualified name (as it appears in the source) of the given type
   */
  private static void getFullyQualifiedName(Type type, StringBuffer buffer) {
    switch (type.getNodeType()) {
      case ASTNode.ARRAY_TYPE:
        ArrayType arrayType = (ArrayType) type;
        getFullyQualifiedName(arrayType.getElementType(), buffer);
        for (int i = 0, length = arrayType.getDimensions(); i < length; i++) {
          buffer.append('[');
          buffer.append(']');
        }
        break;
      case ASTNode.PARAMETERIZED_TYPE:
View Full Code Here

  /*
   * @see ASTVisitor#visit(ArrayCreation)
   */
  public boolean visit(ArrayCreation node) {
    this.buffer.append("new ");//$NON-NLS-1$
    ArrayType at = node.getType();
    int dims = at.getDimensions();
    Type elementType = at.getElementType();
    elementType.accept(this);
    for (Iterator it = node.dimensions().iterator(); it.hasNext(); ) {
      this.buffer.append("[");//$NON-NLS-1$
      Expression e = (Expression) it.next();
      e.accept(this);
View Full Code Here

   * Appends to the given buffer the fully qualified name (as it appears in the source) of the given type
   */
  private static void getFullyQualifiedName(Type type, StringBuffer buffer) {
    switch (type.getNodeType()) {
      case ASTNode.ARRAY_TYPE:
        ArrayType arrayType = (ArrayType) type;
        getFullyQualifiedName(arrayType.getElementType(), buffer);
        for (int i = 0, length = arrayType.getDimensions(); i < length; i++) {
          buffer.append('[');
          buffer.append(']');
        }
        break;
      case ASTNode.PARAMETERIZED_TYPE:
View Full Code Here

      case ASTNode.SIMPLE_TYPE: {
        return Signature.createTypeSignature(
            binding.getQualifiedName(), true);
      }
      case ASTNode.ARRAY_TYPE: {
        ArrayType a = (ArrayType) type;
        return Signature
            .createArraySignature(
                getTypeSignature(a.getElementType()),
                a.getDimensions());
      }
      case ASTNode.PARAMETERIZED_TYPE: {
        // we don't need to care about the other scoping types only the
        // base type
        return getTypeSignature(((ParameterizedType) type).getType());
View Full Code Here

  public boolean visit(ArrayCreation node) {
    if (!isActive()) {
      return false;
    }

    ArrayType arrayType = node.getType();

    ITypeBinding binding = resolveTypeBinding(arrayType);
    if (binding != null && isALocalType(binding.getElementType())) {
      addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Local_type_array_instance_creation_cannot_be_used_in_an_evaluation_expression_29);
      setHasError(true);
      return false;
    }

    push(new ArrayAllocation(arrayType.getDimensions(), node.dimensions()
        .size(), node.getInitializer() != null, fCounter));

    return true;
  }
View Full Code Here

    }
    Type t = extracTypeInfo2(node);
    if (t instanceof PrimitiveType) {
      return null;
    } else if (t instanceof ArrayType) {
      ArrayType at = (ArrayType) t;
      log(at.getComponentType() + " <-comp type, ele type-> "
          + at.getElementType() + ", "
          + at.getElementType().getClass().getName());
      if (at.getElementType() instanceof PrimitiveType) {
        return null;
      } else if (at.getElementType() instanceof SimpleType) {
        return (SimpleType) at.getElementType();
      } else
        return null;
    } else if (t instanceof ParameterizedType) {
      ParameterizedType pmt = (ParameterizedType) t;
      log(pmt.getType() + ", " + pmt.getType().getClass());
View Full Code Here

      final TypeInfo returnTypeInfo = new TypeInfo(methodDeclaration.getReturnType2(), compilationUnitInfo);
      declSpecifier = returnTypeInfo.getDeclSpecifier();
      if (returnTypeInfo.isSimple() && !returnTypeInfo.getType().resolveBinding().isEnum()) {
        functionDeclarator.addPointerOperator(f.newPointer());
      } else if (methodDeclaration.getReturnType2().isArrayType()) {
        final ArrayType arrayType = (ArrayType) methodDeclaration.getReturnType2();
        for (int i = 0; i < arrayType.getDimensions(); i++) {
          functionDeclarator.addPointerOperator(f.newPointer());
        }
      }
    }
View Full Code Here

    when(dataTypeUtils.getPrimitiveTypeCodes()).thenReturn(primitiveTypes);
    when(dataTypeUtils.isPrimitiveType(Mockito.anyString())).thenReturn(
        true);

    String typeName = "byte[]";
    ArrayType tp = jdtHelper.getAstArrayType(ast, typeName);

    assertEquals("byte[]", tp.toString());
  }
View Full Code Here

      componentType = getAstPrimitiveType(ast, typeName);
    } else {
      componentType = getAstSimpleType(ast, typeName);
    }

    ArrayType arrayType = ast.newArrayType(componentType);
    return arrayType;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.ArrayType

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.