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

(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-11 / +21 lines)
Lines 2318-2326 Link Here
2318
			return;
2318
			return;
2319
		
2319
		
2320
		if (this.options.checkVisibility) {
2320
		if (this.options.checkVisibility) {
2321
			if (invocationType != null && !exceptionType.canBeSeenBy(receiverType, invocationType)) {
2321
			if (invocationType != null) {
2322
				return;
2322
				if (receiverType != null) {
2323
			} else if(invocationType == null && !exceptionType.canBeSeenBy(this.unitScope.fPackage)) {
2323
					if (!exceptionType.canBeSeenBy(receiverType, invocationType)) return;
2324
				} else {
2325
					if (!exceptionType.canBeSeenBy(exceptionType, invocationType)) return;
2326
				}
2327
			} else if(!exceptionType.canBeSeenBy(this.unitScope.fPackage)) {
2324
				return;
2328
				return;
2325
			}
2329
			}
2326
		}
2330
		}
Lines 6347-6356 Link Here
6347
			int typeLength = token.length;
6351
			int typeLength = token.length;
6348
			SourceTypeBinding[] types = this.unitScope.topLevelTypes;
6352
			SourceTypeBinding[] types = this.unitScope.topLevelTypes;
6349
6353
6350
			for (int i = 0, length = types.length; i < length; i++) {
6354
			next : for (int i = 0, length = types.length; i < length; i++) {
6351
				SourceTypeBinding sourceType = types[i]; 
6355
				SourceTypeBinding sourceType = types[i]; 
6352
				
6356
				
6353
				if(isForbidden(sourceType)) continue;
6357
				if(isForbidden(sourceType)) continue next;
6354
				
6358
				
6355
				if(proposeAllMemberTypes &&
6359
				if(proposeAllMemberTypes &&
6356
					sourceType != outerInvocationType) {
6360
					sourceType != outerInvocationType) {
Lines 6365-6386 Link Here
6365
							typesFound);
6369
							typesFound);
6366
				}
6370
				}
6367
				
6371
				
6368
				if (sourceType.sourceName == CompletionParser.FAKE_TYPE_NAME) continue;
6372
				if (sourceType.sourceName == CompletionParser.FAKE_TYPE_NAME) continue next;
6369
				if (sourceType.sourceName == TypeConstants.PACKAGE_INFO_NAME) continue;
6373
				if (sourceType.sourceName == TypeConstants.PACKAGE_INFO_NAME) continue next;
6370
6374
6371
				if (typeLength > sourceType.sourceName.length) continue;
6375
				if (typeLength > sourceType.sourceName.length) continue next;
6372
				
6376
				
6373
				if (!CharOperation.prefixEquals(token, sourceType.sourceName, false)
6377
				if (!CharOperation.prefixEquals(token, sourceType.sourceName, false)
6374
						&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, sourceType.sourceName))) continue;
6378
						&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, sourceType.sourceName))) continue;
6375
	
6379
	
6380
				for (int j = typesFound.size; --j >= 0;) {
6381
					ReferenceBinding otherType = (ReferenceBinding) typesFound.elementAt(j);
6382
	
6383
					if (sourceType == otherType) continue next;
6384
				}
6385
				
6376
				this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), this);
6386
				this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), this);
6377
				
6387
				
6378
				if(this.assistNodeIsClass) {
6388
				if(this.assistNodeIsClass) {
6379
					if(!sourceType.isClass()) continue;
6389
					if(!sourceType.isClass()) continue next;
6380
				} else if(this.assistNodeIsInterface) {
6390
				} else if(this.assistNodeIsInterface) {
6381
					if(!sourceType.isInterface() && !sourceType.isAnnotationType()) continue;
6391
					if(!sourceType.isInterface() && !sourceType.isAnnotationType()) continue next;
6382
				} else if (this.assistNodeIsAnnotation) {
6392
				} else if (this.assistNodeIsAnnotation) {
6383
					if(!sourceType.isAnnotationType()) continue;
6393
					if(!sourceType.isAnnotationType()) continue next;
6384
				}
6394
				}
6385
				
6395
				
6386
				int relevance = computeBaseRelevance();
6396
				int relevance = computeBaseRelevance();
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (+42 lines)
Lines 1114-1119 Link Here
1114
			"IZZBException[TYPE_REF]{IZZBException, test, Ltest.IZZBException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}",
1114
			"IZZBException[TYPE_REF]{IZZBException, test, Ltest.IZZBException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}",
1115
			requestor.getResults());
1115
			requestor.getResults());
1116
}
1116
}
1117
public void testCatchClauseExceptionRef14() throws JavaModelException {
1118
	
1119
	this.workingCopies = new ICompilationUnit[1];
1120
	this.workingCopies[0] = getWorkingCopy(
1121
		"/Completion/src/test/Test.java",
1122
		"package test;"+
1123
		"public class Test {\n" + 
1124
		"	public void throwing() throws IZZException {}\n" +
1125
		"	public void foo() {\n" +
1126
		"      try {\n" +
1127
		"         throwing();\n" +
1128
		"      }\n" +
1129
		"      catch (IZZAException e) {\n" +
1130
		"      }\n" +
1131
		"      catch (IZZ) {\n" +
1132
		"      }\n" +
1133
		"   }" +
1134
		"}" +
1135
		"class IZZAException extends Exception {\n" + 
1136
		"}" +
1137
		"class IZZException extends Exception {\n" + 
1138
		"}\n");
1139
	
1140
	IJavaProject project = this.workingCopies[0].getJavaProject();
1141
	String visibilityCheck = project.getOption(JavaCore.CODEASSIST_VISIBILITY_CHECK, true);
1142
	
1143
	try {
1144
		project.setOption(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1145
		
1146
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1147
		String str = this.workingCopies[0].getSource();
1148
		String completeBehind = "(IZZ";
1149
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1150
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1151
	
1152
		assertResults(
1153
				"IZZException[TYPE_REF]{IZZException, test, Ltest.IZZException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}",
1154
				requestor.getResults());
1155
	} finally {
1156
		project.setOption(JavaCore.CODEASSIST_VISIBILITY_CHECK, visibilityCheck);
1157
	}
1158
}
1117
/*
1159
/*
1118
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=65737
1160
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=65737
1119
 */
1161
 */

Return to bug 173013