View | Details | Raw Unified | Return to bug 83804
Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java (-2 / +4 lines)
Lines 637-643 Link Here
637
						}
637
						}
638
					}
638
					}
639
				}
639
				}
640
				if (parsedUnit.types != null) {
640
				if (parsedUnit.types != null || parsedUnit.isPackageInfo()) {
641
					if(selectDeclaration(parsedUnit))
641
					if(selectDeclaration(parsedUnit))
642
						return;
642
						return;
643
					this.lookupEnvironment.buildTypeBindings(parsedUnit, null /*no access restriction*/);
643
					this.lookupEnvironment.buildTypeBindings(parsedUnit, null /*no access restriction*/);
Lines 645-651 Link Here
645
						try {
645
						try {
646
							this.lookupEnvironment.completeTypeBindings(parsedUnit, true);
646
							this.lookupEnvironment.completeTypeBindings(parsedUnit, true);
647
							parsedUnit.scope.faultInTypes();
647
							parsedUnit.scope.faultInTypes();
648
							ASTNode node = parseBlockStatements(parsedUnit, selectionSourceStart);
648
							ASTNode node = null;
649
							if (parsedUnit.types != null)
650
								node = parseBlockStatements(parsedUnit, selectionSourceStart);
649
							if(DEBUG) {
651
							if(DEBUG) {
650
								System.out.println("SELECTION - AST :"); //$NON-NLS-1$
652
								System.out.println("SELECTION - AST :"); //$NON-NLS-1$
651
								System.out.println(parsedUnit.toString());
653
								System.out.println(parsedUnit.toString());
(-)codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadoc.java (-32 / +33 lines)
Lines 69-77 Link Here
69
	 * 
69
	 * 
70
	 * @throws SelectionNodeFound
70
	 * @throws SelectionNodeFound
71
	 */
71
	 */
72
	public void resolve(ClassScope scope) {
72
	private void internalResolve(Scope scope) {
73
		if (this.selectedNode != null) {
73
		if (this.selectedNode != null) {
74
			this.selectedNode.resolveType(scope);
74
			switch (scope.kind) {
75
				case Scope.COMPILATION_UNIT_SCOPE:
76
					this.selectedNode.resolveType((CompilationUnitScope)scope);
77
					break;
78
				case Scope.CLASS_SCOPE:
79
					this.selectedNode.resolveType((ClassScope)scope);
80
					break;
81
				case Scope.METHOD_SCOPE:
82
					this.selectedNode.resolveType((MethodScope)scope);
83
					break;
84
			}
75
			Binding binding = null;
85
			Binding binding = null;
76
			if (this.selectedNode instanceof JavadocFieldReference) {
86
			if (this.selectedNode instanceof JavadocFieldReference) {
77
				JavadocFieldReference fieldRef = (JavadocFieldReference) this.selectedNode;
87
				JavadocFieldReference fieldRef = (JavadocFieldReference) this.selectedNode;
Lines 108-144 Link Here
108
	 * 
118
	 * 
109
	 * @throws SelectionNodeFound
119
	 * @throws SelectionNodeFound
110
	 */
120
	 */
121
	public void resolve(ClassScope scope) {
122
		internalResolve(scope);
123
	}
124
125
	/**
126
	 * Resolve selected node if not null and throw exception to let clients know
127
	 * that it has been found.
128
	 * 
129
	 * @throws SelectionNodeFound
130
	 */
131
	public void resolve(CompilationUnitScope scope) {
132
		internalResolve(scope);
133
	}
134
135
	/**
136
	 * Resolve selected node if not null and throw exception to let clients know
137
	 * that it has been found.
138
	 * 
139
	 * @throws SelectionNodeFound
140
	 */
111
	public void resolve(MethodScope scope) {
141
	public void resolve(MethodScope scope) {
112
		if (this.selectedNode != null) {
142
		internalResolve(scope);
113
			this.selectedNode.resolveType(scope);
114
			Binding binding = null;
115
			if (this.selectedNode instanceof JavadocFieldReference) {
116
				JavadocFieldReference fieldRef = (JavadocFieldReference) this.selectedNode;
117
				binding = fieldRef.binding;
118
				if (binding == null && fieldRef.methodBinding != null) {
119
					binding = fieldRef.methodBinding;
120
				}
121
			} else if (this.selectedNode instanceof JavadocMessageSend) {
122
				binding = ((JavadocMessageSend) this.selectedNode).binding;
123
			} else if (this.selectedNode instanceof JavadocAllocationExpression) {
124
				binding = ((JavadocAllocationExpression) this.selectedNode).binding;
125
			} else if (this.selectedNode instanceof JavadocSingleNameReference) {
126
				binding = ((JavadocSingleNameReference) this.selectedNode).binding;
127
			} else if (this.selectedNode instanceof JavadocSingleTypeReference) {
128
				JavadocSingleTypeReference typeRef = (JavadocSingleTypeReference) this.selectedNode;
129
				if (typeRef.packageBinding == null) {
130
					binding = typeRef.resolvedType;
131
				}
132
			} else if (this.selectedNode instanceof JavadocQualifiedTypeReference) {
133
				JavadocQualifiedTypeReference typeRef = (JavadocQualifiedTypeReference) this.selectedNode;
134
				if (typeRef.packageBinding == null) {
135
					binding = typeRef.resolvedType;
136
				}
137
			} else {
138
				binding = this.selectedNode.resolvedType;
139
			}
140
			throw new SelectionNodeFound(binding);
141
		}
142
	}
143
	}
143
144
144
}
145
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java (-4 / +13 lines)
Lines 36-41 Link Here
36
	
36
	
37
	public boolean isPropagatingInnerClassEmulation;
37
	public boolean isPropagatingInnerClassEmulation;
38
38
39
	public Javadoc javadoc; // 1.5 addition for package-info.java
40
39
	public CompilationUnitDeclaration(
41
	public CompilationUnitDeclaration(
40
		ProblemReporter problemReporter,
42
		ProblemReporter problemReporter,
41
		CompilationResult compilationResult,
43
		CompilationResult compilationResult,
Lines 173-179 Link Here
173
			}
175
			}
174
			return;
176
			return;
175
		}
177
		}
176
		if (this.isPackageInfo() && this.types != null) {
178
		if (this.isPackageInfo() && this.types != null && this.currentPackage.annotations != null) {
177
			types[0].annotations = this.currentPackage.annotations;
179
			types[0].annotations = this.currentPackage.annotations;
178
		}
180
		}
179
		try {
181
		try {
Lines 217-224 Link Here
217
219
218
	public boolean isPackageInfo() {
220
	public boolean isPackageInfo() {
219
		return CharOperation.equals(this.getMainTypeName(), TypeConstants.PACKAGE_INFO_NAME)
221
		return CharOperation.equals(this.getMainTypeName(), TypeConstants.PACKAGE_INFO_NAME)
220
			&& this.currentPackage != null
222
			&& this.currentPackage != null;
221
			&& this.currentPackage.annotations != null;
223
//			&& this.currentPackage.annotations != null;
222
	}
224
	}
223
	
225
	
224
	public boolean hasErrors() {
226
	public boolean hasErrors() {
Lines 278-285 Link Here
278
	public void resolve() {
280
	public void resolve() {
279
		int startingTypeIndex = 0;
281
		int startingTypeIndex = 0;
280
		if (this.currentPackage != null) {
282
		if (this.currentPackage != null) {
283
			boolean packageInfo = CharOperation.equals(this.getMainTypeName(), TypeConstants.PACKAGE_INFO_NAME);
281
			if (this.currentPackage.annotations != null) {
284
			if (this.currentPackage.annotations != null) {
282
				if (CharOperation.equals(this.getMainTypeName(), TypeConstants.PACKAGE_INFO_NAME)) {
285
				if (packageInfo) {
283
                    if (this.types != null) {
286
                    if (this.types != null) {
284
                        // resolve annotations
287
                        // resolve annotations
285
    					final TypeDeclaration syntheticTypeDeclaration = types[0];
288
    					final TypeDeclaration syntheticTypeDeclaration = types[0];
Lines 293-298 Link Here
293
					scope.problemReporter().invalidFileNameForPackageAnnotations(this.currentPackage.annotations[0]);
296
					scope.problemReporter().invalidFileNameForPackageAnnotations(this.currentPackage.annotations[0]);
294
				}
297
				}
295
			}
298
			}
299
			// resolve javadoc package if any
300
			if (this.javadoc != null) {
301
				if (packageInfo) {
302
					this.javadoc.resolve(this.scope);
303
				}
304
			}
296
		}
305
		}
297
		try {
306
		try {
298
			if (types != null) {
307
			if (types != null) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java (-2 / +6 lines)
Lines 782-793 Link Here
782
	}
782
	}
783
783
784
	public TypeBinding resolveType(BlockScope scope) {
784
	public TypeBinding resolveType(BlockScope scope) {
785
		// by default... subclasses should implement a better TC if required.
785
		// by default... subclasses should implement a better TB if required.
786
		return null;
787
	}
786
788
789
	public TypeBinding resolveType(ClassScope scope) {
790
		// by default... subclasses should implement a better TB if required.
787
		return null;
791
		return null;
788
	}
792
	}
789
793
790
	public TypeBinding resolveType(ClassScope classScope) {
794
	public TypeBinding resolveType(CompilationUnitScope scope) {
791
		// by default... subclasses should implement a better TB if required.
795
		// by default... subclasses should implement a better TB if required.
792
		return null;
796
		return null;
793
	}
797
	}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/Javadoc.java (-7 / +21 lines)
Lines 76-93 Link Here
76
	 * Resolve type javadoc while a class scope
76
	 * Resolve type javadoc while a class scope
77
	 */
77
	 */
78
	public void resolve(ClassScope classScope) {
78
	public void resolve(ClassScope classScope) {
79
		internalResolve(classScope);
80
	}
81
82
	/*
83
	 * Resolve type javadoc while a compilation unit scope
84
	 */
85
	public void resolve(CompilationUnitScope unitScope) {
86
		internalResolve(unitScope);
87
	}
88
89
	private void internalResolve(Scope scope) {
79
90
80
		// @param tags
91
		// @param tags
81
		int paramTagsSize = this.paramReferences == null ? 0 : this.paramReferences.length;
92
		int paramTagsSize = this.paramReferences == null ? 0 : this.paramReferences.length;
82
		for (int i = 0; i < paramTagsSize; i++) {
93
		for (int i = 0; i < paramTagsSize; i++) {
83
			JavadocSingleNameReference param = this.paramReferences[i];
94
			JavadocSingleNameReference param = this.paramReferences[i];
84
			classScope.problemReporter().javadocUnexpectedTag(param.tagSourceStart, param.tagSourceEnd);
95
			scope.problemReporter().javadocUnexpectedTag(param.tagSourceStart, param.tagSourceEnd);
85
		}
96
		}
86
		resolveTypeParameterTags(classScope, true);
97
		resolveTypeParameterTags(scope, true);
87
98
88
		// @return tags
99
		// @return tags
89
		if (this.returnStatement != null) {
100
		if (this.returnStatement != null) {
90
			classScope.problemReporter().javadocUnexpectedTag(this.returnStatement.sourceStart, this.returnStatement.sourceEnd);
101
			scope.problemReporter().javadocUnexpectedTag(this.returnStatement.sourceStart, this.returnStatement.sourceEnd);
91
		}
102
		}
92
103
93
		// @throws/@exception tags
104
		// @throws/@exception tags
Lines 107-119 Link Here
107
				start = typeRef.sourceStart;
118
				start = typeRef.sourceStart;
108
				end = typeRef.sourceEnd;
119
				end = typeRef.sourceEnd;
109
			}
120
			}
110
			classScope.problemReporter().javadocUnexpectedTag(start, end);
121
			scope.problemReporter().javadocUnexpectedTag(start, end);
111
		}
122
		}
112
123
113
		// @see tags
124
		// @see tags
114
		int seeTagsLength = this.seeReferences == null ? 0 : this.seeReferences.length;
125
		int seeTagsLength = this.seeReferences == null ? 0 : this.seeReferences.length;
115
		for (int i = 0; i < seeTagsLength; i++) {
126
		for (int i = 0; i < seeTagsLength; i++) {
116
			resolveReference(this.seeReferences[i], classScope);
127
			resolveReference(this.seeReferences[i], scope);
117
		}
128
		}
118
	}
129
	}
119
	
130
	
Lines 217-226 Link Here
217
		switch (scope.kind) {
228
		switch (scope.kind) {
218
			case Scope.METHOD_SCOPE:
229
			case Scope.METHOD_SCOPE:
219
				reference.resolveType((MethodScope)scope);
230
				reference.resolveType((MethodScope)scope);
220
			break;
231
				break;
221
			case Scope.CLASS_SCOPE:
232
			case Scope.CLASS_SCOPE:
222
				reference.resolveType((ClassScope)scope);
233
				reference.resolveType((ClassScope)scope);
223
			break;
234
				break;
235
			case Scope.COMPILATION_UNIT_SCOPE:
236
				reference.resolveType((CompilationUnitScope)scope);
237
				break;
224
		}
238
		}
225
239
226
		// Verify field references
240
		// Verify field references
(-)compiler/org/eclipse/jdt/internal/compiler/ast/JavadocAllocationExpression.java (-15 / +18 lines)
Lines 35-44 Link Here
35
		this.constant = NotAConstant;
35
		this.constant = NotAConstant;
36
		if (this.type == null) {
36
		if (this.type == null) {
37
			this.resolvedType = scope.enclosingSourceType();
37
			this.resolvedType = scope.enclosingSourceType();
38
		} else if (scope.kind == Scope.CLASS_SCOPE) {
39
			this.resolvedType = this.type.resolveType((ClassScope)scope);
40
		} else {
38
		} else {
41
			this.resolvedType = this.type.resolveType((BlockScope)scope, true /* check bounds*/);
39
			switch (scope.kind) {
40
				case Scope.COMPILATION_UNIT_SCOPE:
41
					this.resolvedType = this.type.resolveType((CompilationUnitScope)scope);
42
					break;
43
				case Scope.CLASS_SCOPE:
44
					this.resolvedType = this.type.resolveType((ClassScope)scope);
45
					break;
46
				default:
47
					this.resolvedType = this.type.resolveType((BlockScope)scope, true /* check bounds*/);
48
					break;
49
			}
42
		}
50
		}
43
	
51
	
44
		// buffering the arguments' types
52
		// buffering the arguments' types
Lines 71-77 Link Here
71
			return null;
79
			return null;
72
		}
80
		}
73
		this.resolvedType = scope.convertToRawType(this.type.resolvedType);
81
		this.resolvedType = scope.convertToRawType(this.type.resolvedType);
74
		this.superAccess = scope.enclosingSourceType().isCompatibleWith(this.resolvedType);
82
		SourceTypeBinding enclosingType = scope.enclosingSourceType();
83
		this.superAccess = enclosingType==null ? false : enclosingType.isCompatibleWith(this.resolvedType);
75
	
84
	
76
		ReferenceBinding allocationType = (ReferenceBinding) this.resolvedType;
85
		ReferenceBinding allocationType = (ReferenceBinding) this.resolvedType;
77
		this.binding = scope.getConstructor(allocationType, argumentTypes, this);
86
		this.binding = scope.getConstructor(allocationType, argumentTypes, this);
Lines 124-151 Link Here
124
		if (isMethodUseDeprecated(this.binding, scope)) {
133
		if (isMethodUseDeprecated(this.binding, scope)) {
125
			scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getDeclarationModifiers());
134
			scope.problemReporter().javadocDeprecatedMethod(this.binding, this, scope.getDeclarationModifiers());
126
		}
135
		}
127
		// TODO (frederic) add support for unsafe type operation warning
128
		return allocationType;
136
		return allocationType;
129
	}
137
	}
130
	
138
131
	/* (non-Javadoc)
132
	 * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#isSuperAccess()
133
	 */
134
	public boolean isSuperAccess() {
139
	public boolean isSuperAccess() {
135
		return this.superAccess;
140
		return this.superAccess;
136
	}
141
	}
137
142
138
	/* (non-Javadoc)
139
	 * @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.BlockScope)
140
	 */
141
	public TypeBinding resolveType(BlockScope scope) {
143
	public TypeBinding resolveType(BlockScope scope) {
142
		return internalResolveType(scope);
144
		return internalResolveType(scope);
143
	}
145
	}
144
146
145
	/* (non-Javadoc)
146
	 * @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.BlockScope)
147
	 */
148
	public TypeBinding resolveType(ClassScope scope) {
147
	public TypeBinding resolveType(ClassScope scope) {
149
		return internalResolveType(scope);
148
		return internalResolveType(scope);
150
	}
149
	}
150
151
	public TypeBinding resolveType(CompilationUnitScope scope) {
152
		return internalResolveType(scope);
153
	}
151
}
154
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/JavadocArgumentExpression.java (-1 / +5 lines)
Lines 82-88 Link Here
82
	public TypeBinding resolveType(ClassScope scope) {
82
	public TypeBinding resolveType(ClassScope scope) {
83
		return internalResolveType(scope);
83
		return internalResolveType(scope);
84
	}
84
	}
85
	
85
86
	public TypeBinding resolveType(CompilationUnitScope scope) {
87
		return internalResolveType(scope);
88
	}
89
86
	/* (non-Javadoc)
90
	/* (non-Javadoc)
87
	 * Redefine to capture javadoc specific signatures
91
	 * Redefine to capture javadoc specific signatures
88
	 * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
92
	 * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
(-)compiler/org/eclipse/jdt/internal/compiler/ast/JavadocFieldReference.java (-12 / +15 lines)
Lines 42-51 Link Here
42
		this.constant = NotAConstant;
42
		this.constant = NotAConstant;
43
		if (this.receiver == null) {
43
		if (this.receiver == null) {
44
			this.receiverType = scope.enclosingSourceType();
44
			this.receiverType = scope.enclosingSourceType();
45
		} else if (scope.kind == Scope.CLASS_SCOPE) {
46
			this.receiverType = this.receiver.resolveType((ClassScope) scope);
47
		} else {
45
		} else {
48
			this.receiverType = this.receiver.resolveType((BlockScope)scope);
46
			switch (scope.kind) {
47
				case Scope.COMPILATION_UNIT_SCOPE:
48
					this.receiverType = this.receiver.resolveType((CompilationUnitScope) scope);
49
					break;
50
				case Scope.CLASS_SCOPE:
51
					this.receiverType = this.receiver.resolveType((ClassScope) scope);
52
					break;
53
				default:
54
					this.receiverType = this.receiver.resolveType((BlockScope)scope);
55
					break;
56
			}
49
		}
57
		}
50
		if (this.receiverType == null) {
58
		if (this.receiverType == null) {
51
			return null;
59
			return null;
Lines 97-105 Link Here
97
		return this.resolvedType = this.binding.type;
105
		return this.resolvedType = this.binding.type;
98
	}
106
	}
99
	
107
	
100
	/* (non-Javadoc)
101
	 * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#isSuperAccess()
102
	 */
103
	public boolean isSuperAccess() {
108
	public boolean isSuperAccess() {
104
		return this.superAccess;
109
		return this.superAccess;
105
	}
110
	}
Lines 113-132 Link Here
113
		return output;
118
		return output;
114
	}
119
	}
115
120
116
	/* (non-Javadoc)
117
	 * @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.BlockScope)
118
	 */
119
	public TypeBinding resolveType(BlockScope scope) {
121
	public TypeBinding resolveType(BlockScope scope) {
120
		return internalResolveType(scope);
122
		return internalResolveType(scope);
121
	}
123
	}
122
124
123
	/* (non-Javadoc)
124
	 * @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.BlockScope)
125
	 */
126
	public TypeBinding resolveType(ClassScope scope) {
125
	public TypeBinding resolveType(ClassScope scope) {
127
		return internalResolveType(scope);
126
		return internalResolveType(scope);
128
	}
127
	}
129
128
129
	public TypeBinding resolveType(CompilationUnitScope scope) {
130
		return internalResolveType(scope);
131
	}
132
130
	/* (non-Javadoc)
133
	/* (non-Javadoc)
131
	 * Redefine to capture javadoc specific signatures
134
	 * Redefine to capture javadoc specific signatures
132
	 * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
135
	 * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
(-)compiler/org/eclipse/jdt/internal/compiler/ast/JavadocImplicitTypeReference.java (-18 / +7 lines)
Lines 13-18 Link Here
13
import org.eclipse.jdt.internal.compiler.ASTVisitor;
13
import org.eclipse.jdt.internal.compiler.ASTVisitor;
14
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
14
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
15
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
15
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
16
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
16
import org.eclipse.jdt.internal.compiler.lookup.Scope;
17
import org.eclipse.jdt.internal.compiler.lookup.Scope;
17
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
18
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
18
19
Lines 56-62 Link Here
56
	}
57
	}
57
58
58
	/*
59
	/*
59
	 * Resolves type on a Block or Class scope.
60
	 * Resolves type on a Block, Class or CompilationUnit scope.
61
	 * We need to modify resoling behavior to avoid raw type creation.
60
	 */
62
	 */
61
	private TypeBinding internalResolveType(Scope scope) {
63
	private TypeBinding internalResolveType(Scope scope) {
62
		// handle the error here
64
		// handle the error here
Lines 76-114 Link Here
76
		return this.resolvedType;
78
		return this.resolvedType;
77
	}
79
	}
78
80
79
	/* (non-Javadoc)
80
	 * Override super implementation to avoid raw type creation.
81
	 * @see org.eclipse.jdt.internal.compiler.ast.TypeReference#resolveType(org.eclipse.jdt.internal.compiler.lookup.BlockScope, boolean)
82
	 */
83
	public TypeBinding resolveType(BlockScope blockScope, boolean checkBounds) {
81
	public TypeBinding resolveType(BlockScope blockScope, boolean checkBounds) {
84
		return internalResolveType(blockScope);
82
		return internalResolveType(blockScope);
85
	}
83
	}
86
84
87
	/* (non-Javadoc)
88
	 * Override super implementation to avoid raw type creation.
89
	 * @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.ClassScope)
90
	 */
91
	public TypeBinding resolveType(ClassScope classScope) {
85
	public TypeBinding resolveType(ClassScope classScope) {
92
		return internalResolveType(classScope);
86
		return internalResolveType(classScope);
93
	}
87
	}
94
88
95
	/* (non-Javadoc)
89
	public TypeBinding resolveType(CompilationUnitScope scope) {
96
	 * @see org.eclipse.jdt.internal.compiler.ast.TypeReference#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
90
		return internalResolveType(scope);
97
	 */
91
	}
92
98
	public void traverse(ASTVisitor visitor, BlockScope classScope) {
93
	public void traverse(ASTVisitor visitor, BlockScope classScope) {
99
		// Do nothing
94
		// Do nothing
100
	}
95
	}
101
96
102
	/* (non-Javadoc)
103
	 * @see org.eclipse.jdt.internal.compiler.ast.TypeReference#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.ClassScope)
104
	 */
105
	public void traverse(ASTVisitor visitor, ClassScope classScope) {
97
	public void traverse(ASTVisitor visitor, ClassScope classScope) {
106
		// Do nothing
98
		// Do nothing
107
	}
99
	}
108
100
109
	/* (non-Javadoc)
110
	 * @see org.eclipse.jdt.internal.compiler.ast.Expression#printExpression(int, java.lang.StringBuffer)
111
	 */
112
	public StringBuffer printExpression(int indent, StringBuffer output) {
101
	public StringBuffer printExpression(int indent, StringBuffer output) {
113
		return new StringBuffer();
102
		return new StringBuffer();
114
	}
103
	}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/JavadocMessageSend.java (-4 / +17 lines)
Lines 42-51 Link Here
42
		this.constant = NotAConstant;
42
		this.constant = NotAConstant;
43
		if (this.receiver == null) {
43
		if (this.receiver == null) {
44
			this.actualReceiverType = scope.enclosingSourceType();
44
			this.actualReceiverType = scope.enclosingSourceType();
45
		} else if (scope.kind == Scope.CLASS_SCOPE) {
46
			this.actualReceiverType = this.receiver.resolveType((ClassScope) scope);
47
		} else {
45
		} else {
48
			this.actualReceiverType = this.receiver.resolveType((BlockScope) scope);
46
			switch (scope.kind) {
47
				case Scope.COMPILATION_UNIT_SCOPE:
48
					this.actualReceiverType = this.receiver.resolveType((CompilationUnitScope) scope);
49
					break;
50
				case Scope.CLASS_SCOPE:
51
					this.actualReceiverType = this.receiver.resolveType((ClassScope) scope);
52
					break;
53
				default:
54
					this.actualReceiverType = this.receiver.resolveType((BlockScope) scope);
55
					break;
56
			}
49
		}
57
		}
50
58
51
		// will check for null after args are resolved
59
		// will check for null after args are resolved
Lines 79-85 Link Here
79
			return null;
87
			return null;
80
		}
88
		}
81
		this.actualReceiverType = scope.convertToRawType(this.receiver.resolvedType);
89
		this.actualReceiverType = scope.convertToRawType(this.receiver.resolvedType);
82
		this.superAccess = scope.enclosingSourceType().isCompatibleWith(this.actualReceiverType);
90
		SourceTypeBinding enclosingType = scope.enclosingSourceType();
91
		this.superAccess = enclosingType==null ? false : enclosingType.isCompatibleWith(this.actualReceiverType);
83
92
84
		// base type cannot receive any message
93
		// base type cannot receive any message
85
		if (this.actualReceiverType.isBaseType()) {
94
		if (this.actualReceiverType.isBaseType()) {
Lines 200-205 Link Here
200
		return internalResolveType(scope);
209
		return internalResolveType(scope);
201
	}
210
	}
202
211
212
	public TypeBinding resolveType(CompilationUnitScope scope) {
213
		return internalResolveType(scope);
214
	}
215
203
	/* (non-Javadoc)
216
	/* (non-Javadoc)
204
	 * Redefine to capture javadoc specific signatures
217
	 * Redefine to capture javadoc specific signatures
205
	 * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
218
	 * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
(-)compiler/org/eclipse/jdt/internal/compiler/ast/JavadocQualifiedTypeReference.java (-9 / +5 lines)
Lines 47-53 Link Here
47
	}
47
	}
48
48
49
	/*
49
	/*
50
	 *
50
	 * We need to modify resolving behavior to handle package references
51
	 */
51
	 */
52
	private TypeBinding internalResolveType(Scope scope, boolean checkBounds) {
52
	private TypeBinding internalResolveType(Scope scope, boolean checkBounds) {
53
		// handle the error here
53
		// handle the error here
Lines 73-91 Link Here
73
		return resolvedType;
73
		return resolvedType;
74
	}
74
	}
75
75
76
	/* (non-Javadoc)
77
	 * @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.BlockScope)
78
	 * We need to override to handle package references
79
	 */
80
	public TypeBinding resolveType(BlockScope blockScope, boolean checkBounds) {
76
	public TypeBinding resolveType(BlockScope blockScope, boolean checkBounds) {
81
		return internalResolveType(blockScope, checkBounds);
77
		return internalResolveType(blockScope, checkBounds);
82
	}
78
	}
83
79
84
	/* (non-Javadoc)
85
	 * @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.ClassScope)
86
	 * We need to override to handle package references
87
	 */
88
	public TypeBinding resolveType(ClassScope classScope) {
80
	public TypeBinding resolveType(ClassScope classScope) {
89
		return internalResolveType(classScope, false);
81
		return internalResolveType(classScope, false);
90
	}
82
	}
83
84
	public TypeBinding resolveType(CompilationUnitScope scope) {
85
		return internalResolveType(scope, false);
86
	}
91
}
87
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleTypeReference.java (-4 / +7 lines)
Lines 47-52 Link Here
47
		visitor.endVisit(this, scope);
47
		visitor.endVisit(this, scope);
48
	}
48
	}
