Examples of ExplicitConstructorCall


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

  }

  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

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

  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

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

  (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

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

  (2) :
  ExplicitConstructorInvocation ::= Name '.' TypeArguments 'super' '(' ArgumentListopt ')' ';'
  ExplicitConstructorInvocation ::= Name '.' TypeArguments '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

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

    if (!containsComment(cd.bodyStart, cd.bodyEnd)) {
      cd.bits |= ASTNode.UndocumentedEmptyBlock;
    }
  }

  ExplicitConstructorCall explicitConstructorCall = cd.constructorCall;
  if (explicitConstructorCall != null && explicitConstructorCall.sourceEnd == 0) {
    explicitConstructorCall.sourceEnd = cd.sourceEnd;
    explicitConstructorCall.sourceStart = cd.sourceStart;
  }
}
View Full Code Here

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

protected ASTNode wrapWithExplicitConstructorCallIfNeeded(ASTNode ast) {
  int selector;
  if (ast != null && topKnownElementKind(ASSIST_PARSER) == K_SELECTOR && ast instanceof Expression &&
      (((selector = topKnownElementInfo(ASSIST_PARSER)) == THIS_CONSTRUCTOR) ||
      (selector == SUPER_CONSTRUCTOR))) {
    ExplicitConstructorCall call = new ExplicitConstructorCall(
      (selector == THIS_CONSTRUCTOR) ?
        ExplicitConstructorCall.This :
        ExplicitConstructorCall.Super
    );
    call.arguments = new Expression[] {(Expression)ast};
View Full Code Here

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

  } else {
    super.consumeMethodInvocationName();
    return;
  }

  final ExplicitConstructorCall constructorCall = new SelectionOnExplicitConstructorCall(accessMode);
  constructorCall.sourceEnd = this.rParenPos;
  constructorCall.sourceStart = (int) (this.identifierPositionStack[this.identifierPtr] >>> 32);
  int length;
  if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
    this.expressionPtr -= length;
    System.arraycopy(this.expressionStack, this.expressionPtr + 1, constructorCall.arguments = new Expression[length], 0, length);
  }

  if (!this.diet){
    pushOnAstStack(constructorCall);
    this.restartRecovery  = true// force to restart in recovery mode
    this.lastIgnoredToken = -1;
  } else {
    pushOnExpressionStack(new Expression(){
      public TypeBinding resolveType(BlockScope scope) {
        constructorCall.resolve(scope);
        return null;
      }
      public StringBuffer printExpression(int indent, StringBuffer output) {
        return output;
      }
View Full Code Here

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

  } else {
    super.consumeMethodInvocationPrimary();
    return;
  }

  final ExplicitConstructorCall constructorCall = new SelectionOnExplicitConstructorCall(accessMode);
  constructorCall.sourceEnd = this.rParenPos;
  int length;
  if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
    this.expressionPtr -= length;
    System.arraycopy(this.expressionStack, this.expressionPtr + 1, constructorCall.arguments = new Expression[length], 0, length);
  }
  constructorCall.qualification = this.expressionStack[this.expressionPtr--];
  constructorCall.sourceStart = constructorCall.qualification.sourceStart;

  if (!this.diet){
    pushOnAstStack(constructorCall);
    this.restartRecovery  = true// force to restart in recovery mode
    this.lastIgnoredToken = -1;
  } else {
    pushOnExpressionStack(new Expression(){
      public TypeBinding resolveType(BlockScope scope) {
        constructorCall.resolve(scope);
        return null;
      }
      public StringBuffer printExpression(int indent, StringBuffer output) {
        return output;
      }
View Full Code Here

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

        currentMethod = ctor;
        currentMethodBody = (JMethodBody) ctor.getBody();
        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 = enclosingType.getMethods().get(0);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.