Examples of ConstructorDeclaration


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

    tyDecl.memberTypes = new TypeDeclaration[0];
    tyDecl.fields = new FieldDeclaration[0];
    if (TypeDeclaration.kind(tyDecl.modifiers) != TypeDeclaration.INTERFACE_DECL &&
        TypeDeclaration.kind(tyDecl.modifiers) != TypeDeclaration.ENUM_DECL) {
      // Create a default constructor so that the class is proper.
      ConstructorDeclaration constructor = tyDecl.createDefaultConstructor(true, true);
      // Mark only constructor as private so that it can not be instantiated.
      constructor.modifiers = ClassFileConstants.AccPrivate;
      // Clear a bit that is used for marking the constructor as default as it makes JDT
      // assume that the constructor is public.
      constructor.bits &= ~ASTNode.IsDefaultConstructor;
View Full Code Here

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

        }
      }
    }

    if (method.isConstructor()) {
      ConstructorDeclaration decl = new ConstructorDeclaration(this.compilationResult);
      decl.bits &= ~ASTNode.IsDefaultConstructor;
      decl.typeParameters = typeParams;
      methodDeclaration = decl;
    } else {
      MethodDeclaration decl = type.isAnnotation() ? new AnnotationMethodDeclaration(this.compilationResult) : new MethodDeclaration(this.compilationResult);
View Full Code Here

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

    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

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

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

}
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

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

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

}
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

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

        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

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

        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

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

    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
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.