View | Details | Raw Unified | Return to bug 343865 | Differences between
and this patch

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (+9 lines)
Lines 670-675 Link Here
670
		this.monitor = monitor;
670
		this.monitor = monitor;
671
	}
671
	}
672
	
672
	
673
	public void accept(ICompilationUnit sourceUnit, AccessRestriction accessRestriction) {
674
		if (!CharOperation.equals(sourceUnit.getMainTypeName(), TypeConstants.PACKAGE_INFO_NAME)) {
675
			// do not accept package-info.java as a type for completion engine
676
			// because it contains no extra info that will help in completion
677
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=343865
678
			super.accept(sourceUnit, accessRestriction);
679
		}
680
	}
681
	
673
	public void acceptConstructor(
682
	public void acceptConstructor(
674
			int modifiers,
683
			int modifiers,
675
			char[] simpleTypeName,
684
			char[] simpleTypeName,
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java (-1 / +42 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 2423-2428 Link Here
2423
	} else {
2423
	} else {
2424
		assertResults(
2424
		assertResults(
2425
				"interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
2425
				"interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
2426
				"YAAnnot[TYPE_REF]{testxxx.YAAnnot, testxxx, Ltestxxx.YAAnnot;, null, null, " + (R_NAME_PREFIX + R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
2426
				"_ConfigurationData[TYPE_REF]{test325481._ConfigurationData, test325481, Ltest325481._ConfigurationData;, null, null, " + (R_NAME_PREFIX + R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
2427
				"_ConfigurationData[TYPE_REF]{test325481._ConfigurationData, test325481, Ltest325481._ConfigurationData;, null, null, " + (R_NAME_PREFIX + R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
2427
				"_Path[TYPE_REF]{test325481._Path, test325481, Ltest325481._Path;, null, null, " + (R_NAME_PREFIX + R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
2428
				"_Path[TYPE_REF]{test325481._Path, test325481, Ltest325481._Path;, null, null, " + (R_NAME_PREFIX + R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
2428
				"Deprecated[TYPE_REF]{Deprecated, java.lang, Ljava.lang.Deprecated;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_TARGET + R_NON_RESTRICTED + R_UNQUALIFIED) + "}\n" +
2429
				"Deprecated[TYPE_REF]{Deprecated, java.lang, Ljava.lang.Deprecated;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_TARGET + R_NON_RESTRICTED + R_UNQUALIFIED) + "}\n" +
Lines 9021-9026 Link Here
9021
	assertResults(
9022
	assertResults(
9022
			"interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
9023
			"interface[KEYWORD]{interface, null, null, interface, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
9023
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_TARGET + R_NON_RESTRICTED) + "}\n" +
9024
			"QQAnnotation[TYPE_REF]{pkgannotations.QQAnnotation, pkgannotations, Lpkgannotations.QQAnnotation;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_TARGET + R_NON_RESTRICTED) + "}\n" +
9025
			"YAAnnot[TYPE_REF]{testxxx.YAAnnot, testxxx, Ltestxxx.YAAnnot;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_TARGET + R_NON_RESTRICTED) + "}\n" +
9024
			"_ConfigurationData[TYPE_REF]{test325481._ConfigurationData, test325481, Ltest325481._ConfigurationData;, null, null, " + (R_NAME_PREFIX + R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
9026
			"_ConfigurationData[TYPE_REF]{test325481._ConfigurationData, test325481, Ltest325481._ConfigurationData;, null, null, " + (R_NAME_PREFIX + R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
9025
			"_Path[TYPE_REF]{test325481._Path, test325481, Ltest325481._Path;, null, null, " + (R_NAME_PREFIX + R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
9027
			"_Path[TYPE_REF]{test325481._Path, test325481, Ltest325481._Path;, null, null, " + (R_NAME_PREFIX + R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_NON_RESTRICTED) + "}\n" +
9026
			"Deprecated[TYPE_REF]{Deprecated, java.lang, Ljava.lang.Deprecated;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_TARGET + R_NON_RESTRICTED + R_UNQUALIFIED) + "}",
9028
			"Deprecated[TYPE_REF]{Deprecated, java.lang, Ljava.lang.Deprecated;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ANNOTATION + R_TARGET + R_NON_RESTRICTED + R_UNQUALIFIED) + "}",
Lines 13874-13877 Link Here
13874
			"Inn.Inn3[TYPE_REF]{Inn3, label, Llabel.Inn$Inn3;, null, null, 44}",
13876
			"Inn.Inn3[TYPE_REF]{Inn3, label, Llabel.Inn$Inn3;, null, null, 44}",
13875
			requestor.getResults());
13877
			requestor.getResults());
13876
}
13878
}
13879
13880
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=343865
13881
// Verify that no NPE is thrown and we get correct proposals
13882
public void testBug343865a() throws JavaModelException {
13883
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13884
	ICompilationUnit cu = getCompilationUnit("Completion", "src3", "testxxx", "TestType.java");
13885
13886
	String str = cu.getSource();
13887
	String completeBehind = "@YAAnnot(";
13888
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13889
	cu.codeComplete(cursorLocation, requestor);
13890
13891
	assertResults(
13892
		"name[ANNOTATION_ATTRIBUTE_REF]{name, Ltestxxx.YAAnnot;, Ljava.lang.String;, name, null, " + (R_NAME_FIRST_PREFIX + R_EXPECTED_TYPE + R_RESOLVED) + "}\n" +
13893
		"val[ANNOTATION_ATTRIBUTE_REF]{val, Ltestxxx.YAAnnot;, I, val, null, " + (R_NAME_FIRST_PREFIX + R_EXPECTED_TYPE + R_RESOLVED) + "}",
13894
		requestor.getResults());
13895
}
13896
13897
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=343865
13898
// Verify that the correct expected type is computed
13899
public void testBug343865b() throws JavaModelException {
13900
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13901
	ICompilationUnit cu = getCompilationUnit("Completion", "src3", "testxxx", "TestType2.java");
13902
13903
	String str = cu.getSource();
13904
	String completeBehind = "String xxyy2 = xxy";
13905
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13906
	cu.codeComplete(cursorLocation, requestor);
13907
13908
	assertResults(
13909
			"expectedTypesSignatures={Ljava.lang.String;}\n" +
13910
			"expectedTypesKeys={Ljava/lang/String;}",
13911
			requestor.getContext());
13912
	
13913
	assertResults(
13914
		"xxyy[FIELD_REF]{xxyy, Ltestxxx.TestType2;, I, xxyy, null, " + (R_NAME_FIRST_PREFIX + R_EXPECTED_TYPE + R_RESOLVED) + "}\n" +
13915
		"xxyy1[FIELD_REF]{xxyy1, Ltestxxx.TestType2;, Ljava.lang.String;, xxyy1, null, " + (R_NAME_FIRST_PREFIX + R_EXPECTED_TYPE + R_RESOLVED + R_EXACT_EXPECTED_TYPE) + "}",
13916
		requestor.getResults());
13917
}
13877
}
13918
}
(-)workspace/Completion/src3/testxxx/Annot.java (+8 lines)
Added Link Here
1
package testxxx;
2
3
@interface YAAnnot {
4
	
5
	int val();
6
	String name();
7
8
}
(-)workspace/Completion/src3/testxxx/TestType.java (+11 lines)
Added Link Here
1
2
package testxxx;
3
4
public class TestType {
5
	
6
	String abc = "hi";
7
	
8
	@YAAnnot()
9
    protected String element = abc;
10
    
11
}
(-)workspace/Completion/src3/testxxx/TestType2.java (+8 lines)
Added Link Here
1
package testxxx;
2
3
public class TestType2 {
4
	int xxyy = 1;
5
	String xxyy1 = "hi";
6
    String xxyy2 = xxy
7
    
8
}
(-)workspace/Completion/src3/testxxx/package-info.java (+3 lines)
Added Link Here
1
@Deprecated
2
@YAAnnot(name = "", val = 0)
3
package testxxx;

Return to bug 343865