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;
21 public boolean superAccess = false;
23 public JavadocAllocationExpression(long pos) {
24 this.sourceStart = (int) (pos >>> 32);
25 this.sourceEnd = (int) pos;
26 this.bits |= InsideJavadoc;
30 * Resolves type on a Block or Class scope.
32 private TypeBinding internalResolveType(Scope scope) {
34 // Propagate the type checking to the arguments, and check if the constructor is defined.
35 this.constant = NotAConstant;
36 if (this.type == null) {
37 this.resolvedType = scope.enclosingSourceType();
38 } else if (scope.kind == Scope.CLASS_SCOPE) {
39 this.resolvedType = this.type.resolveType((ClassScope)scope);
41 this.resolvedType = this.type.resolveType((BlockScope)scope, true /* check bounds*/);
44 // buffering the arguments' types
45 TypeBinding[] argumentTypes = NoParameters;
46 if (this.arguments != null) {
47 boolean argHasError = false;
48 int length = this.arguments.length;
49 argumentTypes = new TypeBinding[length];
50 for (int i = 0; i < length; i++) {
51 Expression argument = this.arguments[i];
52 if (scope.kind == Scope.CLASS_SCOPE) {
53 argumentTypes[i] = argument.resolveType((ClassScope)scope);
55 argumentTypes[i] = argument.resolveType((BlockScope)scope);
57 if (argumentTypes[i] == null) {
66 // check resolved type
67 if (this.resolvedType == null) {
70 this.superAccess = scope.enclosingSourceType().isCompatibleWith(this.resolvedType);
72 ReferenceBinding allocationType = (ReferenceBinding) this.resolvedType;
73 this.binding = scope.getConstructor(allocationType, argumentTypes, this);
74 if (!this.binding.isValidBinding()) {
75 MethodBinding methodBinding = scope.getMethod(this.resolvedType, this.resolvedType.sourceName(), argumentTypes, this);
76 if (methodBinding.isValidBinding()) {
77 this.binding = methodBinding;
79 if (this.binding.declaringClass == null) {
80 this.binding.declaringClass = allocationType;
82 scope.problemReporter().javadocInvalidConstructor(this, this.binding, scope.getDeclarationModifiers());
84 return this.resolvedType;
86 if (isMethodUseDeprecated(this.binding, scope)) {
87 scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getDeclarationModifiers());
89 // TODO (frederic) add support for unsafe type operation warning
90 return allocationType;
94 * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#isSuperAccess()
96 public boolean isSuperAccess() {
97 return this.superAccess;
101 * @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.BlockScope)
103 public TypeBinding resolveType(BlockScope scope) {
104 return internalResolveType(scope);
108 * @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.BlockScope)
110 public TypeBinding resolveType(ClassScope scope) {
111 return internalResolveType(scope);