49
49
50
	/*
51
	 * We need to modify resolving behavior to handle package references
52
	 */
50
	TypeBinding internalResolveType(Scope scope) {
53
	TypeBinding internalResolveType(Scope scope) {
51
		// handle the error here
54
		// handle the error here
52
		this.constant = NotAConstant;
55
		this.constant = NotAConstant;
Lines 80-90 Link Here
80
		return internalResolveType(blockScope);
83
		return internalResolveType(blockScope);
81
	}
84
	}
82
85
83
	/* (non-Javadoc)
84
	 * @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.ClassScope)
85
	 * We need to override to handle package references
86
	 */
87
	public TypeBinding resolveType(ClassScope classScope) {
86
	public TypeBinding resolveType(ClassScope classScope) {
88
		return internalResolveType(classScope);
87
		return internalResolveType(classScope);
89
	}
88
	}
89
90
	public TypeBinding resolveType(CompilationUnitScope scope) {
91
		return internalResolveType(scope);
92
	}
90
}
93
}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-1 / +7 lines)
Lines 4230-4236 Link Here
4230
	this.realBlockStack[this.realBlockPtr] = 0;
4230
	this.realBlockStack[this.realBlockPtr] = 0;
4231
}
4231
}
4232
protected void consumePackageComment() {
4232
protected void consumePackageComment() {
4233
	// do nothing
4233
	// get possible comment for syntax since 1.5
4234
	if(options.sourceLevel >= ClassFileConstants.JDK1_5) {
4235
		checkComment();
4236
		resetModifiers();
4237
	}
4234
}
4238
}
4235
protected void consumePackageDeclaration() {
4239
protected void consumePackageDeclaration() {
4236
	// PackageDeclaration ::= 'package' Name ';'
4240
	// PackageDeclaration ::= 'package' Name ';'
Lines 4238-4243 Link Here
4238
	stored in the identifier stack. */
4242
	stored in the identifier stack. */
4239
4243
4240
	ImportReference impt = this.compilationUnit.currentPackage;
4244
	ImportReference impt = this.compilationUnit.currentPackage;
4245
	this.compilationUnit.javadoc = this.javadoc;
4246
	this.javadoc = null;
4241
	// flush comments defined prior to import statements
4247
	// flush comments defined prior to import statements
4242
	impt.declarationEnd = this.endStatementPosition;
4248
	impt.declarationEnd = this.endStatementPosition;
4243
	impt.declarationSourceEnd = this.flushCommentsDefinedPriorTo(impt.declarationSourceEnd);
4249
	impt.declarationSourceEnd = this.flushCommentsDefinedPriorTo(impt.declarationSourceEnd);
(-)dom/org/eclipse/jdt/core/dom/ASTConverter.java (-6 / +32 lines)
Lines 1124-1129 Link Here
1124
		this.compilationUnitSource = source;
1124
		this.compilationUnitSource = source;
1125
		this.scanner.setSource(unit.compilationResult);
1125
		this.scanner.setSource(unit.compilationResult);
1126
		CompilationUnit compilationUnit = new CompilationUnit(this.ast);
1126
		CompilationUnit compilationUnit = new CompilationUnit(this.ast);
1127
1128
		// Parse comments
1129
		int[][] comments = unit.comments;
1130
		if (comments != null) {
1131
			buildCommentsTable(compilationUnit, comments);
1132
		}
1133
1127
		// handle the package declaration immediately
1134
		// handle the package declaration immediately
1128
		// There is no node corresponding to the package declaration
1135
		// There is no node corresponding to the package declaration
1129
		if (this.resolveBindings) {
1136
		if (this.resolveBindings) {
Lines 1141-1152 Link Here
1141
			}
1148
			}
1142
		}
1149
		}
