Package org.eclipse.jdt.internal.compiler.ast

Examples of org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall


      return null;
    }

    this.lastLocalDeclarationSourceStart = -1;
    try {
      ExplicitConstructorCall explicitConstructorCall = constructorDeclaration.constructorCall;
      if (explicitConstructorCall != null && !explicitConstructorCall.isImplicitSuper()) {
        explicitConstructorCall.traverse(this, null);
      }
      Statement[] statements = constructorDeclaration.statements;
      if (statements != null) {
        formatStatements(null, statements, false);
      }
View Full Code Here


  }

  if (methodDeclaration.isDefaultConstructor()) {
    if (this.reportReferenceInfo) {
      ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) methodDeclaration;
      ExplicitConstructorCall constructorCall = constructorDeclaration.constructorCall;
      if (constructorCall != null) {
        switch(constructorCall.accessMode) {
          case ExplicitConstructorCall.This :
            this.requestor.acceptConstructorReference(
              this.typeNames[this.nestedTypeIndex-1],
              constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
              constructorCall.sourceStart);
            break;
          case ExplicitConstructorCall.Super :
          case ExplicitConstructorCall.ImplicitSuper :
            this.requestor.acceptConstructorReference(
              this.superTypeNames[this.nestedTypeIndex-1],
              constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
              constructorCall.sourceStart);
            break;
        }
      }
    }
    return;
  }
  char[][] argumentTypes = null;
  char[][] argumentNames = null;
  boolean isVarArgs = false;
  Argument[] arguments = methodDeclaration.arguments;
  ParameterInfo[] parameterInfos = null;
  ISourceElementRequestor.MethodInfo methodInfo = new ISourceElementRequestor.MethodInfo();
  methodInfo.typeAnnotated = ((methodDeclaration.bits & ASTNode.HasTypeAnnotations) != 0);

  if (arguments != null) {
    Object[][] argumentInfos = getArgumentInfos(arguments);
    parameterInfos = (ParameterInfo[]) argumentInfos[0];
    argumentTypes = (char[][]) argumentInfos[1][0];
    argumentNames = (char[][]) argumentInfos[1][1];

    isVarArgs = arguments[arguments.length-1].isVarArgs();
  }
  char[][] thrownExceptionTypes = getThrownExceptions(methodDeclaration);
  // by default no selector end position
  int selectorSourceEnd = -1;
  if (methodDeclaration.isConstructor()) {
    selectorSourceEnd = this.sourceEnds.get(methodDeclaration);
    if (isInRange){
      int currentModifiers = methodDeclaration.modifiers;
      currentModifiers &= ExtraCompilerModifiers.AccJustFlag | ClassFileConstants.AccDeprecated;
      if (isVarArgs)
        currentModifiers |= ClassFileConstants.AccVarargs;
      if (hasDeprecatedAnnotation(methodDeclaration.annotations))
        currentModifiers |= ClassFileConstants.AccDeprecated;

      methodInfo.isConstructor = true;
      methodInfo.declarationStart = methodDeclaration.declarationSourceStart;
      methodInfo.modifiers = currentModifiers;
      methodInfo.name = methodDeclaration.selector;
      methodInfo.nameSourceStart = methodDeclaration.sourceStart;
      methodInfo.nameSourceEnd = selectorSourceEnd;
      methodInfo.parameterTypes = argumentTypes;
      methodInfo.parameterNames = argumentNames;
      methodInfo.exceptionTypes = thrownExceptionTypes;
      methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
      methodInfo.parameterInfos = parameterInfos;
      methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
      methodInfo.annotations = methodDeclaration.annotations;
      methodInfo.declaringPackageName = currentPackage == null ? CharOperation.NO_CHAR : CharOperation.concatWith(currentPackage.tokens, '.');
      methodInfo.declaringTypeModifiers = declaringType.modifiers;
      methodInfo.extraFlags = ExtraFlags.getExtraFlags(declaringType);
      methodInfo.node = methodDeclaration;
      this.requestor.enterConstructor(methodInfo);
    }
    if (this.reportReferenceInfo) {
      ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) methodDeclaration;
      ExplicitConstructorCall constructorCall = constructorDeclaration.constructorCall;
      if (constructorCall != null) {
        switch(constructorCall.accessMode) {
          case ExplicitConstructorCall.This :
            this.requestor.acceptConstructorReference(
              this.typeNames[this.nestedTypeIndex-1],
View Full Code Here

        currentMethod = ctor;
        currentMethodScope = x.scope;

        JMethodCall superOrThisCall = null;
        ExplicitConstructorCall ctorCall = x.constructorCall;
        if (ctorCall != null) {
          superOrThisCall = (JMethodCall) dispatch("processExpression",
              ctorCall);
        }

        /*
         * Determine if we have an explicit this call. The presence of an
         * explicit this call indicates we can skip certain initialization steps
         * (as the callee will perform those steps for us). These skippable
         * steps are 1) assigning synthetic args to fields and 2) running
         * initializers.
         */
        boolean hasExplicitThis = (ctorCall != null)
            && !ctorCall.isSuperAccess();

        JClassType enclosingType = (JClassType) ctor.getEnclosingType();

        // Call clinit; $clinit is always in position 0.
        JMethod clinitMethod = (JMethod) enclosingType.methods.get(0);
View Full Code Here

  }

  if (methodDeclaration.isDefaultConstructor()) {
    if (this.reportReferenceInfo) {
      ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) methodDeclaration;
      ExplicitConstructorCall constructorCall = constructorDeclaration.constructorCall;
      if (constructorCall != null) {
        switch(constructorCall.accessMode) {
          case ExplicitConstructorCall.This :
            this.requestor.acceptConstructorReference(
              this.typeNames[this.nestedTypeIndex-1],
              constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
              constructorCall.sourceStart);
            break;
          case ExplicitConstructorCall.Super :
          case ExplicitConstructorCall.ImplicitSuper :
            this.requestor.acceptConstructorReference(
              this.superTypeNames[this.nestedTypeIndex-1],
              constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
              constructorCall.sourceStart);
            break;
        }
      }
    }
    return;
  }
  char[][] argumentTypes = null;
  char[][] argumentNames = null;
  boolean isVarArgs = false;
  Argument[] arguments = methodDeclaration.arguments;
  if (arguments != null) {
    char[][][] argumentTypesAndNames = getArguments(arguments);
    argumentTypes = argumentTypesAndNames[0];
    argumentNames = argumentTypesAndNames[1];

    isVarArgs = arguments[arguments.length-1].isVarArgs();
  }
  char[][] thrownExceptionTypes = getThrownExceptions(methodDeclaration);
  // by default no selector end position
  int selectorSourceEnd = -1;
  if (methodDeclaration.isConstructor()) {
    selectorSourceEnd = this.sourceEnds.get(methodDeclaration);
    if (isInRange){
      int currentModifiers = methodDeclaration.modifiers;
      if (isVarArgs)
        currentModifiers |= ClassFileConstants.AccVarargs;

      // remember deprecation so as to not lose it below
      boolean deprecated = (currentModifiers & ClassFileConstants.AccDeprecated) != 0 || hasDeprecatedAnnotation(methodDeclaration.annotations);

      ISourceElementRequestor.MethodInfo methodInfo = new ISourceElementRequestor.MethodInfo();
      methodInfo.isConstructor = true;
      methodInfo.declarationStart = methodDeclaration.declarationSourceStart;
      methodInfo.modifiers = deprecated ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated : currentModifiers & ExtraCompilerModifiers.AccJustFlag;
      methodInfo.name = methodDeclaration.selector;
      methodInfo.nameSourceStart = methodDeclaration.sourceStart;
      methodInfo.nameSourceEnd = selectorSourceEnd;
      methodInfo.parameterTypes = argumentTypes;
      methodInfo.parameterNames = argumentNames;
      methodInfo.exceptionTypes = thrownExceptionTypes;
      methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
      methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
      methodInfo.annotations = methodDeclaration.annotations;
      methodInfo.declaringPackageName = currentPackage == null ? CharOperation.NO_CHAR : CharOperation.concatWith(currentPackage.tokens, '.');
      methodInfo.declaringTypeModifiers = declaringType.modifiers;
      methodInfo.extraFlags = ExtraFlags.getExtraFlags(declaringType);
      methodInfo.node = methodDeclaration;
      this.requestor.enterConstructor(methodInfo);
    }
    if (this.reportReferenceInfo) {
      ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) methodDeclaration;
      ExplicitConstructorCall constructorCall = constructorDeclaration.constructorCall;
      if (constructorCall != null) {
        switch(constructorCall.accessMode) {
          case ExplicitConstructorCall.This :
            this.requestor.acceptConstructorReference(
              this.typeNames[this.nestedTypeIndex-1],
View Full Code Here

   * @see BindingResolver#resolveConstructor(ConstructorInvocation)
   */
  synchronized IMethodBinding resolveConstructor(ConstructorInvocation expression) {
    org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(expression);
    if (node instanceof ExplicitConstructorCall) {
      ExplicitConstructorCall explicitConstructorCall = (ExplicitConstructorCall) node;
      return getMethodBinding(explicitConstructorCall.binding);
    }
    return null;
  }
View Full Code Here

   * @see BindingResolver#resolveConstructor(SuperConstructorInvocation)
   */
  synchronized IMethodBinding resolveConstructor(SuperConstructorInvocation expression) {
    org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(expression);
    if (node instanceof ExplicitConstructorCall) {
      ExplicitConstructorCall explicitConstructorCall = (ExplicitConstructorCall) node;
      return getMethodBinding(explicitConstructorCall.binding);
    }
    return null;
  }
View Full Code Here

      return null;
    }

    this.lastLocalDeclarationSourceStart = -1;
    try {
      ExplicitConstructorCall explicitConstructorCall = constructorDeclaration.constructorCall;
      if (explicitConstructorCall != null && !explicitConstructorCall.isImplicitSuper()) {
        explicitConstructorCall.traverse(this, null);
      }
      Statement[] statements = constructorDeclaration.statements;
      if (statements != null) {
        formatStatements(null, statements, false);
      }
View Full Code Here

  }

  if (methodDeclaration.isDefaultConstructor()) {
    if (this.reportReferenceInfo) {
      ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) methodDeclaration;
      ExplicitConstructorCall constructorCall = constructorDeclaration.constructorCall;
      if (constructorCall != null) {
        switch(constructorCall.accessMode) {
          case ExplicitConstructorCall.This :
            this.requestor.acceptConstructorReference(
              this.typeNames[this.nestedTypeIndex-1],
              constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
              constructorCall.sourceStart);
            break;
          case ExplicitConstructorCall.Super :
          case ExplicitConstructorCall.ImplicitSuper :
            this.requestor.acceptConstructorReference(
              this.superTypeNames[this.nestedTypeIndex-1],
              constructorCall.arguments == null ? 0 : constructorCall.arguments.length,
              constructorCall.sourceStart);
            break;
        }
      }
    }
    return;
  }
  char[][] argumentTypes = null;
  char[][] argumentNames = null;
  boolean isVarArgs = false;
  Argument[] arguments = methodDeclaration.arguments;
  ParameterInfo[] parameterInfos = null;
  if (arguments != null) {
    Object[][] argumentInfos = getArgumentInfos(arguments);
    parameterInfos = (ParameterInfo[]) argumentInfos[0];
    argumentTypes = (char[][]) argumentInfos[1][0];
    argumentNames = (char[][]) argumentInfos[1][1];

    isVarArgs = arguments[arguments.length-1].isVarArgs();
  }
  char[][] thrownExceptionTypes = getThrownExceptions(methodDeclaration);
  // by default no selector end position
  int selectorSourceEnd = -1;
  if (methodDeclaration.isConstructor()) {
    selectorSourceEnd = this.sourceEnds.get(methodDeclaration);
    if (isInRange){
      int currentModifiers = methodDeclaration.modifiers;
      if (isVarArgs)
        currentModifiers |= ClassFileConstants.AccVarargs;

      // remember deprecation so as to not lose it below
      boolean deprecated = (currentModifiers & ClassFileConstants.AccDeprecated) != 0 || hasDeprecatedAnnotation(methodDeclaration.annotations);

      ISourceElementRequestor.MethodInfo methodInfo = new ISourceElementRequestor.MethodInfo();
      methodInfo.isConstructor = true;
      methodInfo.declarationStart = methodDeclaration.declarationSourceStart;
      methodInfo.modifiers = deprecated ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated : currentModifiers & ExtraCompilerModifiers.AccJustFlag;
      methodInfo.name = methodDeclaration.selector;
      methodInfo.nameSourceStart = methodDeclaration.sourceStart;
      methodInfo.nameSourceEnd = selectorSourceEnd;
      methodInfo.parameterTypes = argumentTypes;
      methodInfo.parameterNames = argumentNames;
      methodInfo.exceptionTypes = thrownExceptionTypes;
      methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
      methodInfo.parameterInfos = parameterInfos;
      methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
      methodInfo.annotations = methodDeclaration.annotations;
      methodInfo.declaringPackageName = currentPackage == null ? CharOperation.NO_CHAR : CharOperation.concatWith(currentPackage.tokens, '.');
      methodInfo.declaringTypeModifiers = declaringType.modifiers;
      methodInfo.extraFlags = ExtraFlags.getExtraFlags(declaringType);
      methodInfo.node = methodDeclaration;
      this.requestor.enterConstructor(methodInfo);
    }
    if (this.reportReferenceInfo) {
      ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) methodDeclaration;
      ExplicitConstructorCall constructorCall = constructorDeclaration.constructorCall;
      if (constructorCall != null) {
        switch(constructorCall.accessMode) {
          case ExplicitConstructorCall.This :
            this.requestor.acceptConstructorReference(
              this.typeNames[this.nestedTypeIndex-1],
View Full Code Here

  this.intPtr--;
  this.intPtr--;

  //statements
  this.realBlockPtr--;
  ExplicitConstructorCall constructorCall = null;
  Statement[] statements = null;
  if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
    this.astPtr -= length;
    if (!this.options.ignoreMethodBodies) {
      if (this.astStack[this.astPtr + 1] instanceof ExplicitConstructorCall) {
        //avoid a isSomeThing that would only be used here BUT what is faster between two alternatives ?
        System.arraycopy(
          this.astStack,
          this.astPtr + 2,
          statements = new Statement[length - 1],
          0,
          length - 1);
        constructorCall = (ExplicitConstructorCall) this.astStack[this.astPtr + 1];
      } else { //need to add explicitly the super();
        System.arraycopy(
          this.astStack,
          this.astPtr + 1,
          statements = new Statement[length],
          0,
          length);
        constructorCall = SuperReference.implicitSuperConstructorCall();
      }
    }
  } else {
    boolean insideFieldInitializer = false;
    if (this.diet) {
      for (int i = this.nestedType; i > 0; i--){
        if (this.variablesCounter[i] > 0) {
          insideFieldInitializer = true;
          break;
        }
      }
    }

    if (!this.options.ignoreMethodBodies) {
      if (!this.diet || insideFieldInitializer){
        // add it only in non-diet mode, if diet_bodies, then constructor call will be added elsewhere.
        constructorCall = SuperReference.implicitSuperConstructorCall();
      }
    }
  }

  // now we know that the top of stack is a constructorDeclaration
  ConstructorDeclaration cd = (ConstructorDeclaration) this.astStack[this.astPtr];
  cd.constructorCall = constructorCall;
  cd.statements = statements;

  //highlight of the implicit call on the method name
  if (constructorCall != null && cd.constructorCall.sourceEnd == 0) {
    cd.constructorCall.sourceEnd = cd.sourceEnd;
    cd.constructorCall.sourceStart = cd.sourceStart;
  }

  if (!(this.diet && this.dietInt == 0)
      && statements == null
      && (constructorCall == null || constructorCall.isImplicitSuper())
      && !containsComment(cd.bodyStart, this.endPosition)) {
    cd.bits |= ASTNode.UndocumentedEmptyBlock;
  }

  //watch for } that could be given as a unicode ! ( u007D is '}' )
View Full Code Here

  (2) :
  ExplicitConstructorInvocation ::= Name '.' 'super' '(' ArgumentListopt ')' ';'
  ExplicitConstructorInvocation ::= Name '.' 'this' '(' ArgumentListopt ')' ';'
  */
  int startPosition = this.intStack[this.intPtr--];
  ExplicitConstructorCall ecc = new ExplicitConstructorCall(recFlag);
  int length;
  if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
    this.expressionPtr -= length;
    System.arraycopy(this.expressionStack, this.expressionPtr + 1, ecc.arguments = new Expression[length], 0, length);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall

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.