blob: 2935b1d622361791a457dc0e4b873c59fcdce378 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class JavadocAllocationExpression extends AllocationExpression {
public int tagSourceStart, tagSourceEnd;
public JavadocAllocationExpression(long pos) {
this.sourceStart = (int) (pos >>> 32);
this.sourceEnd = (int) pos;
this.bits |= InsideJavadoc;
}
/*
* Resolves type on a Block or Class scope.
*/
private TypeBinding internalResolveType(Scope scope) {
// Propagate the type checking to the arguments, and check if the constructor is defined.
constant = NotAConstant;
if (scope.isClassScope()) {
this.resolvedType = type.resolveType((ClassScope)scope);
} else {
this.resolvedType = type.resolveType((BlockScope)scope);
}
// will check for null after args are resolved
// buffering the arguments' types
TypeBinding[] argumentTypes = NoParameters;
if (arguments != null) {
boolean argHasError = false;
int length = arguments.length;
argumentTypes = new TypeBinding[length];
for (int i = 0; i < length; i++) {
Expression argument = this.arguments[i];
if (scope.isClassScope()) {
argumentTypes[i] = argument.resolveType((ClassScope)scope);
} else {
argumentTypes[i] = argument.resolveType((BlockScope)scope);
}
if (argumentTypes[i] == null) {
argHasError = true;
}
}
if (argHasError) {
return this.resolvedType;
}
}
if (this.resolvedType == null)
return null;
if (!this.resolvedType.canBeInstantiated()) {
scope.problemReporter().cannotInstantiate(type, this.resolvedType);
return this.resolvedType;
}
ReferenceBinding allocationType = (ReferenceBinding) this.resolvedType;
this.binding = scope.getConstructor(allocationType, argumentTypes, this);
if (!this.binding.isValidBinding()) {
MethodBinding methodBinding = scope.getMethod(this.resolvedType, this.resolvedType.sourceName(), argumentTypes, this);
if (methodBinding.isValidBinding()) {
this.binding = methodBinding;
} else {
if (binding.declaringClass == null) {
binding.declaringClass = allocationType;
}
scope.problemReporter().invalidConstructor(this, binding);
}
return this.resolvedType;
}
if (isMethodUseDeprecated(binding, scope))
scope.problemReporter().deprecatedMethod(binding, this);
if (arguments != null) {
for (int i = 0; i < arguments.length; i++) {
arguments[i].implicitWidening(binding.parameters[i], argumentTypes[i]);
}
}
return allocationType;
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.BlockScope)
*/
public TypeBinding resolveType(BlockScope scope) {
return internalResolveType(scope);
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.BlockScope)
*/
public TypeBinding resolveType(ClassScope scope) {
return internalResolveType(scope);
}
}