1143
1150
1144
		// Parse comments
1145
		int[][] comments = unit.comments;
1146
		if (comments != null) {
1147
			buildCommentsTable(compilationUnit, comments);
1148
		}
1149
1150
		org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = unit.types;
1151
		org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = unit.types;
1151
		if (types != null) {
1152
		if (types != null) {
1152
			int typesLength = types.length;
1153
			int typesLength = types.length;
Lines 1744-1749 Link Here
1744
			}
1745
			}
1745
		}
1746
		}
1746
	}
1747
	}
1748
1749
	public void convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc, PackageDeclaration packageDeclaration) {
1750
		if (ast.apiLevel == AST.JLS3 && packageDeclaration.getJavadoc() == null) {
1751
			if (javadoc != null) {
1752
				if (this.commentMapper == null || !this.commentMapper.hasSameTable(this.commentsTable)) {
1753
					this.commentMapper = new DefaultCommentMapper(this.commentsTable);
1754
				}
1755
				Comment comment = this.commentMapper.getComment(javadoc.sourceStart);
1756
				if (comment != null && comment.isDocComment() && comment.getParent() == null) {
1757
					Javadoc docComment = (Javadoc) comment;
1758
					if (this.resolveBindings) {
1759
						recordNodes(docComment, javadoc);
1760
						// resolve member and method references binding
1761
						Iterator tags = docComment.tags().listIterator();
1762
						while (tags.hasNext()) {
1763
							recordNodes(javadoc, (TagElement) tags.next());
1764
						}
1765
					}
1766
					packageDeclaration.setJavadoc(docComment);
1767
				}
1768
			}
1769
		}
1770
	}
