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

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


    return;
  }

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


}
private void visitIfNeeded(AbstractMethodDeclaration method) {
  if (this.localDeclarationVisitor != null
    && (method.bits & ASTNode.HasLocalType) != 0) {
      if (method instanceof ConstructorDeclaration) {
        ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) method;
        if (constructorDeclaration.constructorCall != null) {
          constructorDeclaration.constructorCall.traverse(this.localDeclarationVisitor, method.scope);
        }
      }
      if (method.statements != null) {
View Full Code Here

        this.methodDeclaration.bodyEnd = block.sourceEnd;
      }

      /* first statement might be an explict constructor call destinated to a special slot */
      if (this.methodDeclaration.isConstructor()) {
        ConstructorDeclaration constructor = (ConstructorDeclaration)this.methodDeclaration;
        if (this.methodDeclaration.statements != null
          && this.methodDeclaration.statements[0] instanceof ExplicitConstructorCall){
          constructor.constructorCall = (ExplicitConstructorCall)this.methodDeclaration.statements[0];
          int length = this.methodDeclaration.statements.length;
          System.arraycopy(
View Full Code Here

        compilerOptions.defaultEncoding);

    final CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
    CompilationUnitDeclaration compilationUnitDeclaration = new CompilationUnitDeclaration(problemReporter, compilationResult, length);

    ConstructorDeclaration constructorDeclaration = new ConstructorDeclaration(compilationResult);
    constructorDeclaration.sourceEnd  = -1;
    constructorDeclaration.declarationSourceEnd = offset + length - 1;
    constructorDeclaration.bodyStart = offset;
    constructorDeclaration.bodyEnd = offset + length - 1;
View Full Code Here

    if (this.sourceLength == -1) {
      this.sourceLength = this.rawSource.length;
    }
    switch(this.astKind) {
      case K_STATEMENTS :
        ConstructorDeclaration constructorDeclaration = codeSnippetParsingUtil.parseStatements(
            this.rawSource,
            this.sourceOffset,
            this.sourceLength,
            this.compilerOptions,
            true,
View Full Code Here

    }
    return internalFormatExpression(source, indentationLevel, lineSeparator, expression, regions, includeComments);
  }

  private TextEdit formatStatements(String source, int indentationLevel, String lineSeparator, IRegion[] regions, boolean includeComments) {
    ConstructorDeclaration constructorDeclaration = this.codeSnippetParsingUtil.parseStatements(source.toCharArray(), getDefaultCompilerOptions(), true, false);

    if (constructorDeclaration.statements == null) {
      // a problem occured while parsing the source
      return null;
    }
View Full Code Here

    if (bodyDeclarations != null) {
      return internalFormatClassBodyDeclarations(source, indentationLevel, lineSeparator, bodyDeclarations, regions, includeComments);
    }

    // probe for statements
    ConstructorDeclaration constructorDeclaration = this.codeSnippetParsingUtil.parseStatements(source.toCharArray(), getDefaultCompilerOptions(), true, false);
    if (constructorDeclaration.statements != null) {
      return internalFormatStatements(source, indentationLevel, lineSeparator, constructorDeclaration, regions, includeComments);
    }

    // this has to be a compilation unit
View Full Code Here

    return;
  }

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

}
private void visitIfNeeded(AbstractMethodDeclaration method) {
  if (this.localDeclarationVisitor != null
    && (method.bits & ASTNode.HasLocalType) != 0) {
      if (method instanceof ConstructorDeclaration) {
        ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) method;
        if (constructorDeclaration.constructorCall != null) {
          constructorDeclaration.constructorCall.traverse(this.localDeclarationVisitor, method.scope);
        }
      }
      if (method.statements != null) {
View Full Code Here

      }
    }
  }

  // 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) {
View Full Code Here

TOP

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

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.