1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.ast;
13 import org.eclipse.jdt.internal.compiler.lookup.*;
14 import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
15 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
17 public class JavadocAllocationExpression extends AllocationExpression {
19 public int tagSourceStart, tagSourceEnd;
20 public boolean superAccess = false;
22 public JavadocAllocationExpression(long pos) {
23 this.sourceStart = (int) (pos >>> 32);
24 this.sourceEnd = (int) pos;
25 this.bits |= InsideJavadoc;
29 * Resolves type on a Block or Class scope.
31 private TypeBinding internalResolveType(Scope scope) {
33 // Propagate the type checking to the arguments, and check if the constructor is defined.
34 this.constant = NotAConstant;
35 if (this.type == null) {
36 this.resolvedType = scope.enclosingSourceType();
37 } else if (scope.kind == Scope.CLASS_SCOPE) {
38 this.resolvedType = this.type.resolveType((ClassScope)scope);
40 this.resolvedType = this.type.resolveType((BlockScope)scope);
43 // buffering the arguments' types
44 TypeBinding[] argumentTypes = NoParameters;
45 if (this.arguments != null) {
46 boolean argHasError = false;
47 int length = this.arguments.length;
48 argumentTypes = new TypeBinding[length];
49 for (int i = 0; i < length; i++) {
50 Expression argument = this.arguments[i];
51 if (scope.kind == Scope.CLASS_SCOPE) {
52 argumentTypes[i] = argument.resolveType((ClassScope)scope);
54 argumentTypes[i] = argument.resolveType((BlockScope)scope);
56 if (argumentTypes[i] == null) {
65 // check resolved type
66 if (this.resolvedType == null) {
69 this.superAccess = scope.enclosingSourceType().isCompatibleWith(this.resolvedType);
71 ReferenceBinding allocationType = (ReferenceBinding) this.resolvedType;
72 this.binding = scope.getConstructor(allocationType, argumentTypes, this);
73 if (!this.binding.isValidBinding()) {
74 MethodBinding methodBinding = scope.getMethod(this.resolvedType, this.resolvedType.sourceName(), argumentTypes, this);
75 if (methodBinding.isValidBinding()) {
76 this.binding = methodBinding;
78 if (this.binding.declaringClass == null) {
79 this.binding.declaringClass = allocationType;
81 scope.problemReporter().javadocInvalidConstructor(this, this.binding, scope.getDeclarationModifiers());
83 return this.resolvedType;
85 if (isMethodUseDeprecated(this.binding, scope)) {
86 scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getDeclarationModifiers());
89 return allocationType;
93 * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#isSuperAccess()
95 public boolean isSuperAccess() {
96 return this.superAccess;
100 * @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.BlockScope)
102 public TypeBinding resolveType(BlockScope scope) {
103 return internalResolveType(scope);
107 * @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.BlockScope)
109 public TypeBinding resolveType(ClassScope scope) {
110 return internalResolveType(scope);