Makefile fixup
[org.ibex.tool.git] / src / org / eclipse / jdt / internal / compiler / ast / JavadocAllocationExpression.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.ast;
12
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;
16
17 public class JavadocAllocationExpression extends AllocationExpression {
18
19         public int tagSourceStart, tagSourceEnd;
20         public boolean superAccess = false;
21         
22         public JavadocAllocationExpression(long pos) {
23                 this.sourceStart = (int) (pos >>> 32);
24                 this.sourceEnd = (int) pos;
25                 this.bits |= InsideJavadoc;
26         }
27
28         /*
29          * Resolves type on a Block or Class scope.
30          */
31         private TypeBinding internalResolveType(Scope scope) {
32
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);
39                 } else {
40                         this.resolvedType = this.type.resolveType((BlockScope)scope);
41                 }
42
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);
53                                 } else {
54                                         argumentTypes[i] = argument.resolveType((BlockScope)scope);
55                                 }
56                                 if (argumentTypes[i] == null) {
57                                         argHasError = true;
58                                 }
59                         }
60                         if (argHasError) {
61                                 return null;
62                         }
63                 }
64
65                 // check resolved type
66                 if (this.resolvedType == null) {
67                         return null;
68                 }
69                 this.superAccess = scope.enclosingSourceType().isCompatibleWith(this.resolvedType);
70
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;
77                         } else {
78                                 if (this.binding.declaringClass == null) {
79                                         this.binding.declaringClass = allocationType;
80                                 }
81                                 scope.problemReporter().javadocInvalidConstructor(this, this.binding, scope.getDeclarationModifiers());
82                         }
83                         return this.resolvedType;
84                 }
85                 if (isMethodUseDeprecated(this.binding, scope)) {
86                         scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getDeclarationModifiers());
87                 }
88
89                 return allocationType;
90         }
91         
92         /* (non-Javadoc)
93          * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#isSuperAccess()
94          */
95         public boolean isSuperAccess() {
96                 return this.superAccess;
97         }
98
99         /* (non-Javadoc)
100          * @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.BlockScope)
101          */
102         public TypeBinding resolveType(BlockScope scope) {
103                 return internalResolveType(scope);
104         }
105
106         /* (non-Javadoc)
107          * @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.BlockScope)
108          */
109         public TypeBinding resolveType(ClassScope scope) {
110                 return internalResolveType(scope);
111         }
112 }