1747
	
1771
	
1748
	public LabeledStatement convert(org.eclipse.jdt.internal.compiler.ast.LabeledStatement statement) {
1772
	public LabeledStatement convert(org.eclipse.jdt.internal.compiler.ast.LabeledStatement statement) {
1749
		LabeledStatement labeledStatement = new LabeledStatement(this.ast);
1773
		LabeledStatement labeledStatement = new LabeledStatement(this.ast);
Lines 2621-2626 Link Here
2621
		if (this.resolveBindings) {
2645
		if (this.resolveBindings) {
2622
			recordNodes(packageDeclaration, importReference);
2646
			recordNodes(packageDeclaration, importReference);
2623
		}
2647
		}
2648
		// Set javadoc
2649
		convert(compilationUnitDeclaration.javadoc, packageDeclaration);
2624
		return packageDeclaration;
2650
		return packageDeclaration;
2625
	}
2651
	}
2626
	
2652
	
(-)search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java (-15 / +39 lines)
Lines 1380-1403 Link Here
1380
1380
1381
		getMethodBodies(unit);
1381
		getMethodBodies(unit);
1382
1382
1383
		if (bindingsWereCreated && ((InternalSearchPattern)this.pattern).mustResolve && unit.types != null) {
1383
		boolean mustResolve = ((InternalSearchPattern)this.pattern).mustResolve;
1384
			if (BasicSearchEngine.VERBOSE)
1384
		if (bindingsWereCreated &&  mustResolve) {
1385
				System.out.println("Resolving " + this.currentPossibleMatch.openable.toStringWithAncestors()); //$NON-NLS-1$
1385
			if (unit.types != null) {
1386
1386
				if (BasicSearchEngine.VERBOSE)
1387
			reduceParseTree(unit);
1387
					System.out.println("Resolving " + this.currentPossibleMatch.openable.toStringWithAncestors()); //$NON-NLS-1$
1388
1388
	
1389
			if (unit.scope != null) {
1389
				reduceParseTree(unit);
1390
				// fault in fields & methods
1390
	
1391
				unit.scope.faultInTypes();
1391
				if (unit.scope != null) {
1392
					// fault in fields & methods
1393
					unit.scope.faultInTypes();
1394
				}
1395
				unit.resolve();
1396
			} else if (unit.isPackageInfo()) {
1397
				if (BasicSearchEngine.VERBOSE)
1398
					System.out.println("Resolving " + this.currentPossibleMatch.openable.toStringWithAncestors()); //$NON-NLS-1$
1399
				unit.resolve();
1392
			}
1400
			}
1393
			unit.resolve();
1394
1395
			reportMatching(unit, true);
1396
		} else {
1397
			reportMatching(unit, ((InternalSearchPattern)this.pattern).mustResolve);
1398
		}
1401
		}
1402
		reportMatching(unit, mustResolve);
1399
	} catch (AbortCompilation e) {
1403
	} catch (AbortCompilation e) {
1400
		// could not resolve: report innacurate matches
1404
		// could not resolve: report inaccurate matches
1401
		reportMatching(unit, true); // was partially resolved
1405
		reportMatching(unit, true); // was partially resolved
1402
		if (!(e instanceof AbortCompilationUnit)) {
1406
		if (!(e instanceof AbortCompilationUnit)) {
1403
			// problem with class path
1407
			// problem with class path
Lines 1853-1858 Link Here
1853
	if (nodeSet.matchingNodes.elementSize == 0) return; // no matching nodes were found
1857
	if (nodeSet.matchingNodes.elementSize == 0) return; // no matching nodes were found
1854
1858
1855
	boolean matchedUnitContainer = (this.matchContainer & PatternLocator.COMPILATION_UNIT_CONTAINER) != 0;
1859
	boolean matchedUnitContainer = (this.matchContainer & PatternLocator.COMPILATION_UNIT_CONTAINER) != 0;
1860
1861
	// report references in javadoc
1862
	if (unit.javadoc != null) {
1863
		ASTNode[] nodes = nodeSet.matchingNodes(unit.javadoc.sourceStart, unit.javadoc.sourceEnd);
1864
		if (nodes != null) {
1865
			if (!matchedUnitContainer) {
1866
				for (int i = 0, l = nodes.length; i < l; i++)
1867
					nodeSet.matchingNodes.removeKey(nodes[i]);
1868
			} else {
1869
				IJavaElement element = createTypeHandle(new String(unit.getMainTypeName()));
1870
				for (int i = 0, l = nodes.length; i < l; i++) {
1871
					ASTNode node = nodes[i];
1872
					Integer level = (Integer) nodeSet.matchingNodes.removeKey(node);
1873
					if (encloses(element))
1874
						this.patternLocator.matchReportReference(node, element, null/*no binding*/, level.intValue(), this);
1875
				}
1876
			}
1877
		}
1878
	}
1879
1856
	if (matchedUnitContainer) {
1880
	if (matchedUnitContainer) {
1857
// Currently a no-op
1881
// Currently a no-op
1858
//	ImportReference pkg = unit.currentPackage;
1882
//	ImportReference pkg = unit.currentPackage;

Return to bug 83804