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

(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (-8287 / +8902 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 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 24-29 Link Here
24
24
25
public class CompletionTests extends AbstractJavaModelCompletionTests implements RelevanceConstants {
25
public class CompletionTests extends AbstractJavaModelCompletionTests implements RelevanceConstants {
26
26
27
static {
28
//	TESTS_NAMES = new String[] { "testDeprecationCheck17"};
29
}
30
public static Test suite() {
31
	return buildModelTestSuite(CompletionTests.class);
32
}
27
public CompletionTests(String name) {
33
public CompletionTests(String name) {
28
	super(name);
34
	super(name);
29
}
35
}
Lines 38-1851 Link Here
38
public void tearDownSuite() throws Exception {
44
public void tearDownSuite() throws Exception {
39
	super.tearDownSuite();
45
	super.tearDownSuite();
40
}
46
}
41
static {
47
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=164311
42
//	TESTS_NAMES = new String[] { "testDeprecationCheck17"};
48
public void testBug164311() throws JavaModelException {
43
}
49
	this.workingCopies = new ICompilationUnit[1];
44
public static Test suite() {
50
	this.workingCopies[0] = getWorkingCopy(
45
	return buildModelTestSuite(CompletionTests.class);
51
		"/Completion/src/test/Test.java",
46
}
52
		"package test;"+
47
public void testParameterNames1() throws CoreException, IOException {
53
		"public class Test {\n" + 
48
	Hashtable options = JavaCore.getOptions();
54
		"    public int zzzzzz;\n" + 
49
	Object timeout = options.get(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC);
55
		"    public void method1() {\n" + 
50
	options.put(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC,"2000"); //$NON-NLS-1$
56
		"        label : if (0> (10));\n" + 
51
	
57
		"        zzz\n" + 
52
	JavaCore.setOptions(options);
58
		"    }\n" + 
59
		"}\n");
53
60
54
	try {
61
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
55
		this.workingCopies = new ICompilationUnit[1];
62
	String str = this.workingCopies[0].getSource();
56
		this.workingCopies[0] = getWorkingCopy(
63
	String completeBehind = "zzz";
57
			"/Completion/src/p/Test.java",
64
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
58
			"package p;"+
65
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
59
			"public class Test {\n" + 
66
60
			"  void foo(doctest.X x) {\n" + 
67
	assertResults(
61
			"    x.fo\n" + 
68
			"zzzzzz[FIELD_REF]{zzzzzz, Ltest.Test;, I, zzzzzz, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
62
			"  }\n" + 
69
			requestor.getResults());
63
			"}\n");
64
		
65
		addLibrary(
66
				"Completion", 
67
				"tmpDoc.jar",
68
				null,
69
				"tmpDocDoc.zip",
70
				false);
71
		
72
		CompletionTestsRequestor2 requestor;
73
		try {
74
			requestor = new CompletionTestsRequestor2(true);
75
			String str = this.workingCopies[0].getSource();
76
			String completeBehind = "x.fo";
77
			int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
78
			this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
79
			
80
			assertResults(
81
				"foo[METHOD_REF]{foo(), Ldoctest.X;, (Ljava.lang.Object;)V, foo, (param), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}",
82
				requestor.getResults());
83
		} finally {
84
			removeLibrary("Completion", "tmpDoc.jar");
85
		}
86
	} finally {
87
		options.put(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, timeout);
88
		JavaCore.setOptions(options);
89
	}
90
}
70
}
91
public void testInconsistentHierarchy1() throws CoreException, IOException {
71
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=164311
72
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=167750
73
public void testBug164311_2() throws JavaModelException {
92
	this.workingCopies = new ICompilationUnit[1];
74
	this.workingCopies = new ICompilationUnit[1];
93
	this.workingCopies[0] = getWorkingCopy(
75
	this.workingCopies[0] = getWorkingCopy(
94
		"/Completion/src/p/Test.java",
76
		"/Completion/src/test/Test.java",
95
		"package p;"+
77
		"package test;\n"+
96
		"public class Test extends Unknown {\n" + 
78
		"public class X {\n"+
97
		"  void foo() {\n" + 
79
		"    public void zork() { \n"+
98
		"    this.has\n" + 
80
		"    } \n"+
99
		"  }\n" + 
81
		"    public void foo() { \n"+
82
		"        this.foo(new Object(){\n"+
83
		"            public void bar() {\n"+
84
		"                if (zzz>(Integer)vvv.foo(i)) {\n"+
85
		"                    return;\n"+
86
		"                }\n"+
87
		"                if (true) {\n"+
88
		"                    return;\n"+
89
		"                }\n"+
90
		"                zor\n"+
91
		"            }        \n"+    
92
		"        });\n"+
93
		"    }\n"+
100
		"}\n");
94
		"}\n");
101
	
95
102
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
96
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
103
	String str = this.workingCopies[0].getSource();
97
	String str = this.workingCopies[0].getSource();
104
	String completeBehind = "this.has";
98
	String completeBehind = "zor";
105
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
99
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
106
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
100
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
107
	
101
108
	assertResults(
102
	assertResults(
109
		"hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}",
103
			"zork[METHOD_REF]{zork(), Ltest.X;, ()V, zork, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
110
		requestor.getResults());
104
			requestor.getResults());
111
}
105
}
112
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
106
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=96213
113
public void testDeprecationCheck1() throws JavaModelException {
107
public void testBug96213() throws JavaModelException {
114
	Hashtable options = JavaCore.getOptions();
108
    this.wc = getWorkingCopy(
115
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
109
            "/Completion/src/test/Test.java",
116
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED); //$NON-NLS-1$
110
            "package test;\n" +
117
	
111
            "public class Test{\n"+
118
	JavaCore.setOptions(options);
112
            "  Test toto(Object o) {\n"+
113
            "    return null;\n"+
114
            "  }\n"+
115
            "  void titi(int removed) {\n"+
116
            "  }\n"+
117
            "  void foo() {\n"+
118
            "    int removed = 0;\n"+
119
            "    toto(Test.this).titi(removed);\n"+
120
            "  }\n"+
121
            "}");
122
    
123
    
124
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
125
    String str = this.wc.getSource();
126
    String completeBehind = "removed";
127
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
128
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
119
129
120
	try {
130
	assertResults(
121
		this.workingCopies = new ICompilationUnit[3];
131
            "removed[LOCAL_VARIABLE_REF]{removed, null, I, removed, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
122
		this.workingCopies[0] = getWorkingCopy(
132
            requestor.getResults());
123
			"/Completion/src/deprecation/Test.java",
133
}
124
			"package deprecation;"+
134
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=99811
125
			"public class Test {\n"+
135
public void testBug99811() throws JavaModelException {
126
			"  ZZZTy\n"+
136
	ICompilationUnit aType = null;
127
			"}");
137
    try {
128
		
138
    	this.wc = getWorkingCopy(
129
		this.workingCopies[1] = getWorkingCopy(
139
	            "/Completion/src/test/A.java",
130
			"/Completion/src/deprecation/ZZZType1.java",
140
	            "public abstract class A implements I {}");
131
			"package deprecation;"+
141
    	
132
			"public class ZZZType1 {\n"+
142
	    aType = getWorkingCopy(
133
			"}");
143
	            "/Completion/src/test/I.java",
134
		
144
	            "public interface I {\n"+
135
		this.workingCopies[2] = getWorkingCopy(
145
	            "  public class M extends A {}\n"+
136
			"/Completion/src/deprecation/ZZZType2.java",
146
	            "}");
137
			"package deprecation;"+
138
			"/** @deprecated */\n"+
139
			"public class ZZZType2 {\n"+
140
			"}");
141
	
147
	
142
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
148
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
143
		String str = this.workingCopies[0].getSource();
149
	    String str = this.wc.getSource();
144
		String completeBehind = "ZZZTy";
150
	    String completeBehind = "A";
145
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
151
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
146
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
152
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
147
	
153
	
148
		assertResults(
154
		assertResults("", requestor.getResults());
149
				"ZZZTy[POTENTIAL_METHOD_DECLARATION]{ZZZTy, Ldeprecation.Test;, ()V, ZZZTy, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
150
				"ZZZType1[TYPE_REF]{ZZZType1, deprecation, Ldeprecation.ZZZType1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
151
				"ZZZType2[TYPE_REF]{ZZZType2, deprecation, Ldeprecation.ZZZType2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
152
				requestor.getResults());
153
	} finally {
155
	} finally {
154
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
156
		if(aType != null) {
155
		JavaCore.setOptions(options);
157
			aType.discardWorkingCopy();
158
		}
156
	}
159
	}
157
}
160
}
158
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
161
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
159
public void testDeprecationCheck2() throws JavaModelException {
162
public void testCamelCaseField1() throws JavaModelException {
160
	Hashtable options = JavaCore.getOptions();
163
	this.oldOptions = JavaCore.getOptions();
161
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
162
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
163
	
164
	JavaCore.setOptions(options);
165
166
	try {
164
	try {
167
		this.workingCopies = new ICompilationUnit[3];
165
		Hashtable options = new Hashtable(oldOptions);
166
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
167
		JavaCore.setOptions(options);
168
		
169
		this.workingCopies = new ICompilationUnit[1];
168
		this.workingCopies[0] = getWorkingCopy(
170
		this.workingCopies[0] = getWorkingCopy(
169
			"/Completion/src/deprecation/Test.java",
171
			"/Completion/src/camelcase/Test.java",
170
			"package deprecation;"+
172
			"package camelcase;"+
171
			"public class Test {\n"+
173
			"public class Test {\n"+
172
			"  ZZZTy\n"+
174
			"  int oneTwoThree;\n"+
173
			"}");
175
			"  int oTTField;\n"+
174
		
176
			"  void foo() {\n"+
175
		this.workingCopies[1] = getWorkingCopy(
177
			"    oTT\n"+
176
			"/Completion/src/deprecation/ZZZType1.java",
178
			"  }\n"+
177
			"package deprecation;"+
178
			"public class ZZZType1 {\n"+
179
			"}");
180
		
181
		this.workingCopies[2] = getWorkingCopy(
182
			"/Completion/src/deprecation/ZZZType2.java",
183
			"package deprecation;"+
184
			"/** @deprecated */\n"+
185
			"public class ZZZType2 {\n"+
186
			"}");
179
			"}");
187
	
180
	
188
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
181
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
189
		String str = this.workingCopies[0].getSource();
182
		String str = this.workingCopies[0].getSource();
190
		String completeBehind = "ZZZTy";
183
		String completeBehind = "oTT";
191
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
184
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
192
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
185
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
193
	
186
	
194
		assertResults(
187
		assertResults(
195
				"ZZZTy[POTENTIAL_METHOD_DECLARATION]{ZZZTy, Ldeprecation.Test;, ()V, ZZZTy, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
188
				"oneTwoThree[FIELD_REF]{oneTwoThree, Lcamelcase.Test;, I, oneTwoThree, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
196
				"ZZZType1[TYPE_REF]{ZZZType1, deprecation, Ldeprecation.ZZZType1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
189
				"oTTField[FIELD_REF]{oTTField, Lcamelcase.Test;, I, oTTField, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
197
				requestor.getResults());
190
				requestor.getResults());
198
	} finally {
191
	} finally {
199
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
192
		JavaCore.setOptions(oldOptions);
200
		JavaCore.setOptions(options);
201
	}
193
	}
202
}
194
}
203
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
195
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
204
public void testDeprecationCheck3() throws JavaModelException {
196
public void testCamelCaseLocalVariable1() throws JavaModelException {
205
	Hashtable options = JavaCore.getOptions();
197
	this.oldOptions = JavaCore.getOptions();
206
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
207
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED); //$NON-NLS-1$
208
	
209
	JavaCore.setOptions(options);
210
211
	try {
198
	try {
212
	
199
		Hashtable options = new Hashtable(oldOptions);
213
		this.workingCopies = new ICompilationUnit[2];
200
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
201
		JavaCore.setOptions(options);
202
		
203
		this.workingCopies = new ICompilationUnit[1];
214
		this.workingCopies[0] = getWorkingCopy(
204
		this.workingCopies[0] = getWorkingCopy(
215
			"/Completion/src/deprecation/Test.java",
205
			"/Completion/src/camelcase/Test.java",
216
			"package deprecation;"+
206
			"package camelcase;"+
217
			"public class Test {\n"+
207
			"public class Test {\n"+
218
			"  void foo() {"+
208
			"  void foo() {\n"+
219
			"    ZZZType1.fo\n"+
209
			"    int oneTwoThree;\n"+
220
			"  }"+
210
			"    int oTTLocal;\n"+
221
			"}");
211
			"    oTT\n"+
222
		
212
			"  }\n"+
223
		this.workingCopies[1] = getWorkingCopy(
224
			"/Completion/src/deprecation/ZZZType1.java",
225
			"package deprecation;"+
226
			"public class ZZZType1 {\n"+
227
			"  public static void foo1(){}\n"+
228
			"  /** @deprecated */\n"+
229
			"  public static void foo2(){}\n"+
230
			"}");
213
			"}");
231
	
214
	
232
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
215
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
233
		String str = this.workingCopies[0].getSource();
216
		String str = this.workingCopies[0].getSource();
234
		String completeBehind = "ZZZType1.fo";
217
		String completeBehind = "oTT";
235
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
218
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
236
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
219
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
237
	
220
	
238
		assertResults(
221
		assertResults(
239
				"foo1[METHOD_REF]{foo1(), Ldeprecation.ZZZType1;, ()V, foo1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n" +
222
				"oneTwoThree[LOCAL_VARIABLE_REF]{oneTwoThree, null, I, oneTwoThree, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
240
				"foo2[METHOD_REF]{foo2(), Ldeprecation.ZZZType1;, ()V, foo2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}",
223
				"oTTLocal[LOCAL_VARIABLE_REF]{oTTLocal, null, I, oTTLocal, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
241
				requestor.getResults());
224
				requestor.getResults());
242
	} finally {
225
	} finally {
243
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
226
		JavaCore.setOptions(oldOptions);
244
		JavaCore.setOptions(options);
245
	}
227
	}
246
}
228
}
247
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
229
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
248
public void testDeprecationCheck4() throws JavaModelException {
230
public void testCamelCaseMethod1() throws JavaModelException {
249
	Hashtable options = JavaCore.getOptions();
231
	this.oldOptions = JavaCore.getOptions();
250
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
251
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
252
	
253
	JavaCore.setOptions(options);
254
255
	try {
232
	try {
256
233
		Hashtable options = new Hashtable(oldOptions);
257
		this.workingCopies = new ICompilationUnit[2];
234
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
235
		JavaCore.setOptions(options);
236
		
237
	this.workingCopies = new ICompilationUnit[1];
258
		this.workingCopies[0] = getWorkingCopy(
238
		this.workingCopies[0] = getWorkingCopy(
259
			"/Completion/src/deprecation/Test.java",
239
			"/Completion/src/camelcase/Test.java",
260
			"package deprecation;"+
240
			"package camelcase;"+
261
			"public class Test {\n"+
241
			"public class Test {\n"+
262
			"  void foo() {"+
242
			"  void oneTwoThree(){}\n"+
263
			"    ZZZType1.fo\n"+
243
			"  void oTTMethod(){}\n"+
264
			"  }"+
244
			"  void foo() {\n"+
265
			"}");
245
			"    oTT\n"+
266
		
246
			"  }\n"+
267
		this.workingCopies[1] = getWorkingCopy(
268
			"/Completion/src/deprecation/ZZZType1.java",
269
			"package deprecation;"+
270
			"public class ZZZType1 {\n"+
271
			"  public static void foo1(){}\n"+
272
			"  /** @deprecated */\n"+
273
			"  public static void foo2(){}\n"+
274
			"}");
247
			"}");
275
	
248
	
276
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
249
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
277
		String str = this.workingCopies[0].getSource();
250
		String str = this.workingCopies[0].getSource();
278
		String completeBehind = "ZZZType1.fo";
251
		String completeBehind = "oTT";
279
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
252
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
280
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
253
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
281
	
254
	
282
		assertResults(
255
		assertResults(
283
				"foo1[METHOD_REF]{foo1(), Ldeprecation.ZZZType1;, ()V, foo1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}",
256
				"oneTwoThree[METHOD_REF]{oneTwoThree(), Lcamelcase.Test;, ()V, oneTwoThree, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
257
				"oTTMethod[METHOD_REF]{oTTMethod(), Lcamelcase.Test;, ()V, oTTMethod, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
284
				requestor.getResults());
258
				requestor.getResults());
285
	} finally {
259
	} finally {
286
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
260
		JavaCore.setOptions(oldOptions);
287
		JavaCore.setOptions(options);
288
	}
261
	}
289
}
262
}
290
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
263
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
291
public void testDeprecationCheck5() throws JavaModelException {
264
public void testCamelCaseMethodDeclaration1() throws JavaModelException {
292
	Hashtable options = JavaCore.getOptions();
265
	this.oldOptions = JavaCore.getOptions();
293
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
294
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED); //$NON-NLS-1$
295
	
296
	JavaCore.setOptions(options);
297
298
	try {
266
	try {
299
267
		Hashtable options = new Hashtable(oldOptions);
268
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
269
		JavaCore.setOptions(options);
270
		
300
		this.workingCopies = new ICompilationUnit[2];
271
		this.workingCopies = new ICompilationUnit[2];
301
		this.workingCopies[0] = getWorkingCopy(
272
		this.workingCopies[0] = getWorkingCopy(
302
			"/Completion/src/deprecation/Test.java",
273
			"/Completion/src/camelcase/Test.java",
303
			"package deprecation;"+
274
			"package camelcase;"+
304
			"public class Test {\n"+
275
			"public class Test extends SuperClass {\n"+
305
			"  ZZZType1.Inn\n"+
276
			"  oTT\n"+
306
			"}");
277
			"}");
307
		
278
		
308
		this.workingCopies[1] = getWorkingCopy(
279
		this.workingCopies[1] = getWorkingCopy(
309
			"/Completion/src/deprecation/ZZZType1.java",
280
			"/Completion/src/camelcase/SuperClass.java",
310
			"package deprecation;"+
281
			"package camelcase;"+
311
			"public class ZZZType1 {\n"+
282
			"public class SuperClass {\n"+
312
			"  public class Inner1 {}\n"+
283
			"  public void oneTwoThree(){}\n"+
313
			"  /** @deprecated */\n"+
284
			"  public void oTTMethod(){}\n"+
314
			"  public class Inner2 {}\n"+
315
			"}");
285
			"}");
316
	
286
	
317
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
287
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
318
		String str = this.workingCopies[0].getSource();
288
		String str = this.workingCopies[0].getSource();
319
		String completeBehind = "ZZZType1.Inn";
289
		String completeBehind = "oTT";
320
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
290
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
321
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
291
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
322
	
292
	
323
		assertResults(
293
		assertResults(
324
				"ZZZType1.Inner1[TYPE_REF]{Inner1, deprecation, Ldeprecation.ZZZType1$Inner1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
294
				"oTT[POTENTIAL_METHOD_DECLARATION]{oTT, Lcamelcase.Test;, ()V, oTT, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
325
				"ZZZType1.Inner2[TYPE_REF]{Inner2, deprecation, Ldeprecation.ZZZType1$Inner2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
295
				"oneTwoThree[METHOD_DECLARATION]{public void oneTwoThree(), Lcamelcase.SuperClass;, ()V, oneTwoThree, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
296
				"oTTMethod[METHOD_DECLARATION]{public void oTTMethod(), Lcamelcase.SuperClass;, ()V, oTTMethod, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
326
				requestor.getResults());
297
				requestor.getResults());
327
	} finally {
298
	} finally {
328
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
299
		JavaCore.setOptions(oldOptions);
329
		JavaCore.setOptions(options);
330
	}
300
	}
331
}
301
}
332
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
302
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
333
public void testDeprecationCheck6() throws JavaModelException {
303
public void testCamelCaseType1() throws JavaModelException {
334
	Hashtable options = JavaCore.getOptions();
304
	this.oldOptions = JavaCore.getOptions();
335
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
336
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
337
	
338
	JavaCore.setOptions(options);
339
340
	try {
305
	try {
341
306
		Hashtable options = new Hashtable(oldOptions);
342
		this.workingCopies = new ICompilationUnit[2];
307
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
308
		JavaCore.setOptions(options);
309
		
310
		this.workingCopies = new ICompilationUnit[3];
343
		this.workingCopies[0] = getWorkingCopy(
311
		this.workingCopies[0] = getWorkingCopy(
344
			"/Completion/src/deprecation/Test.java",
312
			"/Completion/src/camelcase/Test.java",
345
			"package deprecation;"+
313
			"package camelcase;"+
346
			"public class Test {\n"+
314
			"public class Test {\n"+
347
			"  ZZZType1.Inn\n"+
315
			"  FF\n"+
348
			"}");
316
			"}");
349
		
317
	
350
		this.workingCopies[1] = getWorkingCopy(
318
		this.workingCopies[1] = getWorkingCopy(
351
			"/Completion/src/deprecation/ZZZType1.java",
319
			"/Completion/src/camelcase/FoFoFo.java",
352
			"package deprecation;"+
320
			"package camelcase;"+
353
			"public class ZZZType1 {\n"+
321
			"public class FoFoFo {\n"+
354
			"  public class Inner1 {}\n"+
322
			"}");
355
			"  /** @deprecated */\n"+
323
		
356
			"  public class Inner2 {}\n"+
324
		this.workingCopies[2] = getWorkingCopy(
325
			"/Completion/src/camelcase/FFFTest.java",
326
			"package camelcase;"+
327
			"public class FFFTest {\n"+
357
			"}");
328
			"}");
358
	
329
	
359
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
330
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
360
		String str = this.workingCopies[0].getSource();
331
		String str = this.workingCopies[0].getSource();
361
		String completeBehind = "ZZZType1.Inn";
332
		String completeBehind = "FF";
362
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
333
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
363
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
334
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
364
	
335
	
365
		assertResults(
336
		assertResults(
366
				"ZZZType1.Inner1[TYPE_REF]{Inner1, deprecation, Ldeprecation.ZZZType1$Inner1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
337
				"FF[POTENTIAL_METHOD_DECLARATION]{FF, Lcamelcase.Test;, ()V, FF, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
338
				"FoFoFo[TYPE_REF]{FoFoFo, camelcase, Lcamelcase.FoFoFo;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
339
				"FFFTest[TYPE_REF]{FFFTest, camelcase, Lcamelcase.FFFTest;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
367
				requestor.getResults());
340
				requestor.getResults());
368
	} finally {
341
	} finally {
369
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
342
		JavaCore.setOptions(oldOptions);
370
		JavaCore.setOptions(options);
371
	}
343
	}
372
}
344
}
373
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
345
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
374
public void testDeprecationCheck7() throws JavaModelException {
346
public void testCamelCaseType2() throws JavaModelException {
375
	Hashtable options = JavaCore.getOptions();
347
	this.oldOptions = JavaCore.getOptions();
376
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
377
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED); //$NON-NLS-1$
378
	
379
	JavaCore.setOptions(options);
380
381
	try {
348
	try {
382
349
		Hashtable options = new Hashtable(oldOptions);
383
		this.workingCopies = new ICompilationUnit[2];
350
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
351
		JavaCore.setOptions(options);
352
		
353
		this.workingCopies = new ICompilationUnit[3];
384
		this.workingCopies[0] = getWorkingCopy(
354
		this.workingCopies[0] = getWorkingCopy(
385
			"/Completion/src/deprecation/Test.java",
355
			"/Completion/src/camelcase/Test.java",
386
			"package deprecation;"+
356
			"package camelcase;"+
387
			"public class Test {\n"+
357
			"public class Test {\n"+
388
			"  void foo() {"+
358
			"  camelcase.FF\n"+
389
			"    ZZZType1.fo\n"+
390
			"  }"+
391
			"}");
359
			"}");
392
		
360
	
393
		this.workingCopies[1] = getWorkingCopy(
361
		this.workingCopies[1] = getWorkingCopy(
394
			"/Completion/src/deprecation/ZZZType1.java",
362
			"/Completion/src/camelcase/FoFoFo.java",
395
			"package deprecation;"+
363
			"package camelcase;"+
396
			"public class ZZZType1 {\n"+
364
			"public class FoFoFo {\n"+
397
			"  public static int foo1;\n"+
365
			"}");
398
			"  /** @deprecated */\n"+
366
		
399
			"  public static int foo2;\n"+
367
		this.workingCopies[2] = getWorkingCopy(
368
			"/Completion/src/camelcase/FFFTest.java",
369
			"package camelcase;"+
370
			"public class FFFTest {\n"+
400
			"}");
371
			"}");
401
	
372
	
402
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
373
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
403
		String str = this.workingCopies[0].getSource();
374
		String str = this.workingCopies[0].getSource();
404
		String completeBehind = "ZZZType1.fo";
375
		String completeBehind = "FF";
405
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
376
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
406
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
377
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
407
	
378
	
408
		assertResults(
379
		assertResults(
409
				"foo1[FIELD_REF]{foo1, Ldeprecation.ZZZType1;, I, foo1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n" +
380
				"FoFoFo[TYPE_REF]{FoFoFo, camelcase, Lcamelcase.FoFoFo;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_NON_RESTRICTED) + "}\n" +
410
				"foo2[FIELD_REF]{foo2, Ldeprecation.ZZZType1;, I, foo2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}",
381
				"FFFTest[TYPE_REF]{FFFTest, camelcase, Lcamelcase.FFFTest;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
411
				requestor.getResults());
382
				requestor.getResults());
412
	} finally {
383
	} finally {
413
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
384
		JavaCore.setOptions(oldOptions);
414
		JavaCore.setOptions(options);
415
	}
385
	}
416
}
386
}
417
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
387
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
418
public void testDeprecationCheck8() throws JavaModelException {
388
public void testCamelCaseType3() throws JavaModelException {
419
	Hashtable options = JavaCore.getOptions();
389
	this.oldOptions = JavaCore.getOptions();
420
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
421
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
422
	
423
	JavaCore.setOptions(options);
424
425
	try {
390
	try {
426
391
		Hashtable options = new Hashtable(oldOptions);
427
		this.workingCopies = new ICompilationUnit[2];
392
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
393
		JavaCore.setOptions(options);
394
			
395
		this.workingCopies = new ICompilationUnit[1];
428
		this.workingCopies[0] = getWorkingCopy(
396
		this.workingCopies[0] = getWorkingCopy(
429
			"/Completion/src/deprecation/Test.java",
397
			"/Completion/src/camelcase/Test.java",
430
			"package deprecation;"+
398
			"package camelcase;"+
431
			"public class Test {\n"+
399
			"public class Test {\n"+
432
			"  void foo() {"+
400
			"  /**/FF\n"+
433
			"    ZZZType1.fo\n"+
401
			"}\n"+
434
			"  }"+
402
			"class FoFoFo {\n"+
435
			"}");
403
			"}\n"+
436
		
404
			"class FFFTest {\n"+
437
		this.workingCopies[1] = getWorkingCopy(
438
			"/Completion/src/deprecation/ZZZType1.java",
439
			"package deprecation;"+
440
			"public class ZZZType1 {\n"+
441
			"  public static int foo1;\n"+
442
			"  /** @deprecated */\n"+
443
			"  public static int foo2;\n"+
444
			"}");
405
			"}");
445
	
406
	
446
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
407
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
447
		String str = this.workingCopies[0].getSource();
408
		String str = this.workingCopies[0].getSource();
448
		String completeBehind = "ZZZType1.fo";
409
		String completeBehind = "/**/FF";
449
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
410
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
450
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
411
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
451
	
412
	
452
		assertResults(
413
		assertResults(
453
				"foo1[FIELD_REF]{foo1, Ldeprecation.ZZZType1;, I, foo1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}",
414
				"FF[POTENTIAL_METHOD_DECLARATION]{FF, Lcamelcase.Test;, ()V, FF, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
415
				"FoFoFo[TYPE_REF]{FoFoFo, camelcase, Lcamelcase.FoFoFo;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
416
				"FFFTest[TYPE_REF]{FFFTest, camelcase, Lcamelcase.FFFTest;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
454
				requestor.getResults());
417
				requestor.getResults());
455
	} finally {
418
	} finally {
456
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
419
		JavaCore.setOptions(oldOptions);
457
		JavaCore.setOptions(options);
458
	}
420
	}
459
}
421
}
460
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
461
public void testDeprecationCheck9() throws JavaModelException {
462
	Hashtable options = JavaCore.getOptions();
463
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
464
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED); //$NON-NLS-1$
465
	
466
	JavaCore.setOptions(options);
467
422
423
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
424
public void testCamelCaseType4() throws JavaModelException {
425
	this.oldOptions = JavaCore.getOptions();
468
	try {
426
	try {
469
427
		Hashtable options = new Hashtable(oldOptions);
470
		this.workingCopies = new ICompilationUnit[1];
428
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
429
		JavaCore.setOptions(options);
430
		
431
		this.workingCopies = new ICompilationUnit[3];
471
		this.workingCopies[0] = getWorkingCopy(
432
		this.workingCopies[0] = getWorkingCopy(
472
			"/Completion/src/deprecation/Test.java",
433
			"/Completion/src/camelcase/Test.java",
473
			"package deprecation;"+
434
			"package camelcase;"+
474
			"public class Test {\n"+
435
			"public class Test {\n"+
475
			"  public void bar1(){}\n"+
436
			"  FF\n"+
476
			"  /** @deprecated */\n"+
437
			"}");
477
			"  public void bar2(){}\n"+
438
	
478
			"  void foo() {"+
439
		this.workingCopies[1] = getWorkingCopy(
479
			"    bar\n"+
440
			"/Completion/src/camelcase/Member1.java",
480
			"  }"+
441
			"package camelcase;"+
442
			"public class Member1 {\n"+
443
			"  public class FoFoFo {\n"+
444
			"  }\n"+
445
			"}");
446
		
447
		this.workingCopies[2] = getWorkingCopy(
448
			"/Completion/src/camelcase/Member2.java",
449
			"package camelcase;"+
450
			"public class Member2 {\n"+
451
			"  public class FFFTest {\n"+
452
			"  }\n"+
481
			"}");
453
			"}");
482
	
454
	
483
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
455
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
484
		String str = this.workingCopies[0].getSource();
456
		String str = this.workingCopies[0].getSource();
485
		String completeBehind = "bar";
457
		String completeBehind = "FF";
486
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
458
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
487
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
459
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
488
	
460
	
489
		assertResults(
461
		assertResults(
490
				"bar1[METHOD_REF]{bar1(), Ldeprecation.Test;, ()V, bar1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
462
				"FF[POTENTIAL_METHOD_DECLARATION]{FF, Lcamelcase.Test;, ()V, FF, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
491
				"bar2[METHOD_REF]{bar2(), Ldeprecation.Test;, ()V, bar2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
463
				"Member1.FoFoFo[TYPE_REF]{camelcase.Member1.FoFoFo, camelcase, Lcamelcase.Member1$FoFoFo;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_NON_RESTRICTED) + "}\n" +
464
				"Member2.FFFTest[TYPE_REF]{camelcase.Member2.FFFTest, camelcase, Lcamelcase.Member2$FFFTest;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
492
				requestor.getResults());
465
				requestor.getResults());
493
	} finally {
466
	} finally {
494
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
467
		JavaCore.setOptions(oldOptions);
495
		JavaCore.setOptions(options);
496
	}
468
	}
497
}
469
}
498
470
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
499
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
471
public void testCamelCaseType5() throws JavaModelException {
500
public void testDeprecationCheck10() throws JavaModelException {
472
	this.oldOptions = JavaCore.getOptions();
501
	Hashtable options = JavaCore.getOptions();
502
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
503
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
504
	
505
	JavaCore.setOptions(options);
506
507
	try {
473
	try {
508
474
		Hashtable options = new Hashtable(oldOptions);
475
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
476
		JavaCore.setOptions(options);
477
		
509
		this.workingCopies = new ICompilationUnit[1];
478
		this.workingCopies = new ICompilationUnit[1];
510
		this.workingCopies[0] = getWorkingCopy(
479
		this.workingCopies[0] = getWorkingCopy(
511
			"/Completion/src/deprecation/Test.java",
480
			"/Completion/src/camelcase/Test.java",
512
			"package deprecation;"+
481
			"package camelcase;"+
513
			"public class Test {\n"+
482
			"public class Test {\n"+
514
			"  public void bar1(){}\n"+
483
			"  public class FoFoFo {\n"+
515
			"  /** @deprecated */\n"+
484
			"    public class FFFTest {\n"+
516
			"  public void bar2(){}\n"+
485
			"      FF\n"+
517
			"  void foo() {"+
486
			"    }\n"+
518
			"    bar\n"+
487
			"  }\n"+
519
			"  }"+
520
			"}");
488
			"}");
521
	
489
	
522
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
490
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
523
		String str = this.workingCopies[0].getSource();
491
		String str = this.workingCopies[0].getSource();
524
		String completeBehind = "bar";
492
		String completeBehind = "FF";
525
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
493
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
526
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
494
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
527
	
495
	
528
		assertResults(
496
		assertResults(
529
				"bar1[METHOD_REF]{bar1(), Ldeprecation.Test;, ()V, bar1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
497
				"FF[POTENTIAL_METHOD_DECLARATION]{FF, Lcamelcase.Test$FoFoFo$FFFTest;, ()V, FF, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
530
				"bar2[METHOD_REF]{bar2(), Ldeprecation.Test;, ()V, bar2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
498
				"Test.FoFoFo[TYPE_REF]{FoFoFo, camelcase, Lcamelcase.Test$FoFoFo;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
499
				"Test.FoFoFo.FFFTest[TYPE_REF]{FFFTest, camelcase, Lcamelcase.Test$FoFoFo$FFFTest;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
531
				requestor.getResults());
500
				requestor.getResults());
532
	} finally {
501
	} finally {
533
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
502
		JavaCore.setOptions(oldOptions);
534
		JavaCore.setOptions(options);
535
	}
503
	}
536
}
504
}
537
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
505
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
538
public void testDeprecationCheck11() throws JavaModelException {
506
public void testCatchClauseExceptionRef01() throws JavaModelException {
539
	Hashtable options = JavaCore.getOptions();
507
	this.workingCopies = new ICompilationUnit[4];
540
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
508
	this.workingCopies[0] = getWorkingCopy(
541
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED); //$NON-NLS-1$
509
		"/Completion/src/test/Test.java",
510
		"package test;"+
511
		"public class Test {\n" + 
512
		"	public void throwing() throws IZZAException, IZZException {}\n" +
513
		"	public void foo() {\n" +
514
		"      try {\n" +
515
		"         throwing();\n" +
516
		"      }\n" +
517
		"      catch (IZZAException e) {\n" +
518
		"         bar();\n" +
519
		"      }\n" +
520
		"      catch (IZZ) {\n" +
521
		"      }\n" +
522
		"   }" +
523
		"}\n");
542
	
524
	
543
	JavaCore.setOptions(options);
525
	this.workingCopies[1] = getWorkingCopy(
526
			"/Completion/src/test/IZZAException.java",
527
			"package test;"+
528
			"public class IZZAException extends Exception {\n" + 
529
			"}\n");
530
	
531
	this.workingCopies[2] = getWorkingCopy(
532
			"/Completion/src/test/IZZBException.java",
533
			"package test;"+
534
			"public class IZZBException extends Exception {\n" + 
535
			"}\n");
536
	
537
	this.workingCopies[3] = getWorkingCopy(
538
			"/Completion/src/test/IZZException.java",
539
			"package test;"+
540
			"public class IZZException extends Exception {\n" + 
541
			"}\n");
544
542
545
	try {
543
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
544
	String str = this.workingCopies[0].getSource();
545
	String completeBehind = "IZZ";
546
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
547
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
546
548
547
		this.workingCopies = new ICompilationUnit[1];
549
	assertResults(
548
		this.workingCopies[0] = getWorkingCopy(
550
			"IZZBException[TYPE_REF]{IZZBException, test, Ltest.IZZBException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}\n" +
549
			"/Completion/src/deprecation/Test.java",
551
			"IZZException[TYPE_REF]{IZZException, test, Ltest.IZZException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
550
			"package deprecation;"+
552
			requestor.getResults());
551
			"public class Test {\n"+
553
}
552
			"  public int bar1;\n"+
554
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
553
			"  /** @deprecated */\n"+
555
public void testCatchClauseExceptionRef02() throws JavaModelException {
554
			"  public int bar2;\n"+
556
	this.workingCopies = new ICompilationUnit[4];
555
			"  void foo() {"+
557
	this.workingCopies[0] = getWorkingCopy(
556
			"    bar\n"+
558
		"/Completion/src/test/Test.java",
557
			"  }"+
559
		"package test;"+
558
			"}");
560
		"public class Test {\n" + 
561
		"	public void throwing() throws IZZAException, IZZException {}\n" +
562
		"	public void foo() {\n" +
563
		"      try {\n" +
564
		"         throwing()\n" +
565
		"      }\n" +
566
		"      catch (IZZAException e) {\n" +
567
		"         bar();\n" +
568
		"      }\n" +
569
		"      catch (IZZ) {\n" +
570
		"      }\n" +
571
		"   }" +
572
		"}\n");
559
	
573
	
560
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
574
	this.workingCopies[1] = getWorkingCopy(
561
		String str = this.workingCopies[0].getSource();
575
			"/Completion/src/test/IZZAException.java",
562
		String completeBehind = "bar";
576
			"package test;"+
563
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
577
			"public class IZZAException extends Exception {\n" + 
564
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
578
			"}\n");
565
	
579
	
566
		assertResults(
580
	this.workingCopies[2] = getWorkingCopy(
567
				"bar1[FIELD_REF]{bar1, Ldeprecation.Test;, I, bar1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
581
			"/Completion/src/test/IZZBException.java",
568
				"bar2[FIELD_REF]{bar2, Ldeprecation.Test;, I, bar2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
582
			"package test;"+
569
				requestor.getResults());
583
			"public class IZZBException extends Exception {\n" + 
570
	} finally {
584
			"}\n");
571
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
572
		JavaCore.setOptions(options);
573
	}
574
}
575
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
576
public void testDeprecationCheck12() throws JavaModelException {
577
	Hashtable options = JavaCore.getOptions();
578
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
579
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
580
	
585
	
581
	JavaCore.setOptions(options);
586
	this.workingCopies[3] = getWorkingCopy(
587
			"/Completion/src/test/IZZException.java",
588
			"package test;"+
589
			"public class IZZException extends Exception {\n" + 
590
			"}\n");
582
591
583
	try {
592
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
593
	String str = this.workingCopies[0].getSource();
594
	String completeBehind = "IZZ";
595
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
596
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
584
597
585
		this.workingCopies = new ICompilationUnit[1];
598
	assertResults(
586
		this.workingCopies[0] = getWorkingCopy(
599
			"IZZAException[TYPE_REF]{IZZAException, test, Ltest.IZZAException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}\n" +
587
			"/Completion/src/deprecation/Test.java",
600
			"IZZBException[TYPE_REF]{IZZBException, test, Ltest.IZZBException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}\n" +
588
			"package deprecation;"+
601
			"IZZException[TYPE_REF]{IZZException, test, Ltest.IZZException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}",
589
			"public class Test {\n"+
602
			requestor.getResults());
590
			"  public int bar1;\n"+
603
}
591
			"  /** @deprecated */\n"+
604
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
592
			"  public int bar2;\n"+
605
public void testCatchClauseExceptionRef03() throws JavaModelException {
593
			"  void foo() {"+
606
	this.workingCopies = new ICompilationUnit[4];
594
			"    bar\n"+
607
	this.workingCopies[0] = getWorkingCopy(
595
			"  }"+
608
		"/Completion/src/test/Test.java",
596
			"}");
609
		"package test;"+
610
		"public class Test {\n" + 
611
		"	public void throwing() throws IZZAException, IZZException {}\n" +
612
		"	public void foo() {\n" +
613
		"      #\n" +
614
		"      try {\n" +
615
		"         throwing();\n" +
616
		"      }\n" +
617
		"      catch (IZZAException e) {\n" +
618
		"         bar();\n" +
619
		"      }\n" +
620
		"      catch (IZZ) {\n" +
621
		"      }\n" +
622
		"   }" +
623
		"}\n");
597
	
624
	
598
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
625
	this.workingCopies[1] = getWorkingCopy(
599
		String str = this.workingCopies[0].getSource();
626
			"/Completion/src/test/IZZAException.java",
600
		String completeBehind = "bar";
627
			"package test;"+
601
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
628
			"public class IZZAException extends Exception {\n" + 
602
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
629
			"}\n");
603
	
630
	
604
		assertResults(
631
	this.workingCopies[2] = getWorkingCopy(
605
				"bar1[FIELD_REF]{bar1, Ldeprecation.Test;, I, bar1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
632
			"/Completion/src/test/IZZBException.java",
606
				"bar2[FIELD_REF]{bar2, Ldeprecation.Test;, I, bar2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
633
			"package test;"+
607
				requestor.getResults());
634
			"public class IZZBException extends Exception {\n" + 
608
	} finally {
635
			"}\n");
609
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
610
		JavaCore.setOptions(options);
611
	}
612
}
613
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
614
public void testDeprecationCheck13() throws JavaModelException {
615
	Hashtable options = JavaCore.getOptions();
616
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
617
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED); //$NON-NLS-1$
618
	
636
	
619
	JavaCore.setOptions(options);
637
	this.workingCopies[3] = getWorkingCopy(
620
638
			"/Completion/src/test/IZZException.java",
621
	try {
639
			"package test;"+
622
640
			"public class IZZException extends Exception {\n" + 
623
		this.workingCopies = new ICompilationUnit[1];
641
			"}\n");
624
		this.workingCopies[0] = getWorkingCopy(
625
			"/Completion/src/deprecation/Test.java",
626
			"package deprecation;"+
627
			"public class Test {\n"+
628
			"  class Inner1 {}\n"+
629
			"  /** @deprecated */\n"+
630
			"  class Inner2 {}\n"+
631
			"  void foo() {"+
632
			"    Inn\n"+
633
			"  }"+
634
			"}");
635
	
636
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
637
		String str = this.workingCopies[0].getSource();
638
		String completeBehind = "Inn";
639
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
640
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
641
	
642
		assertResults(
643
				"Test.Inner1[TYPE_REF]{Inner1, deprecation, Ldeprecation.Test$Inner1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
644
				"Test.Inner2[TYPE_REF]{Inner2, deprecation, Ldeprecation.Test$Inner2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
645
				requestor.getResults());
646
	} finally {
647
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
648
		JavaCore.setOptions(options);
649
	}
650
}
651
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
652
public void testDeprecationCheck14() throws JavaModelException {
653
	Hashtable options = JavaCore.getOptions();
654
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
655
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
656
	
657
	JavaCore.setOptions(options);
658
659
	try {
660
661
		this.workingCopies = new ICompilationUnit[2];
662
		this.workingCopies[0] = getWorkingCopy(
663
			"/Completion/src/deprecation/Test.java",
664
			"package deprecation;"+
665
			"public class Test {\n"+
666
			"  class Inner1 {}\n"+
667
			"  /** @deprecated */\n"+
668
			"  class Inner2 {}\n"+
669
			"  void foo() {"+
670
			"    Inn\n"+
671
			"  }"+
672
			"}");
673
	
674
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
675
		String str = this.workingCopies[0].getSource();
676
		String completeBehind = "Inn";
677
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
678
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
679
	
680
		assertResults(
681
				"Test.Inner1[TYPE_REF]{Inner1, deprecation, Ldeprecation.Test$Inner1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
682
				"Test.Inner2[TYPE_REF]{Inner2, deprecation, Ldeprecation.Test$Inner2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
683
				requestor.getResults());
684
	} finally {
685
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
686
		JavaCore.setOptions(options);
687
	}
688
}
689
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
690
public void testDeprecationCheck15() throws JavaModelException {
691
	Hashtable options = JavaCore.getOptions();
692
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
693
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
694
	
695
	JavaCore.setOptions(options);
696
642
697
	try {
643
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
644
	String str = this.workingCopies[0].getSource();
645
	String completeBehind = "IZZ";
646
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
647
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
698
648
699
		this.workingCopies = new ICompilationUnit[2];
649
	assertResults(
700
		this.workingCopies[0] = getWorkingCopy(
650
			"IZZAException[TYPE_REF]{IZZAException, test, Ltest.IZZAException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}\n" +
701
			"/Completion/src/deprecation/Test.java",
651
			"IZZBException[TYPE_REF]{IZZBException, test, Ltest.IZZBException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}\n" +
702
			"package deprecation;"+
652
			"IZZException[TYPE_REF]{IZZException, test, Ltest.IZZException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}",
703
			"public class Test {\n"+
653
			requestor.getResults());
704
			"  void foo() {"+
705
			"    ZZZType1.foo\n"+
706
			"  }"+
707
			"}");
708
		
709
		this.workingCopies[1] = getWorkingCopy(
710
			"/Completion/src/deprecation/ZZZType1.java",
711
			"package deprecation;"+
712
			"/** @deprecated */\n"+
713
			"public class ZZZType1 {\n"+
714
			"  public static int foo1;\n"+
715
			"  public static int foo2;\n"+
716
			"}");
717
	
718
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
719
		String str = this.workingCopies[0].getSource();
720
		String completeBehind = "ZZZType1.foo";
721
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
722
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
723
	
724
		assertResults(
725
				"",
726
				requestor.getResults());
727
	} finally {
728
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
729
		JavaCore.setOptions(options);
730
	}
731
}
654
}
732
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
655
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
733
public void testDeprecationCheck16() throws JavaModelException {
656
public void testCatchClauseExceptionRef04() throws JavaModelException {
734
	Hashtable options = JavaCore.getOptions();
657
	this.workingCopies = new ICompilationUnit[4];
735
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
658
	this.workingCopies[0] = getWorkingCopy(
736
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
659
		"/Completion/src/test/Test.java",
737
	
660
		"package test;"+
738
	JavaCore.setOptions(options);
661
		"public class Test {\n" + 
739
662
		"	public void throwing() throws test.p.IZZAException, test.p.IZZException {}\n" +
740
	try {
663
		"	public void foo() {\n" +
741
664
		"      try {\n" +
742
		this.workingCopies = new ICompilationUnit[1];
665
		"         throwing();\n" +
743
		this.workingCopies[0] = getWorkingCopy(
666
		"      }\n" +
744
			"/Completion/src/deprecation/Test.java",
667
		"      catch (test.p.IZZAException e) {\n" +
745
			"package deprecation;"+
668
		"         bar();\n" +
746
			"/** @deprecated */\n"+
669
		"      }\n" +
747
			"public class ZZZType1 {\n"+
670
		"      catch (IZZ) {\n" +
748
			"}"+
671
		"      }\n" +
749
			"public class Test {\n"+
672
		"   }" +
750
			"  void foo() {"+
673
		"}\n");
751
			"    ZZZTy\n"+
752
			"  }"+
753
			"}");
754
	
674
	
755
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
675
	this.workingCopies[1] = getWorkingCopy(
756
		String str = this.workingCopies[0].getSource();
676
			"/Completion/src/test/p/IZZAException.java",
757
		String completeBehind = "ZZZTy";
677
			"package test.p;"+
758
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
678
			"public class IZZAException extends Exception {\n" + 
759
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
679
			"}\n");
760
	
680
	
761
		assertResults(
681
	this.workingCopies[2] = getWorkingCopy(
762
				"ZZZType1[TYPE_REF]{ZZZType1, deprecation, Ldeprecation.ZZZType1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
682
			"/Completion/src/test/p/IZZBException.java",
763
				requestor.getResults());
683
			"package test.p;"+
764
	} finally {
684
			"public class IZZBException extends Exception {\n" + 
765
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
685
			"}\n");
766
		JavaCore.setOptions(options);
767
	}
768
}
769
770
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127628
771
public void testDeprecationCheck17() throws JavaModelException {
772
	Hashtable options = JavaCore.getOptions();
773
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
774
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
775
	
686
	
776
	JavaCore.setOptions(options);
687
	this.workingCopies[3] = getWorkingCopy(
688
			"/Completion/src/test/p/IZZException.java",
689
			"package test.p;"+
690
			"public class IZZException extends Exception {\n" + 
691
			"}\n");
777
692
778
	try {
693
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
694
	String str = this.workingCopies[0].getSource();
695
	String completeBehind = "IZZ";
696
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
697
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
779
698
780
		this.workingCopies = new ICompilationUnit[1];
699
	assertResults(
781
		this.workingCopies[0] = getWorkingCopy(
700
			"IZZBException[TYPE_REF]{test.p.IZZBException, test.p, Ltest.p.IZZBException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXCEPTION + R_NON_RESTRICTED) + "}\n" +
782
			"/Completion/src/deprecation/Test.java",
701
			"IZZException[TYPE_REF]{test.p.IZZException, test.p, Ltest.p.IZZException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXCEPTION + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
783
			"package deprecation;"+
702
			requestor.getResults());
784
			"public class Test {\n"+
785
			"  Bug127628Ty\n"+
786
			"}");
787
	
788
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
789
		String str = this.workingCopies[0].getSource();
790
		String completeBehind = "Bug127628Ty";
791
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
792
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
793
	
794
		assertResults(
795
				"Bug127628Ty[POTENTIAL_METHOD_DECLARATION]{Bug127628Ty, Ldeprecation.Test;, ()V, Bug127628Ty, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
796
				"Bug127628Type1.Bug127628TypeInner1[TYPE_REF]{deprecation.Bug127628Type1.Bug127628TypeInner1, deprecation, Ldeprecation.Bug127628Type1$Bug127628TypeInner1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
797
				"Bug127628Type2.Bug127628TypeInner2[TYPE_REF]{deprecation.Bug127628Type2.Bug127628TypeInner2, deprecation, Ldeprecation.Bug127628Type2$Bug127628TypeInner2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
798
				"Bug127628Type1[TYPE_REF]{Bug127628Type1, deprecation, Ldeprecation.Bug127628Type1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
799
				requestor.getResults());
800
	} finally {
801
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
802
		JavaCore.setOptions(options);
803
	}
804
}
703
}
805
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=144858
704
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
806
public void testDuplicateLocals1() throws JavaModelException {
705
public void testCatchClauseExceptionRef05() throws JavaModelException {
807
	this.workingCopies = new ICompilationUnit[2];
706
	this.workingCopies = new ICompilationUnit[1];
808
	this.workingCopies[0] = getWorkingCopy(
707
	this.workingCopies[0] = getWorkingCopy(
809
		"/Completion/src/test/Test.java",
708
		"/Completion/src/test/Test.java",
810
		"package test;"+
709
		"package test;"+
811
		"public class Test {\n" + 
710
		"public class Test {\n" + 
812
		"	void foo() {\n" + 
711
		"	public class IZZAException extends Exception {}\n" +
813
		"		int x = 0;\n" + 
712
		"	public class IZZBException extends Exception {}\n" +
814
		"		TestString x = null;\n" + 
713
		"	public class IZZException extends Exception {}\n" +
815
		"		x.bar;\n" + 
714
		"	public void throwing() throws IZZAException, IZZException {}\n" +
816
		"	}\n" + 
715
		"	public void foo() {\n" +
817
		"}");
716
		"      try {\n" +
818
	
717
		"         throwing();\n" +
819
	this.workingCopies[1] = getWorkingCopy(
718
		"      }\n" +
820
		"/Completion/src/test/TestString.java",
719
		"      catch (IZZAException e) {\n" +
821
		"package test;"+
720
		"         bar();\n" +
822
		"public class TestString {\n" + 
721
		"      }\n" +
823
		"	public void bar() {\n" + 
722
		"      catch (IZZ) {\n" +
824
		"	}\n" + 
723
		"      }\n" +
825
		"}");
724
		"   }" +
725
		"}\n");
826
726
827
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
727
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
828
	String str = this.workingCopies[0].getSource();
728
	String str = this.workingCopies[0].getSource();
829
	String completeBehind = "bar";
729
	String completeBehind = "IZZ";
830
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
730
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
831
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
731
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
832
732
833
	assertResults(
733
	assertResults(
834
			"bar[METHOD_REF]{bar(), Ltest.TestString;, ()V, bar, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
734
			"Test.IZZBException[TYPE_REF]{IZZBException, test, Ltest.Test$IZZBException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}\n" +
735
			"Test.IZZException[TYPE_REF]{IZZException, test, Ltest.Test$IZZException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
835
			requestor.getResults());
736
			requestor.getResults());
836
}
737
}
837
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=144858
738
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
838
public void testDuplicateLocals2() throws JavaModelException {
739
public void testCatchClauseExceptionRef06() throws JavaModelException {
839
	this.workingCopies = new ICompilationUnit[2];
740
	this.workingCopies = new ICompilationUnit[1];
840
	this.workingCopies[0] = getWorkingCopy(
741
	this.workingCopies[0] = getWorkingCopy(
841
		"/Completion/src/test/Test.java",
742
		"/Completion/src/test/Test.java",
842
		"package test;"+
743
		"package test;"+
843
		"public class Test {\n" + 
744
		"public class Test {\n" + 
844
		"        public static void main(String[] args) {\n" + 
745
		"   public class Inner {\n" + 
845
		"                int x = 2;\n" + 
746
		"      public class IZZAException extends Exception {}\n" +
846
		"                try {\n" + 
747
		"      public class IZZBException extends Exception {}\n" +
847
		"                \n" + 
748
		"      public class IZZException extends Exception {}\n" +
848
		"                } catch(TestException x) {\n" + 
749
		"      public void throwing() throws IZZAException, IZZException {}\n" +
849
		"                        x.bar\n" + 
750
		"      public void foo() {\n" +
850
		"                } catch(Exception e) {\n" + 
751
		"         try {\n" +
851
		"                }\n" + 
752
		"            throwing();\n" +
852
		"        }\n" + 
753
		"         }\n" +
853
		"}");
754
		"         catch (IZZAException e) {\n" +
854
	
755
		"            bar();\n" +
855
	this.workingCopies[1] = getWorkingCopy(
756
		"         }\n" +
856
		"/Completion/src/test/TestException.java",
757
		"         catch (IZZ) {\n" +
857
		"package test;"+
758
		"         }\n" +
858
		"public class TestException extends Exception {\n" + 
759
		"      }" +
859
		"	public void bar() {\n" + 
760
		"   }" +
860
		"	}\n" + 
761
		"}\n");
861
		"}");
862
762
863
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
763
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
864
	String str = this.workingCopies[0].getSource();
764
	String str = this.workingCopies[0].getSource();
865
	String completeBehind = "bar";
765
	String completeBehind = "IZZ";
866
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
766
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
867
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
767
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
868
768
869
	assertResults(
769
	assertResults(
870
			"bar[METHOD_REF]{bar(), Ltest.TestException;, ()V, bar, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
770
			"Test.Inner.IZZBException[TYPE_REF]{IZZBException, test, Ltest.Test$Inner$IZZBException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}\n" +
771
			"Test.Inner.IZZException[TYPE_REF]{IZZException, test, Ltest.Test$Inner$IZZException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
871
			requestor.getResults());
772
			requestor.getResults());
872
}
773
}
873
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=144858
774
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
874
public void testDuplicateLocals3() throws JavaModelException {
775
public void testCatchClauseExceptionRef07() throws JavaModelException {
875
	this.workingCopies = new ICompilationUnit[2];
776
	this.workingCopies = new ICompilationUnit[1];
876
	this.workingCopies[0] = getWorkingCopy(
777
	this.workingCopies[0] = getWorkingCopy(
877
		"/Completion/src/test/Test.java",
778
		"/Completion/src/test/Test.java",
878
		"package test;"+
779
		"package test;"+
879
		"public class Test {\n" + 
780
		"public class Test {\n" + 
880
		"        public static void main(String[] args) {\n" + 
781
		"   void zork() {\n" + 
881
		"                int x = x = 0;\n" + 
782
		"      class IZZAException extends Exception {}\n" +
882
		"                if (true) {\n" + 
783
		"      class IZZBException extends Exception {}\n" +
883
		"                        TestString x = x.bar\n" + 
784
		"      class IZZException extends Exception {}\n" +
884
		"                }\n" + 
785
		"      class Local {\n" + 
885
		"        }\n" + 
786
		"         public void throwing() throws IZZAException, IZZException {}\n" +
886
		"}");
787
		"         public void foo() {\n" +
887
	
788
		"            try {\n" +
888
	this.workingCopies[1] = getWorkingCopy(
789
		"               throwing();\n" +
889
		"/Completion/src/test/TestString.java",
790
		"            }\n" +
890
		"package test;"+
791
		"            catch (IZZAException e) {\n" +
891
		"public class TestString {\n" + 
792
		"               bar();\n" +
892
		"	public void bar() {\n" + 
793
		"            }\n" +
893
		"	}\n" + 
794
		"            catch (IZZ) {\n" +
894
		"}");
795
		"            }\n" +
796
		"         }" +
797
		"      }" +
798
		"   }" +
799
		"}\n");
895
800
896
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
801
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
897
	String str = this.workingCopies[0].getSource();
802
	String str = this.workingCopies[0].getSource();
898
	String completeBehind = "bar";
803
	String completeBehind = "IZZ";
899
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
804
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
900
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
805
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
901
806
902
	assertResults(
807
	assertResults(
903
			"bar[METHOD_REF]{bar(), Ltest.TestString;, ()V, bar, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
808
			"IZZBException[TYPE_REF]{IZZBException, test, LIZZBException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}\n" +
809
			"IZZException[TYPE_REF]{IZZException, test, LIZZException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
904
			requestor.getResults());
810
			requestor.getResults());
905
}
811
}
906
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=144858
812
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
907
public void testDuplicateLocals4() throws JavaModelException {
813
public void testCatchClauseExceptionRef08() throws JavaModelException {
908
	this.workingCopies = new ICompilationUnit[2];
814
	this.workingCopies = new ICompilationUnit[4];
909
	this.workingCopies[0] = getWorkingCopy(
815
	this.workingCopies[0] = getWorkingCopy(
910
		"/Completion/src/test/Test.java",
816
		"/Completion/src/test/Test.java",
911
		"package test;"+
817
		"package test;"+
912
		"public class Test {\n" + 
818
		"public class Test {\n" + 
913
		"        public static void main(String[] args) {\n" + 
819
		"	public void throwing() throws IZZAException, IZZException {}\n" +
914
		"                for (int i = 0; i < 10; i++) {\n" + 
820
		"	public void foo() {\n" +
915
		"                        for (TestString i = null; i.bar < 5;)  {\n" + 
821
		"      try {\n" +
916
		"                                // do something\n" + 
822
		"         throwing();\n" +
917
		"                        }\n" + 
823
		"      }\n" +
918
		"                }\n" + 
824
		"      catch (IZZAException e) {\n" +
919
		"        }\n" + 
825
		"         bar();\n" +
920
		"}");
826
		"      }\n" +
827
		"      catch (/**/) {\n" +
828
		"      }\n" +
829
		"   }" +
830
		"}\n");
921
	
831
	
922
	this.workingCopies[1] = getWorkingCopy(
832
	this.workingCopies[1] = getWorkingCopy(
923
		"/Completion/src/test/TestString.java",
833
			"/Completion/src/test/IZZAException.java",
924
		"package test;"+
834
			"package test;"+
925
		"public class TestString {\n" + 
835
			"public class IZZAException extends Exception {\n" + 
926
		"	public void bar() {\n" + 
836
			"}\n");
927
		"	}\n" + 
837
	
928
		"}");
838
	this.workingCopies[2] = getWorkingCopy(
839
			"/Completion/src/test/IZZBException.java",
840
			"package test;"+
841
			"public class IZZBException extends Exception {\n" + 
842
			"}\n");
843
	
844
	this.workingCopies[3] = getWorkingCopy(
845
			"/Completion/src/test/IZZException.java",
846
			"package test;"+
847
			"public class IZZException extends Exception {\n" + 
848
			"}\n");
929
849
930
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
850
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
931
	String str = this.workingCopies[0].getSource();
851
	String str = this.workingCopies[0].getSource();
932
	String completeBehind = "bar";
852
	String completeBehind = "/**/";
933
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
853
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
934
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
854
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
935
855
936
	assertResults(
856
	assertResults(
937
			"bar[METHOD_REF]{bar(), Ltest.TestString;, ()V, bar, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
857
			"Test[TYPE_REF]{Test, test, Ltest.Test;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
858
			"Exception[TYPE_REF]{Exception, java.lang, Ljava.lang.Exception;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" +
859
			"IZZException[TYPE_REF]{IZZException, test, Ltest.IZZException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
938
			requestor.getResults());
860
			requestor.getResults());
939
}
861
}
940
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=144858
862
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
941
public void testDuplicateLocals5() throws JavaModelException {
863
public void testCatchClauseExceptionRef09() throws JavaModelException {
942
	this.workingCopies = new ICompilationUnit[2];
864
	this.workingCopies = new ICompilationUnit[5];
943
	this.workingCopies[0] = getWorkingCopy(
865
	this.workingCopies[0] = getWorkingCopy(
944
		"/Completion/src/test/Test.java",
866
		"/Completion/src/test/Test.java",
945
		"package test;"+
867
		"package test;"+
946
		"public class Test {\n" + 
868
		"public class Test {\n" + 
947
		"        public static void main(String[] args) {\n" + 
869
		"	public void throwing() throws IZZAException, IZZCException, IZZException {}\n" +
948
		"                for (int i = 0; i < 10; i++) {\n" + 
870
		"	public void foo() {\n" +
949
		"                        for (TestString i = null; ;)  {\n" + 
871
		"      try {\n" +
950
		"                                i.bar // do something\n" + 
872
		"         try {\n" +
951
		"                        }\n" + 
873
		"            throwing();\n" +
952
		"                }\n" + 
874
		"         }\n" +
953
		"        }\n" + 
875
		"         catch (IZZCException e) {\n" +
954
		"}");
876
		"            bar();\n" +
877
		"         }\n" +
878
		"      }\n" +
879
		"      catch (IZZAException e) {\n" +
880
		"         bar();\n" +
881
		"      }\n" +
882
		"      catch (IZZ) {\n" +
883
		"      }\n" +
884
		"   }" +
885
		"}\n");
955
	
886
	
956
	this.workingCopies[1] = getWorkingCopy(
887
	this.workingCopies[1] = getWorkingCopy(
957
		"/Completion/src/test/TestString.java",
888
			"/Completion/src/test/IZZAException.java",
958
		"package test;"+
889
			"package test;"+
959
		"public class TestString {\n" + 
890
			"public class IZZAException extends Exception {\n" + 
960
		"	public void bar() {\n" + 
891
			"}\n");
961
		"	}\n" + 
892
	
962
		"}");
893
	this.workingCopies[2] = getWorkingCopy(
894
			"/Completion/src/test/IZZBException.java",
895
			"package test;"+
896
			"public class IZZBException extends Exception {\n" + 
897
			"}\n");
898
	
899
	this.workingCopies[3] = getWorkingCopy(
900
			"/Completion/src/test/IZZCException.java",
901
			"package test;"+
902
			"public class IZZCException extends Exception {\n" + 
903
			"}\n");
904
	
905
	this.workingCopies[4] = getWorkingCopy(
906
			"/Completion/src/test/IZZException.java",
907
			"package test;"+
908
			"public class IZZException extends Exception {\n" + 
909
			"}\n");
963
910
964
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
911
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
965
	String str = this.workingCopies[0].getSource();
912
	String str = this.workingCopies[0].getSource();
966
	String completeBehind = "bar";
913
	String completeBehind = "IZZ";
967
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
914
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
968
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
915
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
969
916
970
	assertResults(
917
	assertResults(
971
			"bar[METHOD_REF]{bar(), Ltest.TestString;, ()V, bar, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
918
			"IZZBException[TYPE_REF]{IZZBException, test, Ltest.IZZBException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}\n" +
919
			"IZZCException[TYPE_REF]{IZZCException, test, Ltest.IZZCException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}\n" +
920
			"IZZException[TYPE_REF]{IZZException, test, Ltest.IZZException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
972
			requestor.getResults());
921
			requestor.getResults());
973
}
922
}
974
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=165662
923
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
975
public void testDuplicateLocalsType1() throws JavaModelException {
924
public void testCatchClauseExceptionRef10() throws JavaModelException {
976
	this.workingCopies = new ICompilationUnit[1];
925
	this.workingCopies = new ICompilationUnit[4];
977
	this.workingCopies[0] = getWorkingCopy(
926
	this.workingCopies[0] = getWorkingCopy(
978
		"/Completion/src/test/Test.java",
927
		"/Completion/src/test/Test.java",
979
		"package test;"+
928
		"package test;"+
980
		"public class Test {\n" + 
929
		"public class Test {\n" + 
981
		"  void foo() {\n" + 
930
		"	public void throwing() throws IZZAException, IZZException {}\n" +
982
		"     class Local {\n" + 
931
		"	public void foo() {\n" +
983
		"        void foo() {}\n" + 
932
		"      try {\n" +
984
		"     }\n" + 
933
		"         throwing();\n" +
985
		"     {\n" + 
934
		"      }\n" +
986
		"        class Local {\n" + 
935
		"      catch (IZZAException e) {\n" +
987
		"                Local(int i) {\n" + 
936
		"         bar();\n" +
988
		"                        this.init(i);\n" + 
937
		"      }\n" +
989
		"                }\n" + 
938
		"      catch (IZZ) {\n" +
990
		"				 void init(int i) {}\n" +
939
		"      }\n" +
991
		"                public void bar() {}\n" + 
940
		"   }" +
992
		"        }\n" + 
941
		"}\n");
993
		"        Local l = new Local(0);\n" + 
942
	
994
		"        l.bar\n" + 
943
	this.workingCopies[1] = getWorkingCopy(
995
		"     }\n" + 
944
			"/Completion/src/test/IZZAException.java",
996
		"  }\n" + 
945
			"package test;"+
997
		"}");
946
			"public class IZZAException extends Exception {\n" + 
947
			"}\n");
948
	
949
	this.workingCopies[2] = getWorkingCopy(
950
			"/Completion/src/test/IZZBException.java",
951
			"package test;"+
952
			"public class IZZBException extends Exception {\n" + 
953
			"}\n");
954
	
955
	this.workingCopies[3] = getWorkingCopy(
956
			"/Completion/src/test/IZZException.java",
957
			"package test;"+
958
			"public class IZZException extends IZZBException {\n" + 
959
			"}\n");
998
960
999
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
961
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1000
	String str = this.workingCopies[0].getSource();
962
	String str = this.workingCopies[0].getSource();
1001
	String completeBehind = "bar";
963
	String completeBehind = "IZZ";
1002
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
964
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1003
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
965
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1004
966
1005
	assertResults(
967
	assertResults(
1006
			"bar[METHOD_REF]{bar(), LLocal;, ()V, bar, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
968
			"IZZBException[TYPE_REF]{IZZBException, test, Ltest.IZZBException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" +
969
			"IZZException[TYPE_REF]{IZZException, test, Ltest.IZZException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
1007
			requestor.getResults());
970
			requestor.getResults());
1008
}
971
}
1009
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=165662
972
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
1010
public void testDuplicateLocalsType2() throws JavaModelException {
973
//IZZBException should not be proposed but to filter this proposal
1011
	this.workingCopies = new ICompilationUnit[1];
974
//we would need to know subclasses of IZZAException and it's currenlty too costly to compute
975
public void testCatchClauseExceptionRef11() throws JavaModelException {
976
	this.workingCopies = new ICompilationUnit[4];
1012
	this.workingCopies[0] = getWorkingCopy(
977
	this.workingCopies[0] = getWorkingCopy(
1013
		"/Completion/src/test/Test.java",
978
		"/Completion/src/test/Test.java",
1014
		"package test;"+
979
		"package test;"+
1015
		"public class Test {\n" + 
980
		"public class Test {\n" + 
1016
		"        void foo() {\n" + 
981
		"	public void throwing() throws IZZAException, IZZException {}\n" +
1017
		"                class Local {\n" + 
982
		"	public void foo() {\n" +
1018
		"                        void foo() {\n" + 
983
		"      try {\n" +
1019
		"                        }\n" + 
984
		"         throwing();\n" +
1020
		"                }\n" + 
985
		"      }\n" +
1021
		"                {\n" + 
986
		"      catch (IZZAException e) {\n" +
1022
		"                        class Local {\n" + 
987
		"         bar();\n" +
1023
		"                               Local(int i) {\n" + 
988
		"      }\n" +
1024
		"                                       this.init(i);\n" + 
989
		"      catch (IZZ) {\n" +
1025
		"                                       this.bar();\n" + 
990
		"      }\n" +
1026
		"                               }\n" + 
991
		"   }" +
1027
		"				 				void init(int i) {}\n" +
992
		"}\n");
1028
		"                        		void bar() {\n" + 
993
	
1029
		"                        		}\n" + 
994
	this.workingCopies[1] = getWorkingCopy(
1030
		"                        }\n" + 
995
			"/Completion/src/test/IZZAException.java",
1031
		"                        Local l = new Local(0);\n" + 
996
			"package test;"+
1032
		"                }\n" + 
997
			"public class IZZAException extends Exception {\n" + 
1033
		"                Local l = new Local();\n" + 
998
			"}\n");
1034
		"                l.foo\n" + 
999
	
1035
		"        }\n" + 
1000
	this.workingCopies[2] = getWorkingCopy(
1036
		"}");
1001
			"/Completion/src/test/IZZBException.java",
1002
			"package test;"+
1003
			"public class IZZBException extends IZZAException {\n" + 
1004
			"}\n");
1005
	
1006
	this.workingCopies[3] = getWorkingCopy(
1007
			"/Completion/src/test/IZZException.java",
1008
			"package test;"+
1009
			"public class IZZException extends Exception {\n" + 
1010
			"}\n");
1037
1011
1038
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1012
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1039
	String str = this.workingCopies[0].getSource();
1013
	String str = this.workingCopies[0].getSource();
1040
	String completeBehind = "foo";
1014
	String completeBehind = "IZZ";
1041
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1015
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1042
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1016
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1043
1017
1044
	assertResults(
1018
	assertResults(
1045
			"foo[METHOD_REF]{foo(), LLocal;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
1019
			"IZZBException[TYPE_REF]{IZZBException, test, Ltest.IZZBException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}\n" +
1020
			"IZZException[TYPE_REF]{IZZException, test, Ltest.IZZException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
1046
			requestor.getResults());
1021
			requestor.getResults());
1047
}
1022
}
1048
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=139937
1023
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
1049
public void testEvaluationContextCompletion() throws JavaModelException {
1024
public void testCatchClauseExceptionRef12() throws JavaModelException {
1050
	class EvaluationContextCompletionRequestor extends CompletionRequestor {
1025
	this.workingCopies = new ICompilationUnit[4];
1051
		public boolean acceptContext;
1052
		public void acceptContext(CompletionContext context) {
1053
			this.acceptContext = context != null;
1054
		}
1055
		public void accept(CompletionProposal proposal) {
1056
			// Do nothing
1057
		}
1058
	}
1059
	String start = "";
1060
	IJavaProject javaProject = getJavaProject("Completion");
1061
	IEvaluationContext context = javaProject.newEvaluationContext();
1062
    EvaluationContextCompletionRequestor rc = new EvaluationContextCompletionRequestor();
1063
	context.codeComplete(start, start.length(), rc);
1064
	
1065
	assertTrue("acceptContext() method isn't call", rc.acceptContext);
1066
}
1067
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140123
1068
public void testEvaluationContextCompletion2() throws JavaModelException {
1069
	class EvaluationContextCompletionRequestor extends CompletionRequestor {
1070
		public boolean acceptContext;
1071
		public boolean beginReporting;
1072
		public boolean endReporting;
1073
		
1074
		public void acceptContext(CompletionContext context) {
1075
			this.acceptContext = context != null;
1076
		}
1077
		public void accept(CompletionProposal proposal) {
1078
			// Do nothing
1079
		}
1080
		
1081
		public void beginReporting() {
1082
			this.beginReporting = true;
1083
			super.beginReporting();
1084
		}
1085
		
1086
		public void endReporting() {
1087
			this.endReporting =  true;
1088
			super.endReporting();
1089
		}
1090
	}
1091
	String start = "";
1092
	IJavaProject javaProject = getJavaProject("Completion");
1093
	IEvaluationContext context = javaProject.newEvaluationContext();
1094
    EvaluationContextCompletionRequestor rc = new EvaluationContextCompletionRequestor();
1095
	context.codeComplete(start, start.length(), rc);
1096
	
1097
	assertTrue("acceptContext() method isn't call", rc.acceptContext);
1098
	assertTrue("beginReporting() method isn't call", rc.beginReporting);
1099
	assertTrue("endReporting() method isn't call", rc.endReporting);
1100
}
1101
1102
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140123
1103
public void testEvaluationContextCompletion3() throws JavaModelException {
1104
	this.workingCopies = new ICompilationUnit[1];
1105
	this.workingCopies[0] = getWorkingCopy(
1026
	this.workingCopies[0] = getWorkingCopy(
1106
		"/Completion/src/test/TestEvaluationContextCompletion3.java",
1027
		"/Completion/src/test/Test.java",
1107
		"package test;"+
1028
		"package test;"+
1108
		"public class TestEvaluationContextCompletion3 {\n"+
1029
		"public class Test {\n" + 
1109
		"}");
1030
		"	public void throwing() throws IZZAException, IZZException {}\n" +
1110
	
1031
		"	public void foo() {\n" +
1111
	String start = "TestEvaluationContextCompletion3";
1032
		"      try {\n" +
1112
	IJavaProject javaProject = getJavaProject("Completion");
1033
		"         throwing();\n" +
1113
	IEvaluationContext context = javaProject.newEvaluationContext();
1034
		"      }\n" +
1035
		"      catch (IZZ) {\n" +
1036
		"      }\n" +
1037
		"   }" +
1038
		"}\n");
1114
	
1039
	
1115
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, false);
1040
	this.workingCopies[1] = getWorkingCopy(
1116
	context.codeComplete(start, start.length(), requestor, this.wcOwner);
1041
			"/Completion/src/test/IZZAException.java",
1042
			"package test;"+
1043
			"public class IZZAException extends Exception {\n" + 
1044
			"}\n");
1117
	
1045
	
1118
	int startOffset = 0;
1046
	this.workingCopies[2] = getWorkingCopy(
1119
	int endOffset = start.length();
1047
			"/Completion/src/test/IZZBException.java",
1048
			"package test;"+
1049
			"public class IZZBException extends Exception {\n" + 
1050
			"}\n");
1120
	
1051
	
1052
	this.workingCopies[3] = getWorkingCopy(
1053
			"/Completion/src/test/IZZException.java",
1054
			"package test;"+
1055
			"public class IZZException extends Exception {\n" + 
1056
			"}\n");
1057
1058
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1059
	String str = this.workingCopies[0].getSource();
1060
	String completeBehind = "IZZ";
1061
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1062
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1063
1121
	assertResults(
1064
	assertResults(
1122
			"completion offset="+endOffset+"\n"+
1065
			"IZZBException[TYPE_REF]{IZZBException, test, Ltest.IZZBException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}\n" +
1123
			"completion range=["+startOffset+", "+(endOffset-1)+"]\n"+
1066
			"IZZAException[TYPE_REF]{IZZAException, test, Ltest.IZZAException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" +
1124
			"completion token=\"TestEvaluationContextCompletion3\"\n"+
1067
			"IZZException[TYPE_REF]{IZZException, test, Ltest.IZZException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
1125
			"completion token kind=TOKEN_KIND_NAME\n"+
1126
			"expectedTypesSignatures=null\n"+
1127
			"expectedTypesKeys=null",
1128
            requestor.getContext());
1129
    
1130
	assertResults(
1131
			"TestEvaluationContextCompletion3[TYPE_REF]{test.TestEvaluationContextCompletion3, test, Ltest.TestEvaluationContextCompletion3;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
1132
			requestor.getResults());
1068
			requestor.getResults());
1133
}
1069
}
1134
1070
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
1135
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140123
1071
public void testCatchClauseExceptionRef13() throws JavaModelException {
1136
public void testEvaluationContextCompletion4() throws JavaModelException {
1072
	this.workingCopies = new ICompilationUnit[4];
1137
	this.workingCopies = new ICompilationUnit[1];
1138
	this.workingCopies[0] = getWorkingCopy(
1073
	this.workingCopies[0] = getWorkingCopy(
1139
		"/Completion/src/test/TestEvaluationContextCompletion4.java",
1074
		"/Completion/src/test/Test.java",
1140
		"package test;"+
1075
		"package test;"+
1141
		"public class TestEvaluationContextCompletion4 {\n"+
1076
		"public class Test {\n" + 
1142
		"}");
1077
		"	public void throwing() throws IZZException {}\n" +
1143
	
1078
		"	public void foo() {\n" +
1144
	String start = "TestEvaluationContextCompletion4";
1079
		"      try {\n" +
1145
	IJavaProject javaProject = getJavaProject("Completion");
1080
		"         throwing();\n" +
1146
	IEvaluationContext context = javaProject.newEvaluationContext();
1081
		"      }\n" +
1082
		"      catch (IZZAException e) {\n" +
1083
		"      }\n" +
1084
		"      catch (IZZ) {\n" +
1085
		"      }\n" +
1086
		"   }" +
1087
		"}\n");
1147
	
1088
	
1148
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, false);
1089
	this.workingCopies[1] = getWorkingCopy(
1149
	requestor.setIgnored(CompletionProposal.TYPE_REF, true);
1090
			"/Completion/src/test/IZZAException.java",
1150
	context.codeComplete(start, start.length(), requestor, this.wcOwner);
1091
			"package test;"+
1092
			"public class IZZAException extends Exception {\n" + 
1093
			"}\n");
1151
	
1094
	
1152
	int startOffset = 0;
1095
	this.workingCopies[2] = getWorkingCopy(
1153
	int endOffset = start.length();
1096
			"/Completion/src/test/IZZBException.java",
1097
			"package test;"+
1098
			"public class IZZBException extends Exception {\n" + 
1099
			"}\n");
1154
	
1100
	
1155
	assertResults(
1101
	this.workingCopies[3] = getWorkingCopy(
1156
			"completion offset="+endOffset+"\n"+
1102
			"/Completion/src/test/IZZException.java",
1157
			"completion range=["+startOffset+", "+(endOffset-1)+"]\n"+
1103
			"package test;"+
1158
			"completion token=\"TestEvaluationContextCompletion4\"\n"+
1104
			"public class IZZException extends IZZAException {\n" + 
1159
			"completion token kind=TOKEN_KIND_NAME\n"+
1105
			"}\n");
1160
			"expectedTypesSignatures=null\n"+
1106
1161
			"expectedTypesKeys=null",
1107
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1162
            requestor.getContext());
1108
	String str = this.workingCopies[0].getSource();
1163
    
1109
	String completeBehind = "IZZ";
1164
	assertResults(
1110
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1165
			"",
1111
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1166
			requestor.getResults());
1167
}
1168
1112
1169
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=141518
1170
public void testEvaluationContextCompletion5() throws JavaModelException {
1171
	this.workingCopies = new ICompilationUnit[1];
1172
	this.workingCopies[0] = getWorkingCopy(
1173
		"/Completion/src/test/TestEvaluationContextCompletion5.java",
1174
		"package test;"+
1175
		"public class TestEvaluationContextCompletion5 {\n"+
1176
		"}");
1177
	
1178
	String start = "someVariable.to";
1179
	IJavaProject javaProject = getJavaProject("Completion");
1180
	IEvaluationContext context = javaProject.newEvaluationContext();
1181
	
1182
	context.newVariable( "Object", "someVariable", null );
1183
	
1184
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, false);
1185
	context.codeComplete(start, start.length(), requestor, this.wcOwner);
1186
	
1187
	int startOffset = start.length() - 2;
1188
	int endOffset = startOffset + 2 ;
1189
	
1190
	assertResults(
1191
			"completion offset="+endOffset+"\n"+
1192
			"completion range=["+startOffset+", "+(endOffset-1)+"]\n"+
1193
			"completion token=\"to\"\n"+
1194
			"completion token kind=TOKEN_KIND_NAME\n"+
1195
			"expectedTypesSignatures=null\n"+
1196
			"expectedTypesKeys=null",
1197
            requestor.getContext());
1198
    
1199
	assertResults(
1113
	assertResults(
1200
			"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + 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) + "}",
1201
			requestor.getResults());
1115
			requestor.getResults());
1202
}
1116
}
1203
1117
/*
1204
/**
1118
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=65737
1205
 * Ensures that completion is not case sensitive
1206
 */
1207
public void testCompletionCaseInsensitive() throws JavaModelException {
1208
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1209
	ICompilationUnit cu = getCompilationUnit("Completion", "src", "", "CompletionCaseInsensitive.java");
1210
	
1211
	String str = cu.getSource();
1212
	String completeBehind = "Fiel";
1213
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1214
	cu.codeComplete(cursorLocation, requestor);
1215
	
1216
	assertEquals("should have one class",
1217
		"element:field    completion:field    relevance:"+(R_DEFAULT + R_INTERESTING + R_NON_STATIC + R_NON_RESTRICTED),
1218
		requestor.getResults());
1219
}
1220
/**
1221
 * Complete a package in a case insensitive way
1222
 */
1119
 */
1223
public void testCompletionCaseInsensitivePackage() throws JavaModelException {
1120
public void testCompletion2InterfacesWithSameMethod() throws JavaModelException {
1224
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1121
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1225
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionCaseInsensitivePackage.java");
1122
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "Completion2InterfacesWithSameMethod.java");
1226
1123
1227
	String str = cu.getSource();
1124
	String str = cu.getSource();
1228
	String completeBehind = "Ja";
1125
	String completeBehind = "var.meth";
1229
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
1126
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
1230
	
1231
	cu.codeComplete(cursorLocation, requestor);
1127
	cu.codeComplete(cursorLocation, requestor);
1232
	assertEquals(
1233
		"should have package completions",
1234
		"element:jarpack1    completion:jarpack1    relevance:"+(R_DEFAULT + R_INTERESTING+ R_NON_RESTRICTED)+"\n" +
1235
		"element:jarpack2    completion:jarpack2    relevance:"+(R_DEFAULT + R_INTERESTING+ R_NON_RESTRICTED)+"\n" +
1236
		"element:java    completion:java    relevance:"+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"\n" +
1237
		"element:java.io    completion:java.io    relevance:"+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"\n" +
1238
		"element:java.lang    completion:java.lang    relevance:"+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED),
1239
		requestor.getResults());
1240
}
1241
1128
1242
/**
1243
 * Complete at end of file.
1244
 */
1245
public void testCompletionEndOfCompilationUnit() throws JavaModelException {
1246
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1247
	ICompilationUnit cu = getCompilationUnit("Completion", "src", "", "CompletionEndOfCompilationUnit.java");
1248
	cu.codeComplete(cu.getSourceRange().getOffset() + cu.getSourceRange().getLength(), requestor);
1249
	assertEquals(
1129
	assertEquals(
1250
		"should have two methods of 'foo'", 
1130
			"element:method    completion:method()    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
1251
		"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
1131
			requestor.getResults());
1252
		"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED),
1253
		requestor.getResults());	
1254
}
1132
}
1255
1133
public void testCompletionAbstractMethod1() throws JavaModelException {
1256
/**
1257
 * Complete the type "A" from "new A".
1258
 */
1259
public void testCompletionFindClass() throws JavaModelException {
1260
	this.wc = getWorkingCopy(
1134
	this.wc = getWorkingCopy(
1261
            "/Completion/src/CompletionFindClass.java",
1135
            "/Completion/src/CompletionAbstractMethod1.java",
1262
            "public class CompletionFindClass {\n" +
1136
            "public class CompletionAbstractMethod1 {\n" +
1263
            "	private    A[] a;\n" +
1137
            "	abstract class A {\n" +
1264
            "	public CompletionFindClass () {\n" +
1138
            "		abstract void foo();\n" +
1265
            "		this.a = new A\n" +
1139
            "	}\n" +
1140
            "	class B extends A {\n" +
1141
            "		void foo{} {}\n" +
1142
            "		void bar() {\n" +
1143
            "			super.fo\n" +
1144
            "		}\n" +
1266
            "	}\n" +
1145
            "	}\n" +
1267
            "}");
1146
            "}");
1268
    
1147
    
1269
    
1148
    
1270
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1149
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1271
    String str = this.wc.getSource();
1150
    String str = this.wc.getSource();
1272
    String completeBehind = "A";
1151
    String completeBehind = "fo";
1273
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1152
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1274
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1153
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1275
1154
1276
    assertResults(
1155
    assertResults(
1277
    		"ABC[TYPE_REF]{p1.ABC, p1, Lp1.ABC;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1156
            "",
1278
    		"ABC[TYPE_REF]{p2.ABC, p2, Lp2.ABC;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1279
			"A3[TYPE_REF]{A3, , LA3;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1280
			"A[TYPE_REF]{A, , LA;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1281
            requestor.getResults());
1157
            requestor.getResults());
1282
}
1158
}
1283
1159
public void testCompletionAbstractMethod2() throws JavaModelException {
1284
/**
1285
 * The same type must be find only once
1286
 */
1287
public void testCompletionFindClass2() throws JavaModelException {
1288
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1289
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindClass2.java");
1290
1291
	String str = cu.getSource();
1292
	String completeBehind = "PX";
1293
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
1294
	cu.codeComplete(cursorLocation, requestor);
1295
1296
	assertEquals(
1297
		"should have one classe", 
1298
		"element:PX    completion:pack1.PX    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_QUALIFIED + R_NON_RESTRICTED),
1299
		requestor.getResults());
1300
}
1301
1302
1303
/**
1304
 * Complete the type "Default" in the default package example.
1305
 */
1306
public void testCompletionFindClassDefaultPackage() throws JavaModelException {
1307
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1308
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionDefaultPackage.java");
1309
1310
	String str = cu.getSource();
1311
	String completeBehind = "Def";
1312
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1313
	cu.codeComplete(cursorLocation, requestor);
1314
1315
	assertEquals(
1316
		"should have one class", 
1317
		"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
1318
		requestor.getResults());	
1319
}
1320
1321
/**
1322
 * Complete the constructor "CompletionFindConstructor" from "new CompletionFindConstructor(".
1323
 */
1324
public void testCompletionFindConstructor() throws JavaModelException {
1325
	this.wc = getWorkingCopy(
1160
	this.wc = getWorkingCopy(
1326
            "/Completion/src/CompletionFindConstructor.java",
1161
            "/Completion/src/CompletionAbstractMethod2.java",
1327
            "public class CompletionFindConstructor {\n"+
1162
            "public class CompletionAbstractMethod2 {\n" +
1328
            "	public CompletionFindConstructor (int i) {\n"+
1163
            "	abstract class A {\n" +
1329
            "	}\n"+
1164
            "		abstract void foo();\n" +
1330
            "	publuc void foo(){\n"+
1165
            "	}\n" +
1331
            "		int x = 45;\n"+
1166
            "	class B extends A {\n" +
1332
            "		new CompletionFindConstructor(i);\n"+
1167
            "		void foo{} {}\n" +
1333
            "	}\n"+
1168
            "		void bar() {\n" +
1169
            "			this.fo\n" +
1170
            "		}\n" +
1171
            "	}\n" +
1334
            "}");
1172
            "}");
1335
    
1173
    
1336
    
1174
    
1337
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1175
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1338
    
1339
    String str = this.wc.getSource();
1176
    String str = this.wc.getSource();
1340
    String completeBehind = "CompletionFindConstructor(";
1177
    String completeBehind = "fo";
1341
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1178
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1342
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1179
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1343
1180
1344
    assertResults(
1181
    assertResults(
1345
            "expectedTypesSignatures=null\n"+
1182
           "foo[METHOD_REF]{foo(), LCompletionAbstractMethod2$A;, ()V, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED) + "}",
1346
            "expectedTypesKeys=null",
1183
           requestor.getResults());
1347
            requestor.getContext());
1348
    
1349
   assertResults(
1350
			"CompletionFindConstructor[ANONYMOUS_CLASS_DECLARATION]{, LCompletionFindConstructor;, (I)V, null, (i), "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n" +
1351
			"CompletionFindConstructor[METHOD_REF<CONSTRUCTOR>]{, LCompletionFindConstructor;, (I)V, CompletionFindConstructor, (i), "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}",
1352
			requestor.getResults());
1353
}
1184
}
1354
1185
public void testCompletionAbstractMethod3() throws JavaModelException {
1355
/**
1356
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78801
1357
 */
1358
public void testCompletionFindConstructor2() throws JavaModelException {
1359
	this.wc = getWorkingCopy(
1186
	this.wc = getWorkingCopy(
1360
            "/Completion/src/CompletionFindConstructor2.java",
1187
            "/Completion/src/CompletionAbstractMethod3.java",
1361
            "import zconstructors.*;\n"+
1188
            "public class CompletionAbstractMethod3 {\n" +
1362
            "public class CompletionFindConstructor2 {\n"+
1189
            "	abstract class A {\n" +
1363
            "	Constructor2 c = new Constructor2();\n"+
1190
            "		abstract void foo();\n" +
1191
            "	}\n" +
1192
            "	class B extends A {\n" +
1193
            "		void bar() {\n" +
1194
            "			this.fo\n" +
1195
            "		}\n" +
1196
            "	}\n" +
1364
            "}");
1197
            "}");
1365
    
1198
    
1366
    
1199
    
1367
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1200
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1368
    
1369
    String str = this.wc.getSource();
1201
    String str = this.wc.getSource();
1370
    String completeBehind = "Constructor2(";
1202
    String completeBehind = "fo";
1371
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1203
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1372
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1204
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1373
1205
1374
    assertResults(
1206
    assertResults(
1375
            "expectedTypesSignatures=null\n"+
1207
           "foo[METHOD_REF]{foo(), LCompletionAbstractMethod3$A;, ()V, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED)+"}",
1376
            "expectedTypesKeys=null",
1208
           requestor.getResults());
1377
            requestor.getContext());
1378
    
1379
    assertEquals(
1380
			"Constructor2[ANONYMOUS_CLASS_DECLARATION]{, Lzconstructors.Constructor2;, ()V, null, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
1381
			"Constructor2[METHOD_REF<CONSTRUCTOR>]{, Lzconstructors.Constructor2;, ()V, Constructor2, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}",
1382
			requestor.getResults());
1383
}
1209
}
1384
1210
public void testCompletionAbstractMethod4() throws JavaModelException {
1385
/**
1386
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78801
1387
 */
1388
public void testCompletionFindConstructor3() throws JavaModelException {
1389
	this.wc = getWorkingCopy(
1211
	this.wc = getWorkingCopy(
1390
            "/Completion/src/CompletionFindConstructor3.java",
1212
            "/Completion/src/CompletionAbstractMethod4.java",
1391
            "import zconstructors.*;\n"+
1213
            "public class CompletionAbstractMethod1 {\n" +
1392
            "public class CompletionFindConstructor3 {\n"+
1214
            "	class A {\n" +
1393
            "	Constructor3 c = new Constructor3();\n"+
1215
            "		void foo(){}\n" +
1216
            "	}\n" +
1217
            "	abstract class B extends A {\n" +
1218
            "		abstract void foo();\n" +
1219
            "	}\n" +
1220
            "	class C extends B {\n" +
1221
            "		void foo{} {}\n" +
1222
            "		void bar() {\n" +
1223
            "			super.fo\n" +
1224
            "		}\n" +
1225
            "	}\n" +
1394
            "}");
1226
            "}");
1395
    
1227
    
1396
    
1228
    
1397
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1229
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1398
    
1399
    String str = this.wc.getSource();
1230
    String str = this.wc.getSource();
1400
    String completeBehind = "Constructor3(";
1231
    String completeBehind = "fo";
1401
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1232
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1402
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1233
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1403
1234
1404
    assertResults(
1235
    assertResults(
1405
            "expectedTypesSignatures=null\n"+
1236
           "",
1406
            "expectedTypesKeys=null",
1237
           requestor.getResults());
1407
            requestor.getContext());
1408
    
1409
    assertEquals(
1410
			"Constructor3[ANONYMOUS_CLASS_DECLARATION]{, Lzconstructors.Constructor3;, ()V, null, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
1411
			"Constructor3[METHOD_REF<CONSTRUCTOR>]{, Lzconstructors.Constructor3;, ()V, Constructor3, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}",
1412
			requestor.getResults());
1413
}
1238
}
1414
/**
1415
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78801
1416
 */
1417
public void testCompletionFindConstructor4() throws JavaModelException {
1418
	this.wc = getWorkingCopy(
1419
            "/Completion/src/CompletionFindConstructor4.java",
1420
            "import zconstructors.*;\n"+
1421
            "public class CompletionFindConstructor4 {\n"+
1422
            "	Constructor4 c = new Constructor4();\n"+
1423
            "}");
1424
    
1425
    
1426
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1427
    
1428
    String str = this.wc.getSource();
1429
    String completeBehind = "Constructor4(";
1430
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1431
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1432
1239
1433
    assertResults(
1240
/*
1434
            "expectedTypesSignatures=null\n"+
1241
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25578
1435
            "expectedTypesKeys=null",
1242
*/
1436
            requestor.getContext());
1243
public void testCompletionAbstractMethodRelevance1() throws JavaModelException {
1437
    
1244
	ICompilationUnit superClass = null;
1438
	assertEquals(
1245
	try {
1439
			"Constructor4[ANONYMOUS_CLASS_DECLARATION]{, Lzconstructors.Constructor4;, (I)V, null, (i), " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
1246
		superClass = getWorkingCopy(
1440
			"Constructor4[METHOD_REF<CONSTRUCTOR>]{, Lzconstructors.Constructor4;, (I)V, Constructor4, (i), " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}",
1247
	            "/Completion/src/CompletionAbstractSuperClass.java",
1248
	            "public abstract class CompletionAbstractSuperClass {\n"+
1249
	            "	public void foo1(){}\n"+
1250
	            "	public abstract void foo2();\n"+
1251
	            "	public void foo3(){}\n"+
1252
	            "}");
1253
		
1254
		this.wc = getWorkingCopy(
1255
	            "/Completion/src/CompletionAbstractMethodRelevance1.java",
1256
	            "public class CompletionAbstractMethodRelevance1 extends CompletionAbstractSuperClass {\n"+
1257
	            "	foo\n"+
1258
	            "}");
1259
	    
1260
	    
1261
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1262
	    String str = this.wc.getSource();
1263
	    String completeBehind = "foo";
1264
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1265
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1266
	
1267
		assertResults(
1268
			"foo[POTENTIAL_METHOD_DECLARATION]{foo, LCompletionAbstractMethodRelevance1;, ()V, foo, null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n" +
1269
			"foo1[METHOD_DECLARATION]{public void foo1(), LCompletionAbstractSuperClass;, ()V, foo1, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n" +
1270
			"foo3[METHOD_DECLARATION]{public void foo3(), LCompletionAbstractSuperClass;, ()V, foo3, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n" +
1271
			"foo2[METHOD_DECLARATION]{public void foo2(), LCompletionAbstractSuperClass;, ()V, foo2, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_ABSTRACT_METHOD + R_METHOD_OVERIDE+ R_NON_RESTRICTED)+"}",
1441
			requestor.getResults());
1272
			requestor.getResults());
1273
	} finally {
1274
		if(superClass != null) {
1275
			superClass.discardWorkingCopy();
1276
		}
1277
	}
1442
}
1278
}
1443
/**
1279
/*
1444
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78801
1280
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25578
1445
 */
1281
*/
1446
public void testCompletionFindConstructor5() throws JavaModelException {
1282
public void testCompletionAbstractMethodRelevance2() throws JavaModelException {
1447
	this.wc = getWorkingCopy(
1283
	ICompilationUnit superClass = null;
1448
            "/Completion/src/CompletionFindConstructor5.java",
1284
	try {
1449
            "import zconstructors.*;\n"+
1285
		superClass = getWorkingCopy(
1450
            "public class CompletionFindConstructor5 {\n"+
1286
	            "/Completion/src/CompletionSuperInterface.java",
1451
            "	Constructor5 c = new Constructor5();\n"+
1287
	            "public interface CompletionSuperInterface{\n"+
1452
            "}");
1288
	            "	public int eqFoo(int a,Object b);\n"+
1453
    
1289
	            "}");
1454
    
1290
		
1455
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1291
		this.wc = getWorkingCopy(
1456
    
1292
	            "/Completion/src/CompletionAbstractMethodRelevance2.java",
1457
    String str = this.wc.getSource();
1293
	            "public class CompletionAbstractMethodRelevance2 implements CompletionSuperInterface {\n"+
1458
    String completeBehind = "Constructor5(";
1294
	            "	eq\n"+
1459
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1295
	            "}");
1460
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1296
	    
1297
	    
1298
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1299
	    String str = this.wc.getSource();
1300
	    String completeBehind = "eq";
1301
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1302
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1303
	
1304
		assertResults(
1305
			"eq[POTENTIAL_METHOD_DECLARATION]{eq, LCompletionAbstractMethodRelevance2;, ()V, eq, null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n" +
1306
			"equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n" +
1307
			"eqFoo[METHOD_DECLARATION]{public int eqFoo(int a, Object b), LCompletionSuperInterface;, (ILjava.lang.Object;)I, eqFoo, (a, b), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_ABSTRACT_METHOD + R_METHOD_OVERIDE+ R_NON_RESTRICTED)+"}",
1308
			requestor.getResults());
1309
	} finally {
1310
		if(superClass != null) {
1311
			superClass.discardWorkingCopy();
1312
		}
1313
	}
1314
}
1315
public void testCompletionAfterCase1() throws JavaModelException {
1316
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1317
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAfterCase1.java");
1461
1318
1462
    assertResults(
1319
		String str = cu.getSource();
1463
            "expectedTypesSignatures=null\n"+
1320
		String completeBehind = "zz";
1464
            "expectedTypesKeys=null",
1321
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1465
            requestor.getContext());
1322
		cu.codeComplete(cursorLocation, requestor);
1466
    
1323
1467
	assertEquals(
1324
		assertEquals(
1468
			"Constructor5[ANONYMOUS_CLASS_DECLARATION]{, Lzconstructors.Constructor5;, (I)V, null, (arg0), " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
1325
			"element:zzz    completion:zzz    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
1469
			"Constructor5[METHOD_REF<CONSTRUCTOR>]{, Lzconstructors.Constructor5;, (I)V, Constructor5, (arg0), " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}",
1470
			requestor.getResults());
1326
			requestor.getResults());
1471
}
1327
}
1472
/**
1328
public void testCompletionAfterCase2() throws JavaModelException {
1473
 * Complete the exception "Exception" in a catch clause.
1474
 */
1475
public void testCompletionFindExceptions1() throws JavaModelException {
1476
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1329
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1477
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindException1.java");
1330
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAfterCase2.java");
1478
1331
1479
	String str = cu.getSource();
1332
		String str = cu.getSource();
1480
	String completeBehind = "Ex";
1333
		String completeBehind = "zz";
1481
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1334
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1482
	cu.codeComplete(cursorLocation, requestor);
1335
		cu.codeComplete(cursorLocation, requestor);
1483
	
1484
	assertEquals(
1485
		"should have one class", 
1486
		"element:Exception    completion:Exception    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXCEPTION + R_UNQUALIFIED + R_NON_RESTRICTED),
1487
		requestor.getResults());
1488
}
1489
1336
1490
/**
1337
		assertEquals(
1491
 * Complete the exception "Exception" in a throws clause.
1338
			"element:zzz    completion:zzz    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
1492
 */
1339
			requestor.getResults());
1493
public void testCompletionFindExceptions2() throws JavaModelException {
1340
}
1494
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1341
public void testCompletionAfterSupercall1() throws JavaModelException {
1495
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindException2.java");
1342
	this.workingCopies = new ICompilationUnit[1];
1343
	this.workingCopies[0] = getWorkingCopy(
1344
		"/Completion/src/CompletionAfterSupercall1.java",
1345
		"public class CompletionAfterSupercall1 extends CompletionAfterSupercall1_1 {\n" +
1346
		"	public void foo(){\n" +
1347
		"		super.foo\n" +
1348
		"	}\n" +
1349
		"}\n" +
1350
		"abstract class CompletionAfterSupercall1_1 extends CompletionAfterSupercall1_2 implements CompletionAfterSupercall1_3 {\n" +
1351
		"	\n" +
1352
		"}\n" +
1353
		"class CompletionAfterSupercall1_2 implements CompletionAfterSupercall1_3 {\n" +
1354
		"	public void foo(){}\n" +
1355
		"}\n" +
1356
		"interface CompletionAfterSupercall1_3 {\n" +
1357
		"	public void foo();\n" +
1358
		"}");
1496
1359
1497
	String str = cu.getSource();
1360
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1498
	String completeBehind = "Ex";
1361
	String str = this.workingCopies[0].getSource();
1362
	String completeBehind = "super.foo";
1499
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1363
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1500
	cu.codeComplete(cursorLocation, requestor);
1364
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
1501
1365
1502
	assertEquals(
1366
	assertResults(
1503
		"should have one class",
1367
			"foo[METHOD_REF]{foo(), LCompletionAfterSupercall1_2;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC+ R_NON_RESTRICTED) + "}",
1504
		"element:Exception    completion:Exception    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXCEPTION + R_UNQUALIFIED + R_NON_RESTRICTED),
1368
			requestor.getResults());
1505
		requestor.getResults());
1506
}
1369
}
1507
1370
public void testCompletionAfterSwitch() throws JavaModelException {
1508
/**
1509
 * Complete the field "var" from "va";
1510
 */
1511
public void testCompletionFindField1() throws JavaModelException {
1512
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1371
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1513
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindField1.java");
1372
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAfterSwitch.java");
1514
1373
1515
	String str = cu.getSource();
1374
	String str = cu.getSource();
1516
	String completeBehind = "va";
1375
	String completeBehind = "bar";
1517
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1376
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
1518
	cu.codeComplete(cursorLocation, requestor);
1377
	cu.codeComplete(cursorLocation, requestor);
1519
	
1378
1520
	assertEquals(
1379
	assertEquals(
1521
		"should have one field: 'var' and one variable: 'var'", 
1380
			"element:bar    completion:bar()    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_NAME+ R_NON_RESTRICTED),
1522
		"element:var    completion:this.var    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n"+
1381
			requestor.getResults());
1523
		"element:var    completion:var    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED),
1524
		requestor.getResults());	
1525
}
1526
1527
/**
1528
 * Complete the field "var" from "this.va";
1529
 */
1530
public void testCompletionFindField2() throws JavaModelException {
1531
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1532
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindField2.java");
1533
1534
	String str = cu.getSource();
1535
	String completeBehind = "va";
1536
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1537
	cu.codeComplete(cursorLocation, requestor);
1538
	
1539
	assertEquals(
1540
		"should have 1 field of starting with 'va'",
1541
		"element:var    completion:var    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED),
1542
		requestor.getResults());
1543
}
1544
1545
public void testCompletionFindField3() throws JavaModelException {
1546
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1547
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindField3.java");
1548
1549
	String str = cu.getSource();
1550
	String completeBehind = "b.ba";
1551
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1552
	cu.codeComplete(cursorLocation, requestor);
1553
1554
	assertEquals(
1555
		"element:bar    completion:bar    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED),
1556
		requestor.getResults());
1557
}
1382
}
1558
1383
public void testCompletionAllMemberTypes() throws JavaModelException {
1559
/**
1384
    this.wc = getWorkingCopy(
1560
 * Complete the import, "import pac"
1385
            "/Completion/src/test/CompletionAllMemberTypes.java",
1561
 */
1386
            "package test;\n" +
1562
public void testCompletionFindImport1() throws JavaModelException {
1387
            "public class CompletionAllMemberTypes {\n" +
1563
	this.wc = getWorkingCopy(
1388
            "  class Member1 {\n" +
1564
            "/Completion/src/CompletionFindImport1.java",
1389
            "    class Member2 {\n" +
1565
            "import pac\n"+
1390
            "      class Member3 {\n" +
1566
            "\n"+
1391
            "      }\n" +
1567
            "public class CompletionFindImport1 {\n"+
1392
            "    }\n" +
1568
            "\n"+
1393
            "    void foo(){\n" +
1394
            "      Member\n" +
1395
            "    }\n" +
1396
            "  \n}" +
1569
            "}");
1397
            "}");
1570
    
1398
    
1571
    
1399
    
1572
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1400
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1573
    String str = this.wc.getSource();
1401
    String str = this.wc.getSource();
1574
    String completeBehind = "pac";
1402
    String completeBehind = "Member";
1575
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1403
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1576
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1404
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1577
    
1405
1578
	assertResults(
1406
	assertResults(
1579
			"pack[PACKAGE_REF]{pack.*;, pack, null, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
1407
            "CompletionAllMemberTypes.Member1.Member2.Member3[TYPE_REF]{test.CompletionAllMemberTypes.Member1.Member2.Member3, test, Ltest.CompletionAllMemberTypes$Member1$Member2$Member3;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1580
			"pack1[PACKAGE_REF]{pack1.*;, pack1, null, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
1408
			"CompletionAllMemberTypes.Member1[TYPE_REF]{Member1, test, Ltest.CompletionAllMemberTypes$Member1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
1581
			"pack1.pack3[PACKAGE_REF]{pack1.pack3.*;, pack1.pack3, null, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
1409
			"CompletionAllMemberTypes.Member1.Member2[TYPE_REF]{Member2, test, Ltest.CompletionAllMemberTypes$Member1$Member2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
1582
			"pack2[PACKAGE_REF]{pack2.*;, pack2, null, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}",
1410
            requestor.getResults());
1583
			requestor.getResults());
1584
}
1411
}
1585
1412
public void testCompletionAllMemberTypes2() throws JavaModelException {
1586
public void testCompletionFindImport2() throws JavaModelException {
1413
    this.wc = getWorkingCopy(
1587
	this.wc = getWorkingCopy(
1414
            "/Completion/src/test/CompletionAllMemberTypes2.java",
1588
            "/Completion/src/CompletionFindImport2.java",
1415
            "package test;\n" +
1589
            "import pack1.P\n"+
1416
            "public class CompletionAllMemberTypes2 {\n" +
1590
            "\n"+
1417
            "  class Member1 {\n" +
1591
            "public class CompletionFindImport2 {\n"+
1418
            "    class Member5 {\n" +
1592
            "\n"+
1419
            "      class Member6 {\n" +
1420
            "      }\n" +
1421
            "    }\n" +
1422
            "    class Member2 {\n" +
1423
            "      class Member3 {\n" +
1424
            "        class Member4 {\n" +
1425
            "        }\n" +
1426
            "      }\n" +
1427
            "      void foo(){\n" +
1428
            "        Member\n" +
1429
            "      }\n" +
1430
            "    }\n" +
1431
            "  \n}" +
1593
            "}");
1432
            "}");
1594
    
1433
    
1595
    
1434
    
1596
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1435
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1597
    String str = this.wc.getSource();
1436
    String str = this.wc.getSource();
1598
    String completeBehind = "pack1.P";
1437
    String completeBehind = "Member";
1599
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1438
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1600
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1439
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1601
    
1602
	assertResults(
1603
			"pack1.pack3[PACKAGE_REF]{pack1.pack3.*;, pack1.pack3, null, null, null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n"+
1604
			"PX[TYPE_REF]{pack1.PX;, pack1, Lpack1.PX;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
1605
			requestor.getResults());
1606
}
1607
1608
/**
1609
 * Complete the local variable "var";
1610
 */
1611
public void testCompletionFindLocalVariable() throws JavaModelException {
1612
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1613
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindLocalVariable.java");
1614
1615
	String str = cu.getSource();
1616
	String completeBehind = "va";
1617
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1618
	cu.codeComplete(cursorLocation, requestor);
1619
	assertEquals(
1620
		"should have one local variable of 'var'", 
1621
		"element:var    completion:var    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED),
1622
		requestor.getResults());	
1623
}
1624
1625
/**
1626
 * Complete the method call "a.foobar" from "a.fooba";
1627
 */
1628
public void testCompletionFindMethod1() throws JavaModelException {
1629
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1630
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindMethod1.java");
1631
1632
	String str = cu.getSource();
1633
	String completeBehind = "fooba";
1634
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1635
	cu.codeComplete(cursorLocation, requestor);
1636
	assertEquals(
1637
		"should have two methods of 'foobar'", 
1638
		"element:foobar    completion:foobar()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED)+"\n" +
1639
		"element:foobar    completion:foobar()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED),
1640
		requestor.getResults());		
1641
}
1642
1643
1644
/**
1645
 * Too much Completion match on interface
1646
 */
1647
public void testCompletionFindMethod2() throws JavaModelException {
1648
	
1649
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1650
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindMethod2.java");
1651
1652
	String str = cu.getSource();
1653
	String completeBehind = "fooba";
1654
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
1655
	cu.codeComplete(cursorLocation, requestor);
1656
1657
	assertEquals(
1658
		"should have two completions", 
1659
		"element:foobar    completion:foobar()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED)+"\n" +
1660
		"element:foobar    completion:foobar()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED),
1661
		requestor.getResults());	
1662
}
1663
1664
1665
/**
1666
 * Complete the method call "foobar" from "fooba";
1667
 */
1668
public void testCompletionFindMethodInThis() throws JavaModelException {
1669
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1670
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindMethodInThis.java");
1671
1672
	String str = cu.getSource();
1673
	String completeBehind = "fooba";
1674
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1675
	cu.codeComplete(cursorLocation, requestor);
1676
	assertEquals(
1677
		"should have one method of 'foobar'", 
1678
		"element:foobar    completion:foobar    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
1679
		requestor.getResults());		
1680
}
1681
1682
/**
1683
 * Complete the method call "foobar" from "fooba".  The compilation
1684
 * unit simulates typing in process; ie it has incomplete structure/syntax errors.
1685
 */
1686
public void testCompletionFindMethodWhenInProcess() throws JavaModelException {
1687
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1688
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindMethodInProcess.java");
1689
1440
1690
	String str = cu.getSource();
1441
	assertResults(
1691
	String completeBehind = "fooba";
1442
            "CompletionAllMemberTypes2.Member1.Member2.Member3.Member4[TYPE_REF]{test.CompletionAllMemberTypes2.Member1.Member2.Member3.Member4, test, Ltest.CompletionAllMemberTypes2$Member1$Member2$Member3$Member4;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1692
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1443
			"CompletionAllMemberTypes2.Member1.Member5.Member6[TYPE_REF]{test.CompletionAllMemberTypes2.Member1.Member5.Member6, test, Ltest.CompletionAllMemberTypes2$Member1$Member5$Member6;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1693
	cu.codeComplete(cursorLocation, requestor);
1444
			"CompletionAllMemberTypes2.Member1[TYPE_REF]{Member1, test, Ltest.CompletionAllMemberTypes2$Member1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
1694
	assertEquals(
1445
			"CompletionAllMemberTypes2.Member1.Member2[TYPE_REF]{Member2, test, Ltest.CompletionAllMemberTypes2$Member1$Member2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
1695
		"should have a method of 'foobar'", 
1446
			"CompletionAllMemberTypes2.Member1.Member2.Member3[TYPE_REF]{Member3, test, Ltest.CompletionAllMemberTypes2$Member1$Member2$Member3;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
1696
		"element:foobar    completion:foobar()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
1447
			"CompletionAllMemberTypes2.Member1.Member5[TYPE_REF]{Member5, test, Ltest.CompletionAllMemberTypes2$Member1$Member5;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
1697
		requestor.getResults());
1448
            requestor.getResults());
1698
	cu.close();
1699
}
1449
}
1700
1450
public void testCompletionAllMemberTypes3() throws JavaModelException {
1701
public void testCompletionFindSuperInterface() throws JavaModelException {
1451
    this.wc = getWorkingCopy(
1702
	this.wc = getWorkingCopy(
1452
            "/Completion/src/test/CompletionAllMemberTypes2.java",
1703
            "/Completion/src/CompletionFindSuperInterface.java",
1453
            "package test;\n" +
1704
            "public class CompletionFindSuperInterface implements SuperInterface {\n"+
1454
            "public interface CompletionAllMemberTypes2 {\n" +
1455
            "  interface Member1 {\n" +
1456
            "    interface Member5 {\n" +
1457
            "      interface Member6 {\n" +
1458
            "      }\n" +
1459
            "    }\n" +
1460
            "    interface Member2 {\n" +
1461
            "      interface Member3 {\n" +
1462
            "        interface Member4 {\n" +
1463
            "        }\n" +
1464
            "      }\n" +
1465
            "        Member\n" +
1466
            "    }\n" +
1467
            "  \n}" +
1705
            "}");
1468
            "}");
1706
    
1469
    
1707
    
1470
    
1708
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1471
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1709
    String str = this.wc.getSource();
1472
    String str = this.wc.getSource();
1710
    String completeBehind = "Super";
1473
    String completeBehind = "Member";
1711
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1474
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1712
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1475
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1713
1476
1714
    assertResults(
1477
	assertResults(
1715
           "SuperInterface[TYPE_REF]{SuperInterface, , LSuperInterface;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_INTERFACE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
1478
            "Member[POTENTIAL_METHOD_DECLARATION]{Member, Ltest.CompletionAllMemberTypes2$Member1$Member2;, ()V, Member, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
1716
			requestor.getResults());
1479
			"CompletionAllMemberTypes2.Member1.Member2.Member3.Member4[TYPE_REF]{test.CompletionAllMemberTypes2.Member1.Member2.Member3.Member4, test, Ltest.CompletionAllMemberTypes2$Member1$Member2$Member3$Member4;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1480
			"CompletionAllMemberTypes2.Member1.Member5.Member6[TYPE_REF]{test.CompletionAllMemberTypes2.Member1.Member5.Member6, test, Ltest.CompletionAllMemberTypes2$Member1$Member5$Member6;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1481
			"CompletionAllMemberTypes2.Member1[TYPE_REF]{Member1, test, Ltest.CompletionAllMemberTypes2$Member1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
1482
			"CompletionAllMemberTypes2.Member1.Member2[TYPE_REF]{Member2, test, Ltest.CompletionAllMemberTypes2$Member1$Member2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
1483
			"CompletionAllMemberTypes2.Member1.Member2.Member3[TYPE_REF]{Member3, test, Ltest.CompletionAllMemberTypes2$Member1$Member2$Member3;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
1484
			"CompletionAllMemberTypes2.Member1.Member5[TYPE_REF]{Member5, test, Ltest.CompletionAllMemberTypes2$Member1$Member5;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
1485
            requestor.getResults());
1717
}
1486
}
1718
1487
public void testCompletionAllMemberTypes4() throws JavaModelException {
1719
/**
1488
	ICompilationUnit anInterface = null;
1720
 * Complete the field "bar" from "this.ba"
1489
	try {
1721
 */
1490
		anInterface = getWorkingCopy(
1722
public void testCompletionFindThisDotField() throws JavaModelException {
1491
	            "/Completion/src/test/AnInterface.java",
1723
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1492
	            "package test;\n" +
1724
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindThisDotField.java");
1493
	            "public interface AnInterface {\n" +
1725
1494
	            "  public interface Member1 {\n" +
1726
	String str = cu.getSource();
1495
	            "    public interface Member5 {\n" +
1727
	String completeBehind = "this.ba";
1496
	            "      public interface Member6 {\n" +
1728
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1497
	            "      }\n" +
1729
	cu.codeComplete(cursorLocation, requestor);
1498
	            "    }\n" +
1730
	assertEquals(
1499
	            "    public interface Member2 {\n" +
1731
		"should have one result of 'bar'", 
1500
	            "      public interface Member3 {\n" +
1732
		"element:bar    completion:bar    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED),
1501
	            "        interface Member4 {\n" +
1733
		requestor.getResults());
1502
	            "        }\n" +
1503
	            "      }\n" +
1504
	            "        Member\n" +
1505
	            "    }\n" +
1506
	            "  \n}" +
1507
	            "}");
1508
		
1509
	    this.wc = getWorkingCopy(
1510
	            "/Completion/src/test/CompletionAllMemberTypes2.java",
1511
	            "package test;\n" +
1512
	            "public class CompletionAllMemberTypes2 {\n" +
1513
	            "  class Member1 {\n" +
1514
	            "    class Member5 {\n" +
1515
	            "      class Member6 {\n" +
1516
	            "      }\n" +
1517
	            "    }\n" +
1518
	            "    class Member2 implements AnInterface {\n" +
1519
	            "      class Member3 {\n" +
1520
	            "        class Member4 {\n" +
1521
	            "        }\n" +
1522
	            "      }\n" +
1523
	            "      void foo(){\n" +
1524
	            "        Member\n" +
1525
	            "      }\n" +
1526
	            "    }\n" +
1527
	            "  \n}" +
1528
	            "}");
1529
	    
1530
	    
1531
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1532
	    String str = this.wc.getSource();
1533
	    String completeBehind = "Member";
1534
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1535
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1536
	
1537
    	assertResults(
1538
	            "AnInterface.Member1.Member2[TYPE_REF]{test.AnInterface.Member1.Member2, test, Ltest.AnInterface$Member1$Member2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1539
				"AnInterface.Member1.Member2.Member3[TYPE_REF]{test.AnInterface.Member1.Member2.Member3, test, Ltest.AnInterface$Member1$Member2$Member3;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1540
				"AnInterface.Member1.Member2.Member3.Member4[TYPE_REF]{test.AnInterface.Member1.Member2.Member3.Member4, test, Ltest.AnInterface$Member1$Member2$Member3$Member4;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1541
				"AnInterface.Member1.Member5[TYPE_REF]{test.AnInterface.Member1.Member5, test, Ltest.AnInterface$Member1$Member5;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1542
				"AnInterface.Member1.Member5.Member6[TYPE_REF]{test.AnInterface.Member1.Member5.Member6, test, Ltest.AnInterface$Member1$Member5$Member6;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1543
				"CompletionAllMemberTypes2.Member1.Member2.Member3.Member4[TYPE_REF]{test.CompletionAllMemberTypes2.Member1.Member2.Member3.Member4, test, Ltest.CompletionAllMemberTypes2$Member1$Member2$Member3$Member4;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1544
				"CompletionAllMemberTypes2.Member1.Member5.Member6[TYPE_REF]{test.CompletionAllMemberTypes2.Member1.Member5.Member6, test, Ltest.CompletionAllMemberTypes2$Member1$Member5$Member6;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1545
				"AnInterface.Member1[TYPE_REF]{Member1, test, Ltest.AnInterface$Member1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
1546
				"CompletionAllMemberTypes2.Member1[TYPE_REF]{Member1, test, Ltest.CompletionAllMemberTypes2$Member1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
1547
				"CompletionAllMemberTypes2.Member1.Member2[TYPE_REF]{Member2, test, Ltest.CompletionAllMemberTypes2$Member1$Member2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
1548
				"CompletionAllMemberTypes2.Member1.Member2.Member3[TYPE_REF]{Member3, test, Ltest.CompletionAllMemberTypes2$Member1$Member2$Member3;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
1549
				"CompletionAllMemberTypes2.Member1.Member5[TYPE_REF]{Member5, test, Ltest.CompletionAllMemberTypes2$Member1$Member5;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
1550
	            requestor.getResults());
1551
	} finally {
1552
		if(anInterface != null) {
1553
			anInterface.discardWorkingCopy();
1554
		}
1555
	}
1734
}
1556
}
1735
1557
1736
/**
1558
public void testCompletionAllMemberTypes5() throws JavaModelException {
1737
 * Attempt to do completion with a null requestor
1559
	ICompilationUnit aType = null;
1738
 */
1560
	Hashtable oldCurrentOptions = JavaCore.getOptions();
1739
public void testCompletionNullRequestor() throws JavaModelException {
1740
	try {
1561
	try {
1741
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindThisDotField.java");
1562
		Hashtable options = new Hashtable(oldCurrentOptions);
1742
		cu.codeComplete(5, (CompletionRequestor)null);
1563
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1743
	} catch (IllegalArgumentException iae) {
1564
		JavaCore.setOptions(options);
1744
		return;
1565
		
1566
		aType = getWorkingCopy(
1567
	            "/Completion/src/test/AType.java",
1568
	            "package test;\n" +
1569
	            "public class AType {\n" +
1570
	            "  public class Member1 {\n" +
1571
	            "    private class Member2 {\n" +
1572
	            "      public class Member3 {\n" +
1573
	            "        public class Member4 {\n" +
1574
	            "        }\n" +
1575
	            "      }\n" +
1576
	            "    }\n" +
1577
	            "  \n}" +
1578
	            "}");
1579
		
1580
	    this.wc = getWorkingCopy(
1581
	            "/Completion/src/test/CompletionAllMemberTypes5.java",
1582
	            "package test;\n" +
1583
	            "public class CompletionAllMemberTypes5 {\n" +
1584
	            "  void foo(){\n" +
1585
	            "    Member\n" +
1586
	            "  }\n" +
1587
	            "}");
1588
	    
1589
	    
1590
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1591
	    String str = this.wc.getSource();
1592
	    String completeBehind = "Member";
1593
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1594
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1595
	
1596
    	// AType.Member1.Member2.Member3 and AType.Member1.Member2.Member3.Member4 should not be proposed because they are not visible.
1597
    	// But visibility need modifiers of enclosing types to be computed. 
1598
    	assertResults(
1599
	            "AType.Member1[TYPE_REF]{test.AType.Member1, test, Ltest.AType$Member1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1600
				"AType.Member1.Member2.Member3[TYPE_REF]{test.AType.Member1.Member2.Member3, test, Ltest.AType$Member1$Member2$Member3;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1601
				"AType.Member1.Member2.Member3.Member4[TYPE_REF]{test.AType.Member1.Member2.Member3.Member4, test, Ltest.AType$Member1$Member2$Member3$Member4;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
1602
	            requestor.getResults());
1603
	} finally {
1604
		if(aType != null) {
1605
			aType.discardWorkingCopy();
1606
		}
1607
		JavaCore.setOptions(oldCurrentOptions);
1745
	}
1608
	}
1746
	assertTrue("Should not be able to do completion with a null requestor", false);
1747
}
1609
}
1748
1610
1749
/**
1611
public void testCompletionAllMemberTypes6() throws JavaModelException {
1750
 * Ensures that the code assist features works on class files with associated source.
1612
	Hashtable oldCurrentOptions = JavaCore.getOptions();
1751
 */
1613
	try {
1752
public void testCompletionOnClassFile() throws JavaModelException {
1614
		Hashtable options = new Hashtable(oldCurrentOptions);
1753
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1615
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1754
	IClassFile cu = getClassFile("Completion", "zzz.jar", "jarpack1", "X.class");
1616
		JavaCore.setOptions(options);
1617
		
1618
	    this.wc = getWorkingCopy(
1619
	            "/Completion/src/test/CompletionAllMemberTypes6.java",
1620
	            "package test;\n" +
1621
	            "class AType {\n" +
1622
	            "  public class Member1 {\n" +
1623
	            "    private class Member2 {\n" +
1624
	            "      public class Member3 {\n" +
1625
	            "      }\n" +
1626
	            "    }\n" +
1627
	            "  }\n" +
1628
	            "}\n" +
1629
	            "public class CompletionAllMemberTypes6 {\n" +
1630
	            "  void foo(){\n" +
1631
	            "    Member\n" +
1632
	            "  }\n" +
1633
	            "}");
1634
	    
1635
	    
1636
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1637
	    String str = this.wc.getSource();
1638
	    String completeBehind = "Member";
1639
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1640
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1755
	
1641
	
1756
	String str = cu.getSource();
1642
    	assertResults(
1757
	String completeBehind = "Obj";
1643
	            "AType.Member1[TYPE_REF]{test.AType.Member1, test, Ltest.AType$Member1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
1758
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1644
	            requestor.getResults());
1759
	cu.codeComplete(cursorLocation, requestor);
1645
	} finally {
1760
	assertEquals(
1646
		JavaCore.setOptions(oldCurrentOptions);
1761
		"should have one class", 
1647
	}
1762
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
1763
		requestor.getResults());
1764
}
1648
}
1765
1649
1766
/**
1650
public void testCompletionAllMemberTypes7() throws JavaModelException {
1767
 * Test that an out of bounds index causes an exception.
1651
	Hashtable oldCurrentOptions = JavaCore.getOptions();
1768
 */
1769
public void testCompletionOutOfBounds() throws JavaModelException {
1770
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1771
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionOutOfBounds.java");
1772
	try {
1652
	try {
1773
		cu.codeComplete(cu.getSource().length() + 1, requestor);
1653
		Hashtable options = new Hashtable(oldCurrentOptions);
1774
	} catch (JavaModelException e) {
1654
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
1775
		return;
1655
		JavaCore.setOptions(options);
1656
		
1657
	    this.wc = getWorkingCopy(
1658
	            "/Completion/src/test/AType.java",
1659
	            "package test;\n" +
1660
	            "class AType {\n" +
1661
	            "  public class Member1 {\n" +
1662
	            "    private class Member2 {\n" +
1663
	            "      public class Member3 {\n" +
1664
	            "      }\n" +
1665
	            "    }\n" +
1666
	            "  }\n" +
1667
	            "  void foo(){\n" +
1668
	            "    Member\n" +
1669
	            "  }\n" +
1670
	            "}");
1671
	    
1672
	    
1673
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1674
	    String str = this.wc.getSource();
1675
	    String completeBehind = "Member";
1676
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1677
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1678
	
1679
    	assertResults(
1680
	            "AType.Member1.Member2[TYPE_REF]{test.AType.Member1.Member2, test, Ltest.AType$Member1$Member2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1681
				"AType.Member1.Member2.Member3[TYPE_REF]{test.AType.Member1.Member2.Member3, test, Ltest.AType$Member1$Member2$Member3;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
1682
				"AType.Member1[TYPE_REF]{Member1, test, Ltest.AType$Member1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
1683
	            requestor.getResults());
1684
	} finally {
1685
		JavaCore.setOptions(oldCurrentOptions);
1776
	}
1686
	}
1777
	assertTrue("should have failed", false);
1778
}
1687
}
1779
1688
1780
/**
1689
public void testCompletionAllocationExpressionIsParent1() throws JavaModelException {
1781
 * Complete the type "Repeated", "RepeatedOtherType from "Repeated".
1782
 */
1783
public void testCompletionRepeatedType() throws JavaModelException {
1784
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1690
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1785
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionRepeatedType.java");
1691
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAllocationExpressionIsParent1.java");
1786
1692
1787
	String str = cu.getSource();
1693
	String str = cu.getSource();
1788
	String completeBehind = "/**/CompletionRepeated";
1694
	String completeBehind = "zz";
1789
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1695
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1790
	cu.codeComplete(cursorLocation, requestor);
1696
	cu.codeComplete(cursorLocation, requestor);
1697
1791
	assertEquals(
1698
	assertEquals(
1792
		"should have two types",
1699
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
1793
		"element:CompletionRepeatedOtherType    completion:CompletionRepeatedOtherType    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
1700
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
1794
		"element:CompletionRepeatedType    completion:CompletionRepeatedType    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
1701
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
1795
		requestor.getResults());	
1702
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
1703
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
1704
		requestor.getResults());
1796
}
1705
}
1797
1706
public void testCompletionAllocationExpressionIsParent2() throws JavaModelException {
1798
1707
	this.wc = getWorkingCopy(
1799
public void testCompletionVisibilityCheckEnabled() throws JavaModelException {
1708
            "/Completion/src/CompletionAllocationExpressionIsParent2.java",
1800
	String visibilityCheckID = "org.eclipse.jdt.core.codeComplete.visibilityCheck";
1709
            "public class CompletionAllocationExpressionIsParent2 {\n" +
1801
	Hashtable options = JavaCore.getOptions();
1710
            "	public class Inner {\n" +
1802
	Object visibilityCheckPreviousValue = options.get(visibilityCheckID);
1711
            "		public Inner(long i, long j){super();}\n" +
1803
	options.put(visibilityCheckID,"enabled");
1712
            "		public Inner(Object i, Object j){super();}\n" +
1804
	JavaCore.setOptions(options);
1713
            "		\n" +
1805
	
1714
            "	}\n" +
1715
            "	\n" +
1716
            "	long zzlong;\n" +
1717
            "	int zzint;\n" +
1718
            "	double zzdouble;\n" +
1719
            "	boolean zzboolean;\n" +
1720
            "	Object zzObject;\n" +
1721
            "	\n" +
1722
            "	void foo() {\n" +
1723
            "		this.new Inner(1, zz\n" +
1724
            "	}\n" +
1725
            "}");
1726
    
1727
    
1728
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1729
    String str = this.wc.getSource();
1730
    String completeBehind = "zz";
1731
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1732
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1733
1734
    assertResults(
1735
            "zzObject[FIELD_REF]{zzObject, LCompletionAllocationExpressionIsParent2;, Ljava.lang.Object;, zzObject, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1736
            "zzboolean[FIELD_REF]{zzboolean, LCompletionAllocationExpressionIsParent2;, Z, zzboolean, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1737
            "zzdouble[FIELD_REF]{zzdouble, LCompletionAllocationExpressionIsParent2;, D, zzdouble, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1738
            "zzint[FIELD_REF]{zzint, LCompletionAllocationExpressionIsParent2;, I, zzint, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1739
            "zzlong[FIELD_REF]{zzlong, LCompletionAllocationExpressionIsParent2;, J, zzlong, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED)+"}",
1740
            requestor.getResults());
1741
}
1742
1743
public void testCompletionAllocationExpressionIsParent3() throws JavaModelException {
1744
	this.wc = getWorkingCopy(
1745
            "/Completion/src/CompletionAllocationExpressionIsParent3.java",
1746
            "public class CompletionAllocationExpressionIsParent3 {\n" +
1747
            "	public class Inner {\n" +
1748
            "		public Inner(long i, long j){super();}\n" +
1749
            "		public Inner(Object i, Object j){super();}\n" +
1750
            "		\n" +
1751
            "	}\n" +
1752
            "	\n" +
1753
            "	long zzlong;\n" +
1754
            "	int zzint;\n" +
1755
            "	double zzdouble;\n" +
1756
            "	boolean zzboolean;\n" +
1757
            "	Object zzObject;\n" +
1758
            "	\n" +
1759
            "	void foo() {\n" +
1760
            "		new CompletionAllocationExpressionIsParent3().new Inner(1, zz\n" +
1761
            "	}\n" +
1762
            "}");
1763
    
1764
    
1765
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1766
    String str = this.wc.getSource();
1767
    String completeBehind = "zz";
1768
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1769
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1770
1771
    assertResults(
1772
            "zzObject[FIELD_REF]{zzObject, LCompletionAllocationExpressionIsParent3;, Ljava.lang.Object;, zzObject, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1773
            "zzboolean[FIELD_REF]{zzboolean, LCompletionAllocationExpressionIsParent3;, Z, zzboolean, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1774
            "zzdouble[FIELD_REF]{zzdouble, LCompletionAllocationExpressionIsParent3;, D, zzdouble, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1775
            "zzint[FIELD_REF]{zzint, LCompletionAllocationExpressionIsParent3;, I, zzint, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1776
            "zzlong[FIELD_REF]{zzlong, LCompletionAllocationExpressionIsParent3;, J, zzlong, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED)+"}",
1777
            requestor.getResults());
1778
}
1779
1780
public void testCompletionAllocationExpressionIsParent4() throws JavaModelException {
1806
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1781
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1807
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVisibilityCheck.java");
1782
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAllocationExpressionIsParent4.java");
1808
1783
1809
	String str = cu.getSource();
1784
	String str = cu.getSource();
1810
	String completeBehind = "x.p";
1785
	String completeBehind = "zz";
1811
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
1786
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1812
	cu.codeComplete(cursorLocation, requestor);
1787
	cu.codeComplete(cursorLocation, requestor);
1813
	
1788
1814
	options.put(visibilityCheckID,visibilityCheckPreviousValue);
1815
	JavaCore.setOptions(options);
1816
	assertEquals(
1789
	assertEquals(
1817
		"should have two methods", 
1790
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
1818
		"element:protectedFoo    completion:protectedFoo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED)+"\n" +
1791
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
1819
		"element:publicFoo    completion:publicFoo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
1792
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
1793
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
1794
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
1820
		requestor.getResults());
1795
		requestor.getResults());
1821
}
1796
}
1822
1797
1823
1798
public void testCompletionAllocationExpressionIsParent5() throws JavaModelException {
1824
public void testCompletionVisibilityCheckDisabled() throws JavaModelException {
1825
	String visibilityCheckID = "org.eclipse.jdt.core.codeComplete.visibilityCheck";
1826
	Hashtable options = JavaCore.getOptions();
1827
	Object visibilityCheckPreviousValue = options.get(visibilityCheckID);
1828
	options.put(visibilityCheckID,"disabled");
1829
	JavaCore.setOptions(options);
1830
	
1831
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1799
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1832
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVisibilityCheck.java");
1800
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAllocationExpressionIsParent5.java");
1833
1801
1834
	String str = cu.getSource();
1802
	String str = cu.getSource();
1835
	String completeBehind = "x.p";
1803
	String completeBehind = "zz";
1836
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
1804
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1837
	cu.codeComplete(cursorLocation, requestor);
1805
	cu.codeComplete(cursorLocation, requestor);
1838
	
1806
1839
	options.put(visibilityCheckID,visibilityCheckPreviousValue);
1840
	JavaCore.setOptions(options);
1841
	assertEquals(
1807
	assertEquals(
1842
		"should have three methods", 
1808
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
1843
		"element:privateFoo    completion:privateFoo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED)+"\n" +
1809
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
1844
		"element:protectedFoo    completion:protectedFoo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED)+"\n" +
1810
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
1845
		"element:publicFoo    completion:publicFoo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
1811
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
1812
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
1846
		requestor.getResults());
1813
		requestor.getResults());
1847
}
1814
}
1848
1815
1816
1817
public void testCompletionAllocationExpressionIsParent6() throws JavaModelException {
1818
	this.wc = getWorkingCopy(
1819
            "/Completion/src/CompletionAllocationExpressionIsParent6.java",
1820
            "public class CompletionAllocationExpressionIsParent6 {\n" +
1821
            "	\n" +
1822
            "	long zzlong;\n" +
1823
            "	int zzint;\n" +
1824
            "	double zzdouble;\n" +
1825
            "	boolean zzboolean;\n" +
1826
            "	Object zzObject;\n" +
1827
            "	\n" +
1828
            "	void foo() {\n" +
1829
            "		new CompletionAllocation_ERROR_ExpressionIsParent6Plus().new Inner(1, zz\n" +
1830
            "	}\n" +
1831
            "}\n" +
1832
            "class CompletionAllocationExpressionIsParent6Plus {\n" +
1833
            "	public class Inner {\n" +
1834
            "		public Inner(long i, long j){\n" +
1835
            "			\n" +
1836
            "		}	\n" +
1837
            "	}	\n" +
1838
            "}");
1839
    
1840
    
1841
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1842
    String str = this.wc.getSource();
1843
    String completeBehind = "zz";
1844
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1845
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1846
1847
    assertResults(
1848
            "zzObject[FIELD_REF]{zzObject, LCompletionAllocationExpressionIsParent6;, Ljava.lang.Object;, zzObject, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1849
            "zzboolean[FIELD_REF]{zzboolean, LCompletionAllocationExpressionIsParent6;, Z, zzboolean, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1850
            "zzdouble[FIELD_REF]{zzdouble, LCompletionAllocationExpressionIsParent6;, D, zzdouble, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1851
            "zzint[FIELD_REF]{zzint, LCompletionAllocationExpressionIsParent6;, I, zzint, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
1852
            "zzlong[FIELD_REF]{zzlong, LCompletionAllocationExpressionIsParent6;, J, zzlong, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED)+"}",
1853
            requestor.getResults());
1854
}
1855
1849
public void testCompletionAmbiguousFieldName() throws JavaModelException {
1856
public void testCompletionAmbiguousFieldName() throws JavaModelException {
1850
1857
1851
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1858
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
Lines 1904-1911 Link Here
1904
		"element:xBar    completion:xBar    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
1911
		"element:xBar    completion:xBar    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
1905
		requestor.getResults());
1912
		requestor.getResults());
1906
}
1913
}
1907
1908
1909
public void testCompletionAmbiguousFieldName4() throws JavaModelException {
1914
public void testCompletionAmbiguousFieldName4() throws JavaModelException {
1910
1915
1911
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1916
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
Lines 1921-4381 Link Here
1921
		"element:xBar    completion:xBar    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
1926
		"element:xBar    completion:xBar    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
1922
		requestor.getResults());
1927
		requestor.getResults());
1923
}
1928
}
1929
public void testCompletionAmbiguousType() throws JavaModelException {
1930
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1931
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAmbiguousType.java");
1924
1932
1933
	String str = cu.getSource();
1934
	String completeBehind = "ABC";
1935
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1936
	cu.codeComplete(cursorLocation, requestor);
1925
1937
1926
public void testCompletionPrefixFieldName1() throws JavaModelException {
1938
	assertEquals(
1927
	this.wc = getWorkingCopy(
1939
		"should have two completions", 
1928
            "/Completion/src/CompletionPrefixFieldName1.java",
1940
		"element:ABC    completion:p1.ABC    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"\n" +
1929
            "public class CompletionPrefixFieldName1 {\n"+
1941
		"element:ABC    completion:p2.ABC    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME+ R_NON_RESTRICTED),
1930
            "	int xBar;\n"+
1942
		requestor.getResults());
1931
            "	\n"+
1943
}
1932
            "	class classFoo {\n"+
1944
public void testCompletionAmbiguousType2() throws JavaModelException {
1933
            "		int xBar;\n"+
1945
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1934
            "		\n"+
1946
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAmbiguousType2.java");
1935
            "		public void foo(){\n"+
1936
            "			xBa\n"+
1937
            "		}\n"+
1938
            "	}\n"+
1939
            "}");
1940
    
1941
    
1942
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1943
    String str = this.wc.getSource();
1944
    String completeBehind = "xBa";
1945
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1946
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1947
1947
1948
	assertResults(
1948
	String str = cu.getSource();
1949
		"xBar[FIELD_REF]{CompletionPrefixFieldName1.this.xBar, LCompletionPrefixFieldName1;, I, xBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1949
	String completeBehind = "ABC";
1950
		"xBar[FIELD_REF]{xBar, LCompletionPrefixFieldName1$classFoo;, I, xBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED)+"}",
1950
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1951
	cu.codeComplete(cursorLocation, requestor);
1952
1953
	assertEquals(
1954
		"should have two completions", 
1955
		"element:ABC    completion:ABC    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
1956
		"element:ABC    completion:p2.ABC    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME+ R_NON_RESTRICTED),
1951
		requestor.getResults());
1957
		requestor.getResults());
1952
}
1958
}
1953
1959
1960
public void testCompletionArgumentName() throws JavaModelException {
1961
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1962
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionArgumentName.java");
1954
1963
1955
public void testCompletionPrefixFieldName2() throws JavaModelException {
1964
	String str = cu.getSource();
1956
	this.wc = getWorkingCopy(
1965
	String completeBehind = "ClassWithComplexName ";
1957
            "/Completion/src/CompletionPrefixFieldName2.java",
1966
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1958
            "public class CompletionPrefixFieldName2 {\n"+
1967
	cu.codeComplete(cursorLocation, requestor);
1959
            "	int xBar;\n"+
1960
            "	\n"+
1961
            "	class classFoo {\n"+
1962
            "		int xBar;\n"+
1963
            "		\n"+
1964
            "		public void foo(){\n"+
1965
            "			new CompletionPrefixFieldName2().xBa\n"+
1966
            "		}\n"+
1967
            "	}\n"+
1968
            "}");
1969
    
1970
    
1971
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
1972
    String str = this.wc.getSource();
1973
    String completeBehind = "xBa";
1974
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1975
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
1976
1968
1977
	assertResults(
1969
	assertEquals(
1978
		"xBar[FIELD_REF]{xBar, LCompletionPrefixFieldName2;, I, xBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED)+"}",
1970
		"should have two completions", 
1971
		"element:classWithComplexName    completion:classWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
1972
		"element:complexName2    completion:complexName2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
1973
		"element:name    completion:name    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
1974
		"element:withComplexName    completion:withComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
1979
		requestor.getResults());
1975
		requestor.getResults());
1980
}
1976
}
1981
1977
1978
public void testCompletionArrayAccess1() throws JavaModelException {
1979
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
1980
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionArrayAccess1.java");
1982
1981
1983
public void testCompletionPrefixMethodName1() throws JavaModelException {
1982
	String str = cu.getSource();
1984
	this.wc = getWorkingCopy(
1983
	String completeBehind = "zzz";
1985
            "/Completion/src/CompletionPrefixMethodName1.java",
1984
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
1986
            "public class CompletionPrefixMethodName1 {\n"+
1985
	cu.codeComplete(cursorLocation, requestor);
1987
           "	int xBar(){}\n"+
1988
           "	\n"+
1989
           "	class classFoo {\n"+
1990
           "		int xBar(){}\n"+
1991
           "		\n"+
1992
           "		public void foo(){\n"+
1993
           "			xBa\n"+
1994
           "		}\n"+
1995
           "	}\n"+
1996
           "}");
1997
    
1998
    
1999
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2000
    String str = this.wc.getSource();
2001
    String completeBehind = "xBa";
2002
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2003
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2004
1986
2005
	assertResults(
1987
	assertEquals(
2006
		"xBar[METHOD_REF]{CompletionPrefixMethodName1.this.xBar(), LCompletionPrefixMethodName1;, ()I, xBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
1988
		"element:zzz1    completion:zzz1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2007
		"xBar[METHOD_REF]{xBar(), LCompletionPrefixMethodName1$classFoo;, ()I, xBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED)+"}",
1989
		"element:zzz2    completion:zzz2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE +R_UNQUALIFIED+ R_NON_RESTRICTED),
2008
		requestor.getResults());
1990
		requestor.getResults());
2009
}
1991
}
2010
1992
2011
1993
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=84690
2012
public void testCompletionPrefixMethodName2() throws JavaModelException {
1994
public void testCompletionArrayClone() throws JavaModelException {
2013
	this.wc = getWorkingCopy(
1995
    this.wc = getWorkingCopy(
2014
            "/Completion/src/CompletionPrefixMethodName2.java",
1996
            "/Completion/src/test/CompletionArrayClone.java",
2015
            "public class CompletionPrefixMethodName2 {\n"+
1997
            "package test;\n" +
2016
            "	int xBar(){}\n"+
1998
            "public class CompletionArrayClone {\n" +
2017
            "	\n"+
1999
            "  public void foo() {\n" +
2018
            "	class classFoo {\n"+
2000
            "    long[] var;\n" +
2019
            "		int xBar(){}\n"+
2001
            "    var.clon\n" +
2020
            "		\n"+
2002
            "  }\n" +
2021
            "		public void foo(){\n"+
2022
            "			new CompletionPrefixMethodName2().xBa\n"+
2023
            "		}\n"+
2024
            "	}\n"+
2025
            "}");
2003
            "}");
2026
    
2004
    
2027
    
2005
    
2028
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2006
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2029
    String str = this.wc.getSource();
2007
    String str = this.wc.getSource();
2030
    String completeBehind = "xBa";
2008
    String completeBehind = "clon";
2031
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2009
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2032
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2010
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2033
2011
2034
	assertResults(
2012
    assertResults(
2035
		"xBar[METHOD_REF]{xBar(), LCompletionPrefixMethodName2;, ()I, xBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED)+"}",
2013
            "clone[METHOD_REF]{clone(), [J, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}",
2036
		requestor.getResults());
2014
            requestor.getResults());
2037
}
2015
}
2038
2016
2039
public void testCompletionPrefixMethodName3() throws JavaModelException {
2017
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=84690
2040
	this.wc = getWorkingCopy(
2018
public void testCompletionArrayLength() throws JavaModelException {
2041
            "/Completion/src/CompletionPrefixMethodName2.java",
2019
    this.wc = getWorkingCopy(
2042
            "public class CompletionPrefixMethodName3 {\n"+
2020
            "/Completion/src/test/CompletionArrayLength.java",
2043
            "	int xBar(int a, int b){}\n"+
2021
            "package test;\n" +
2044
            "	\n"+
2022
            "public class CompletionArrayLength {\n" +
2045
            "	class classFoo {\n"+
2023
            "  public void foo() {\n" +
2046
            "		int xBar(int a, int b){}\n"+
2024
            "    long[] var;\n" +
2047
            "		\n"+
2025
            "    var.leng\n" +
2048
            "		public void foo(){\n"+
2026
            "  }" +
2049
            "			xBar(1,\n"+
2050
            "		}\n"+
2051
            "	}\n"+
2052
            "}");
2027
            "}");
2053
    
2028
    
2054
    
2029
    
2055
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2030
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2056
    String str = this.wc.getSource();
2031
    String str = this.wc.getSource();
2057
    String completeBehind = "xBar(1,";
2032
    String completeBehind = "leng";
2058
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2033
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2059
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2034
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2060
2035
2061
	assertResults(
2036
    assertResults(
2062
		"xBar[METHOD_REF]{CompletionPrefixMethodName3.this.xBar(1,, LCompletionPrefixMethodName3;, (II)I, xBar, (a, b), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME+ R_NON_RESTRICTED)+"}\n"+
2037
            "length[FIELD_REF]{length, [J, I, length, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
2063
		"xBar[METHOD_REF]{, LCompletionPrefixMethodName3$classFoo;, (II)I, xBar, (a, b), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
2038
            requestor.getResults());
2064
		requestor.getResults());
2065
}
2039
}
2066
2040
2067
public void testCompletionFindMemberType1() throws JavaModelException {
2041
public void testCompletionArraysCloneMethod() throws JavaModelException {
2068
	this.wc = getWorkingCopy(
2042
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2069
            "/Completion/src/CompletionFindMemberType1.java",
2043
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionArraysCloneMethod.java");
2070
            "interface A1 {\n"+
2071
            "	class Inner1 {\n"+
2072
            "	}\n"+
2073
            "}\n"+
2074
            "interface B1 extends A1 {\n"+
2075
            "	class Inner1 {\n"+
2076
            "	}\n"+
2077
            "}\n"+
2078
            "public class CompletionFindMemberType1 {\n"+
2079
            "	public void foo() {\n"+
2080
            "		B1.Inner\n"+
2081
            "	}\n"+
2082
            "}");
2083
    
2084
    
2085
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2086
    String str = this.wc.getSource();
2087
    String completeBehind = "Inner";
2088
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2089
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2090
2044
2091
	assertResults(
2045
	String str = cu.getSource();
2092
		"B1.Inner1[TYPE_REF]{Inner1, , LB1$Inner1;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) +"}",
2046
	String completeBehind = ".cl";
2047
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2048
	cu.codeComplete(cursorLocation, requestor);
2049
2050
	assertEquals(
2051
		"element:clone    completion:clone()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
2093
		requestor.getResults());
2052
		requestor.getResults());
2094
}
2053
}
2095
2054
2096
public void testCompletionFindMemberType2() throws JavaModelException {
2055
public void testCompletionAssignmentInMethod1() throws JavaModelException {
2097
	this.wc = getWorkingCopy(
2056
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2098
            "/Completion/src/CompletionPrefixMethodName2.java",
2057
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAssignmentInMethod1.java");
2099
            "interface A2 {\n"+
2100
            "	class ZInner2{\n"+
2101
            "	}\n"+
2102
            "}\n"+
2103
            "interface B2 extends A2 {\n"+
2104
            "	class ZInner2 {\n"+
2105
            "	}\n"+
2106
            "}\n"+
2107
            "public class CompletionFindMemberType2 implements B2{\n"+
2108
            "	public void foo() {\n"+
2109
            "		ZInner\n"+
2110
            "	}\n"+
2111
            "}");
2112
    
2113
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2114
    String str = this.wc.getSource();
2115
    String completeBehind = "ZInner";
2116
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2117
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2118
2058
2119
	assertResults(
2059
	String str = cu.getSource();
2120
		"B2.ZInner2[TYPE_REF]{ZInner2, , LB2$ZInner2;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE+ R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
2060
	String completeBehind = "zz";
2061
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2062
	cu.codeComplete(cursorLocation, requestor);
2063
2064
	assertEquals(
2065
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2066
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2067
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2068
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2069
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
2121
		requestor.getResults());
2070
		requestor.getResults());
2122
}
2071
}
2123
2072
2124
public void testCompletionMethodDeclaration() throws JavaModelException {
2073
public void testCompletionAssignmentInMethod2() throws JavaModelException {
2074
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2075
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAssignmentInMethod2.java");
2076
2077
	String str = cu.getSource();
2078
	String completeBehind = "zz";
2079
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2080
	cu.codeComplete(cursorLocation, requestor);
2081
2082
	assertEquals(
2083
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2084
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2085
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2086
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2087
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
2088
		requestor.getResults());
2089
}
2125
2090
2091
public void testCompletionAssignmentInMethod3() throws JavaModelException {
2126
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2092
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2127
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMethodDeclaration.java");
2093
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAssignmentInMethod3.java");
2128
2094
2129
	String str = cu.getSource();
2095
	String str = cu.getSource();
2130
	String completeBehind = "eq";
2096
	String completeBehind = "Objec";
2131
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
2097
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2132
	cu.codeComplete(cursorLocation, requestor);
2098
	cu.codeComplete(cursorLocation, requestor);
2133
2099
2134
	assertEquals(
2100
	assertEquals(
2135
		"should have two completions", 
2101
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
2136
		"element:eqFoo    completion:public int eqFoo(int a, Object b)    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"\n" +
2137
		"element:equals    completion:public boolean equals(Object obj)    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
2138
		requestor.getResults());
2102
		requestor.getResults());
2139
}
2103
}
2140
2104
2141
public void testCompletionMethodDeclaration2() throws JavaModelException {
2105
2142
	ICompilationUnit superClass = null;
2106
public void testCompletionAssignmentInMethod4() throws JavaModelException {
2143
	try {
2107
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2144
		superClass = getWorkingCopy(
2108
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAssignmentInMethod4.java");
2145
	            "/Completion/src/CompletionSuperClass.java",
2109
2146
	            "public class CompletionSuperClass{\n" +
2110
	String str = cu.getSource();
2147
	            "	public class Inner {}\n" +
2111
	String completeBehind = "Objec";
2148
	            "	public int eqFoo(int a,Object b){\n" +
2112
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2149
	            "		return 1;\n" +
2113
	cu.codeComplete(cursorLocation, requestor);
2150
	            "	}\n" +
2114
2151
	            "}");
2115
	assertEquals(
2152
		
2116
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
2153
		this.wc = getWorkingCopy(
2117
		requestor.getResults());
2154
	            "/Completion/src/CompletionMethodDeclaration2.java",
2155
	            "public class CompletionMethodDeclaration2 extends CompletionSuperClass {\n" +
2156
	            "	eq\n" +
2157
	            "}");
2158
	    
2159
	    
2160
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2161
	    String str = this.wc.getSource();
2162
	    String completeBehind = "eq";
2163
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2164
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2165
	
2166
		assertResults(
2167
			"eq[POTENTIAL_METHOD_DECLARATION]{eq, LCompletionMethodDeclaration2;, ()V, eq, null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n" +
2168
			"eqFoo[METHOD_DECLARATION]{public int eqFoo(int a, Object b), LCompletionSuperClass;, (ILjava.lang.Object;)I, eqFoo, (a, b), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n" +
2169
			"equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED)+"}",
2170
			requestor.getResults());
2171
	} finally {
2172
		if(superClass != null) {
2173
			superClass.discardWorkingCopy();
2174
		}
2175
	}
2176
}
2177
2178
/**
2179
 * Completion should not propose declarations of method already locally implemented
2180
 */
2181
public void testCompletionMethodDeclaration3() throws JavaModelException {
2182
	ICompilationUnit superClass = null;
2183
	try {
2184
		superClass = getWorkingCopy(
2185
	            "/Completion/src/CompletionSuperClass.java",
2186
	            "public class CompletionSuperClass{\n" +
2187
	            "	public class Inner {}\n" +
2188
	            "	public int eqFoo(int a,Object b){\n" +
2189
	            "		return 1;\n" +
2190
	            "	}\n" +
2191
	            "}");
2192
		
2193
		this.wc = getWorkingCopy(
2194
	            "/Completion/src/CompletionMethodDeclaration3.java",
2195
	            "public class CompletionMethodDeclaration3 extends CompletionSuperClass {\n" +
2196
	            "	eq\n" +
2197
	            "	\n" +
2198
	            "	public int eqFoo(int a,Object b){\n" +
2199
	            "		return 1;\n" +
2200
	            "	}\n" +
2201
	            "}");
2202
	    
2203
	    
2204
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2205
	    String str = this.wc.getSource();
2206
	    String completeBehind = "eq";
2207
	    int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
2208
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2209
	
2210
		assertResults(
2211
			"eq[POTENTIAL_METHOD_DECLARATION]{eq, LCompletionMethodDeclaration3;, ()V, eq, null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n" +
2212
			"equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED)+"}",
2213
			requestor.getResults());
2214
	} finally {
2215
		if(superClass != null) {
2216
			superClass.discardWorkingCopy();
2217
		}
2218
	}
2219
}
2118
}
2220
2119
2221
2120
2222
public void testCompletionMethodDeclaration4() throws JavaModelException {
2121
public void testCompletionBasicAnonymousDeclaration1() throws JavaModelException {
2223
	ICompilationUnit superClass = null;
2122
	CompletionResult result = complete(
2224
	try {
2123
			"/Completion/src3/test0000/CompletionBasicCompletionContext.java",
2225
		superClass = getWorkingCopy(
2124
			"public class CompletionBasicAnonymousDeclaration1 {\n"+
2226
	            "/Completion/src/CompletionSuperInterface.java",
2125
			"	void foo() {\n"+
2227
	            "public interface CompletionSuperInterface{\n"+
2126
			"		new Object(\n"+
2228
	            "	public int eqFoo(int a,Object b);\n"+
2127
			"	}\n"+
2229
	            "}");
2128
			"}",
2230
		
2129
			"new Object(");
2231
		this.wc = getWorkingCopy(
2232
	            "/Completion/src/CompletionMethodDeclaration4.java",
2233
	            "public abstract class CompletionMethodDeclaration4 implements CompletionSuperInterface {\n"+
2234
	            "	eq\n"+
2235
	            "}");
2236
	    
2237
	    
2238
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2239
	    String str = this.wc.getSource();
2240
	    String completeBehind = "eq";
2241
	    int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
2242
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2243
	
2130
	
2244
		assertResults(
2131
	assertResults(
2245
			"eq[POTENTIAL_METHOD_DECLARATION]{eq, LCompletionMethodDeclaration4;, ()V, eq, null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n" +
2132
			"expectedTypesSignatures=null\n" +
2246
			"equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
2133
			"expectedTypesKeys=null",
2247
			"eqFoo[METHOD_DECLARATION]{public int eqFoo(int a, Object b), LCompletionSuperInterface;, (ILjava.lang.Object;)I, eqFoo, (a, b), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_ABSTRACT_METHOD + R_METHOD_OVERIDE+ R_NON_RESTRICTED)+"}",
2134
			result.context);
2248
			requestor.getResults());
2135
	
2249
	} finally {
2136
	assertResults(
2250
		if(superClass != null) {
2137
			"Object[ANONYMOUS_CLASS_DECLARATION]{, Ljava.lang.Object;, ()V, null, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
2251
			superClass.discardWorkingCopy();
2138
			"Object[METHOD_REF<CONSTRUCTOR>]{, Ljava.lang.Object;, ()V, Object, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}",
2252
		}
2139
			result.proposals);
2253
	}
2254
}
2140
}
2255
2141
2256
public void testCompletionMethodDeclaration5() throws JavaModelException {
2142
public void testCompletionBasicCompletionContext() throws JavaModelException {
2257
	ICompilationUnit superClass = null;
2143
	CompletionResult result = complete(
2258
	try {
2144
			"/Completion/src3/test0000/CompletionBasicCompletionContext.java",
2259
		superClass = getWorkingCopy(
2145
			"package test0000;\n" +
2260
	            "/Completion/src/CompletionSuperClass.java",
2146
			"public class CompletionBasicCompletionContext {\n" +
2261
	            "public class CompletionSuperClass{\n" +
2147
			"  void bar(String o) {\n" +
2262
	            "	public class Inner {}\n" +
2148
			"    String zzz = null; \n" + 
2263
	            "	public int eqFoo(int a,Object b){\n" +
2149
			"    o = zzz\n" + 
2264
	            "		return 1;\n" +
2150
			"  }\n" +
2265
	            "	}\n" +
2151
			"}",
2266
	            "}");
2152
			"zzz");
2267
		
2268
		this.wc = getWorkingCopy(
2269
	            "/Completion/src/CompletionMethodDeclaration5.java",
2270
	            "public class CompletionMethodDeclaration5 {\n" +
2271
	            "	public static void main(String[] args) {\n" +
2272
	            "		new CompletionSuperClass() {\n" +
2273
	            "	}\n" +
2274
	            "\n" +
2275
	            "}");
2276
	    
2277
	    
2278
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2279
	    String str = this.wc.getSource();
2280
	    String completeBehind = "new CompletionSuperClass() {";
2281
	    int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
2282
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2283
	
2153
	
2284
	    if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
2154
	assertResults(
2285
			assertResults(
2155
			"expectedTypesSignatures={Ljava.lang.String;}\n" +
2286
				"[POTENTIAL_METHOD_DECLARATION]{, LCompletionSuperClass;, ()V, , null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n" +
2156
			"expectedTypesKeys={Ljava/lang/String;}",
2287
				"clone[METHOD_DECLARATION]{protected Object clone() throws CloneNotSupportedException, Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
2157
			result.context);
2288
				"eqFoo[METHOD_DECLARATION]{public int eqFoo(int a, Object b), LCompletionSuperClass;, (ILjava.lang.Object;)I, eqFoo, (a, b), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
2158
	
2289
				"equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
2159
	assertResults(
2290
				"finalize[METHOD_DECLARATION]{protected void finalize() throws Throwable, Ljava.lang.Object;, ()V, finalize, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
2160
			"zzz[LOCAL_VARIABLE_REF]{zzz, null, Ljava.lang.String;, zzz, null, " + (R_DEFAULT + R_INTERESTING + R_CASE +  + R_EXACT_NAME + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
2291
				"hashCode[METHOD_DECLARATION]{public int hashCode(), Ljava.lang.Object;, ()I, hashCode, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
2161
			result.proposals);
2292
				"toString[METHOD_DECLARATION]{public String toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED)+ "}",
2293
				requestor.getResults());
2294
		} else {
2295
			assertResults(
2296
				"[POTENTIAL_METHOD_DECLARATION]{, LCompletionSuperClass;, ()V, , null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n" +
2297
				"CompletionMethodDeclaration5[TYPE_REF]{CompletionMethodDeclaration5, , LCompletionMethodDeclaration5;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
2298
				"clone[METHOD_DECLARATION]{protected Object clone() throws CloneNotSupportedException, Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
2299
				"eqFoo[METHOD_DECLARATION]{public int eqFoo(int a, Object b), LCompletionSuperClass;, (ILjava.lang.Object;)I, eqFoo, (a, b), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
2300
				"equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
2301
				"finalize[METHOD_DECLARATION]{protected void finalize() throws Throwable, Ljava.lang.Object;, ()V, finalize, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
2302
				"hashCode[METHOD_DECLARATION]{public int hashCode(), Ljava.lang.Object;, ()I, hashCode, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
2303
				"toString[METHOD_DECLARATION]{public String toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED)+ "}",
2304
				requestor.getResults());
2305
		}
2306
	} finally {
2307
		if(superClass != null) {
2308
			superClass.discardWorkingCopy();
2309
		}
2310
	}
2311
}
2162
}
2312
public void testCompletionMethodDeclaration6() throws JavaModelException {
2313
2163
2314
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2164
public void testCompletionBasicField1() throws JavaModelException {
2315
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMethodDeclaration6.java");
2165
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
2166
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBasicField1.java");
2316
2167
2317
	String str = cu.getSource();
2168
	String str = cu.getSource();
2318
	String completeBehind = "clon";
2169
	String completeBehind = "zzvar";
2319
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2170
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2320
	cu.codeComplete(cursorLocation, requestor);
2171
	cu.codeComplete(cursorLocation, requestor);
2321
2172
2322
	assertEquals(
2173
	assertResults(
2323
		"should have one completion", 
2174
			"zzvarzz[FIELD_REF]{zzvarzz, LCompletionBasicField1;, I, zzvarzz, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
2324
		"element:CloneNotSupportedException    completion:CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
2175
			requestor.getResults());
2325
		requestor.getResults());
2326
}
2176
}
2327
2177
2328
public void testCompletionMethodDeclaration7() throws JavaModelException {
2178
public void testCompletionBasicKeyword1() throws JavaModelException {
2329
2179
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
2330
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2180
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBasicKeyword1.java");
2331
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMethodDeclaration7.java");
2332
2181
2333
	String str = cu.getSource();
2182
	String str = cu.getSource();
2334
	String completeBehind = "clon";
2183
	String completeBehind = "whil";
2335
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2184
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2336
	cu.codeComplete(cursorLocation, requestor);
2185
	cu.codeComplete(cursorLocation, requestor);
2337
2186
2338
	assertEquals(
2187
	assertResults(
2339
		"should have one completion", 
2188
			"while[KEYWORD]{while, null, null, while, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
2340
		"element:CloneNotSupportedException    completion:CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2189
			requestor.getResults());
2341
		"element:clone    completion:protected Object clone() throws CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
2342
		requestor.getResults());
2343
}
2190
}
2344
2191
2345
public void testCompletionMethodDeclaration8() throws JavaModelException {
2192
public void testCompletionBasicLocalVariable1() throws JavaModelException {
2346
2193
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
2347
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2194
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBasicLocalVariable1.java");
2348
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMethodDeclaration8.java");
2349
2195
2350
	String str = cu.getSource();
2196
	String str = cu.getSource();
2351
	String completeBehind = "clon";
2197
	String completeBehind = "zzvar";
2352
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2198
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2353
	cu.codeComplete(cursorLocation, requestor);
2199
	cu.codeComplete(cursorLocation, requestor);
2354
2200
2355
	assertEquals(
2201
	assertResults(
2356
		"should have one completion", 
2202
			"zzvarzz[LOCAL_VARIABLE_REF]{zzvarzz, null, I, zzvarzz, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
2357
		"element:CloneNotSupportedException    completion:CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2203
			requestor.getResults());
2358
		"element:clone    completion:protected Object clone() throws CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
2359
		requestor.getResults());
2360
}
2204
}
2361
2205
2362
public void testCompletionMethodDeclaration9() throws JavaModelException {
2206
public void testCompletionBasicMethod1() throws JavaModelException {
2363
2207
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
2364
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2208
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBasicMethod1.java");
2365
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMethodDeclaration9.java");
2366
2209
2367
	String str = cu.getSource();
2210
	String str = cu.getSource();
2368
	String completeBehind = "clon";
2211
	String completeBehind = "zzfo";
2369
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2212
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2370
	cu.codeComplete(cursorLocation, requestor);
2213
	cu.codeComplete(cursorLocation, requestor);
2371
2214
2372
	assertEquals(
2215
	assertResults(
2373
		"should have one completion", 
2216
			"zzfoo[METHOD_REF]{zzfoo(), LCompletionBasicMethod1;, ()V, zzfoo, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
2374
		"element:CloneNotSupportedException    completion:CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2217
			requestor.getResults());
2375
		"element:clone    completion:protected Object clone() throws CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
2376
		requestor.getResults());
2377
}
2218
}
2378
2219
2379
public void testCompletionMethodDeclaration10() throws JavaModelException {
2220
public void testCompletionBasicMethodDeclaration1() throws JavaModelException {
2380
2221
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
2381
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2222
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBasicMethodDeclaration1.java");
2382
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMethodDeclaration10.java");
2383
2223
2384
	String str = cu.getSource();
2224
	String str = cu.getSource();
2385
	String completeBehind = "clon";
2225
	String completeBehind = "equals";
2386
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2226
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2387
	cu.codeComplete(cursorLocation, requestor);
2227
	cu.codeComplete(cursorLocation, requestor);
2388
2228
2389
	assertEquals(
2390
		"should have one completion", 
2391
		"element:CloneNotSupportedException    completion:CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2392
		"element:clone    completion:protected Object clone() throws CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
2393
		requestor.getResults());
2394
}
2395
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=80063
2396
public void testCompletionMethodDeclaration11() throws JavaModelException {
2397
	this.wc = getWorkingCopy(
2398
			"/Completion/src/test/CompletionMethodDeclaration11.java",
2399
			"package test;\n" +
2400
			"public class CompletionMethodDeclaration11 {\n" +
2401
			"  private void foo() {\n" +
2402
			"  }\n" +
2403
			"}\n" +
2404
			"class CompletionMethodDeclaration11_2 extends CompletionMethodDeclaration11 {\n" +
2405
			"  fo\n" +
2406
			"}");
2407
	
2408
	
2409
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2410
	String str = this.wc.getSource();
2411
	String completeBehind = "fo";
2412
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2413
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2414
2415
	assertResults(
2229
	assertResults(
2416
			"fo[POTENTIAL_METHOD_DECLARATION]{fo, Ltest.CompletionMethodDeclaration11_2;, ()V, fo, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}",
2230
			"equals[POTENTIAL_METHOD_DECLARATION]{equals, LCompletionBasicMethodDeclaration1;, ()V, equals, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
2231
			"equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_EXACT_NAME + R_NON_RESTRICTED) + "}",
2417
			requestor.getResults());
2232
			requestor.getResults());
2418
}
2233
}
2419
public void testCompletionMethodDeclaration12() throws JavaModelException {
2420
    this.wc = getWorkingCopy(
2421
            "/Completion/src/test/CompletionMethodDeclaration12.java",
2422
            "package test;\n" +
2423
            "public class CompletionMethodDeclaration12 {\n" +
2424
            "  public void foo() {\n" +
2425
            "  }\n" +
2426
            "}\n" +
2427
            "class CompletionMethodDeclaration12_2 extends CompletionMethodDeclaration12{\n" +
2428
            "  public final void foo() {\n" +
2429
            "  }\n" +
2430
            "}\n" +
2431
            "class CompletionMethodDeclaration12_3 extends CompletionMethodDeclaration12_2 {\n" +
2432
            "  fo\n" +
2433
            "}");
2434
    
2435
    
2436
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2437
    String str = this.wc.getSource();
2438
    String completeBehind = "fo";
2439
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2440
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2441
2234
2442
    assertResults(
2235
public void testCompletionBasicPackage1() throws JavaModelException {
2443
            "fo[POTENTIAL_METHOD_DECLARATION]{fo, Ltest.CompletionMethodDeclaration12_3;, ()V, fo, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}",
2236
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
2444
            requestor.getResults());
2237
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBasicPackage1.java");
2445
}
2446
public void testCompletionFieldName() throws JavaModelException {
2447
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2448
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFieldName.java");
2449
2238
2450
	String str = cu.getSource();
2239
	String str = cu.getSource();
2451
	String completeBehind = "ClassWithComplexName ";
2240
	String completeBehind = "java.lan";
2452
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2241
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
2453
	cu.codeComplete(cursorLocation, requestor);
2242
	cu.codeComplete(cursorLocation, requestor);
2454
2243
2455
	assertEquals(
2244
	assertResults(
2456
		"should have two completions",
2245
			"java.lang[PACKAGE_REF]{java.lang, java.lang, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_QUALIFIED + R_NON_RESTRICTED) + "}",
2457
		"element:classWithComplexName    completion:classWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
2246
			requestor.getResults());
2458
		"element:complexName2    completion:complexName2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
2459
		"element:name    completion:name    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
2460
		"element:withComplexName    completion:withComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
2461
		requestor.getResults());
2462
}
2247
}
2463
2248
2464
2249
2465
public void testCompletionLocalName() throws JavaModelException {
2250
public void testCompletionBasicPotentialMethodDeclaration1() throws JavaModelException {
2466
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2251
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
2467
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionLocalName.java");
2252
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBasicPotentialMethodDeclaration1.java");
2468
2253
2469
	String str = cu.getSource();
2254
	String str = cu.getSource();
2470
	String completeBehind = "ClassWithComplexName ";
2255
	String completeBehind = "zzpot";
2471
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2256
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2472
	cu.codeComplete(cursorLocation, requestor);
2257
	cu.codeComplete(cursorLocation, requestor);
2473
2258
2474
	assertEquals(
2259
	assertResults(
2475
		"should have two completions", 
2260
			"zzpot[POTENTIAL_METHOD_DECLARATION]{zzpot, LCompletionBasicPotentialMethodDeclaration1;, ()V, zzpot, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}",
2476
		"element:classWithComplexName    completion:classWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
2261
			requestor.getResults());
2477
		"element:complexName2    completion:complexName2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
2478
		"element:name    completion:name    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
2479
		"element:withComplexName    completion:withComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
2480
		requestor.getResults());
2481
}
2262
}
2482
2263
2483
2264
2484
public void testCompletionArgumentName() throws JavaModelException {
2265
public void testCompletionBasicType1() throws JavaModelException {
2485
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2266
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
2486
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionArgumentName.java");
2267
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBasicType1.java");
2487
2268
2488
	String str = cu.getSource();
2269
	String str = cu.getSource();
2489
	String completeBehind = "ClassWithComplexName ";
2270
	String completeBehind = "Objec";
2490
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2271
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
2491
	cu.codeComplete(cursorLocation, requestor);
2272
	cu.codeComplete(cursorLocation, requestor);
2492
2273
2493
	assertEquals(
2274
	assertResults(
2494
		"should have two completions", 
2275
			"Object[TYPE_REF]{Object, java.lang, Ljava.lang.Object;, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
2495
		"element:classWithComplexName    completion:classWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
2276
			requestor.getResults());
2496
		"element:complexName2    completion:complexName2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
2497
		"element:name    completion:name    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
2498
		"element:withComplexName    completion:withComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
2499
		requestor.getResults());
2500
}
2277
}
2501
2278
2502
2279
public void testCompletionBasicVariableDeclaration1() throws JavaModelException {
2503
public void testCompletionCatchArgumentName() throws JavaModelException {
2504
	this.workingCopies = new ICompilationUnit[1];
2280
	this.workingCopies = new ICompilationUnit[1];
2505
	this.workingCopies[0] = getWorkingCopy(
2281
	this.workingCopies[0] = getWorkingCopy(
2506
		"/Completion/src/CompletionCatchArgumentName.java",
2282
		"/Completion/src/CompletionBasicVariableDeclaration1.java",
2507
		"public class CompletionCatchArgumentName {\n"+
2283
		"public class CompletionBasicVariableDeclaration1 {\n"+
2508
		"	public void foo(){\n"+
2284
		"	public Object obj;\n"+
2509
		"		try{\n"+
2510
		"			\n"+
2511
		"		} catch (Exception ex)\n"+
2512
		"	}\n"+
2513
		"}\n");
2285
		"}\n");
2514
	
2286
	
2515
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2287
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2516
	String str = this.workingCopies[0].getSource();
2288
	String str = this.workingCopies[0].getSource();
2517
	String completeBehind = "ex";
2289
	String completeBehind = "obj";
2518
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2290
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2519
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2291
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2520
	
2292
	
2521
	assertResults(
2293
	assertResults(
2522
		"exception[VARIABLE_DECLARATION]{exception, null, Ljava.lang.Exception;, exception, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED) + "}",
2294
		"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED) + "}",
2523
		requestor.getResults());
2295
		requestor.getResults());
2524
}
2296
}
2525
2297
2298
public void testCompletionBinaryOperator1() throws JavaModelException {
2299
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2300
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBinaryOperator1.java");
2526
2301
2527
public void testCompletionAmbiguousType() throws JavaModelException {
2302
		String str = cu.getSource();
2528
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2303
		String completeBehind = "var";
2529
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAmbiguousType.java");
2304
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2305
		cu.codeComplete(cursorLocation, requestor);
2306
2307
		assertEquals(
2308
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
2309
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2310
			"element:var3    completion:var3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2311
			"element:var4    completion:var4    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE+ R_NON_RESTRICTED),
2312
			requestor.getResults());
2313
}
2314
2315
public void testCompletionBinaryOperator2() throws JavaModelException {
2316
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2317
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBinaryOperator2.java");
2318
2319
		String str = cu.getSource();
2320
		String completeBehind = "var";
2321
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2322
		cu.codeComplete(cursorLocation, requestor);
2323
2324
		assertEquals(
2325
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2326
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
2327
			"element:var3    completion:var3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
2328
			requestor.getResults());
2329
}
2330
2331
2332
public void testCompletionBinaryOperator3() throws JavaModelException {
2333
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2334
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBinaryOperator3.java");
2335
2336
		String str = cu.getSource();
2337
		String completeBehind = "var";
2338
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2339
		cu.codeComplete(cursorLocation, requestor);
2340
2341
		assertEquals(
2342
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
2343
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2344
			"element:var3    completion:var3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
2345
			requestor.getResults());
2346
}
2530
2347
2348
2349
/**
2350
 * Ensures that completion is not case sensitive
2351
 */
2352
public void testCompletionCaseInsensitive() throws JavaModelException {
2353
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2354
	ICompilationUnit cu = getCompilationUnit("Completion", "src", "", "CompletionCaseInsensitive.java");
2355
	
2531
	String str = cu.getSource();
2356
	String str = cu.getSource();
2532
	String completeBehind = "ABC";
2357
	String completeBehind = "Fiel";
2533
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2358
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2534
	cu.codeComplete(cursorLocation, requestor);
2359
	cu.codeComplete(cursorLocation, requestor);
2360
	
2361
	assertEquals("should have one class",
2362
		"element:field    completion:field    relevance:"+(R_DEFAULT + R_INTERESTING + R_NON_STATIC + R_NON_RESTRICTED),
2363
		requestor.getResults());
2364
}
2365
2366
2367
/**
2368
 * Complete a package in a case insensitive way
2369
 */
2370
public void testCompletionCaseInsensitivePackage() throws JavaModelException {
2371
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2372
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionCaseInsensitivePackage.java");
2535
2373
2374
	String str = cu.getSource();
2375
	String completeBehind = "Ja";
2376
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
2377
	
2378
	cu.codeComplete(cursorLocation, requestor);
2536
	assertEquals(
2379
	assertEquals(
2537
		"should have two completions", 
2380
		"should have package completions",
2538
		"element:ABC    completion:p1.ABC    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"\n" +
2381
		"element:jarpack1    completion:jarpack1    relevance:"+(R_DEFAULT + R_INTERESTING+ R_NON_RESTRICTED)+"\n" +
2539
		"element:ABC    completion:p2.ABC    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME+ R_NON_RESTRICTED),
2382
		"element:jarpack2    completion:jarpack2    relevance:"+(R_DEFAULT + R_INTERESTING+ R_NON_RESTRICTED)+"\n" +
2383
		"element:java    completion:java    relevance:"+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"\n" +
2384
		"element:java.io    completion:java.io    relevance:"+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"\n" +
2385
		"element:java.lang    completion:java.lang    relevance:"+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED),
2540
		requestor.getResults());
2386
		requestor.getResults());
2541
}
2387
}
2542
2388
2543
2389
2544
public void testCompletionAmbiguousType2() throws JavaModelException {
2390
public void testCompletionCastIsParent1() throws JavaModelException {
2545
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2391
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2546
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAmbiguousType2.java");
2392
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionCastIsParent1.java");
2547
2393
2548
	String str = cu.getSource();
2394
	String str = cu.getSource();
2549
	String completeBehind = "ABC";
2395
	String completeBehind = "zz";
2550
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2396
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2551
	cu.codeComplete(cursorLocation, requestor);
2397
	cu.codeComplete(cursorLocation, requestor);
2552
2398
2553
	assertEquals(
2399
	assertEquals(
2554
		"should have two completions", 
2400
		"element:zz00    completion:zz00    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2555
		"element:ABC    completion:ABC    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2401
		"element:zz00M    completion:zz00M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2556
		"element:ABC    completion:p2.ABC    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME+ R_NON_RESTRICTED),
2402
		"element:zz01    completion:zz01    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2403
		"element:zz01M    completion:zz01M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2404
		"element:zz02    completion:zz02    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2405
		"element:zz02M    completion:zz02M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2406
		"element:zz10    completion:zz10    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2407
		"element:zz10M    completion:zz10M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2408
		"element:zz11    completion:zz11    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2409
		"element:zz11M    completion:zz11M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2410
		"element:zz12    completion:zz12    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2411
		"element:zz12M    completion:zz12M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2412
		"element:zz20    completion:zz20    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2413
		"element:zz20M    completion:zz20M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2414
		"element:zz21    completion:zz21    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2415
		"element:zz21M    completion:zz21M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2416
		"element:zz22    completion:zz22    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2417
		"element:zz22M    completion:zz22M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2418
		"element:zzOb    completion:zzOb    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2419
		"element:zzObM    completion:zzObM()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
2557
		requestor.getResults());
2420
		requestor.getResults());
2558
}
2421
}
2559
2422
2560
2423
2561
public void testCompletionWithBinaryFolder() throws JavaModelException {
2424
public void testCompletionCastIsParent2() throws JavaModelException {
2562
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2425
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2563
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionWithBinaryFolder.java");
2426
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionCastIsParent2.java");
2564
2427
2565
	String str = cu.getSource();
2428
	String str = cu.getSource();
2566
	String completeBehind = "My";
2429
	String completeBehind = "xx";
2567
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2430
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2568
	cu.codeComplete(cursorLocation, requestor);
2431
	cu.codeComplete(cursorLocation, requestor);
2569
2432
2570
	assertEquals(
2433
	assertEquals(
2571
		"should have two completions",
2434
		"element:XX00    completion:XX00    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2572
		"element:MyClass    completion:MyClass    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2435
		"element:XX01    completion:XX01    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2573
		"element:mypackage    completion:mypackage    relevance:"+(R_DEFAULT + R_INTERESTING+ R_NON_RESTRICTED),
2436
		"element:XX02    completion:XX02    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2437
		"element:XX10    completion:XX10    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2438
		"element:XX11    completion:XX11    relevance:"+(R_DEFAULT + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2439
		"element:XX12    completion:XX12    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2440
		"element:XX20    completion:XX20    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2441
		"element:XX21    completion:XX21    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2442
		"element:XX22    completion:XX22    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
2574
		requestor.getResults());
2443
		requestor.getResults());
2575
}
2444
}
2576
2445
2577
2446
public void testCompletionCatchArgumentName() throws JavaModelException {
2578
public void testCompletionVariableNameOfArray1() throws JavaModelException {
2579
	this.workingCopies = new ICompilationUnit[1];
2447
	this.workingCopies = new ICompilationUnit[1];
2580
	this.workingCopies[0] = getWorkingCopy(
2448
	this.workingCopies[0] = getWorkingCopy(
2581
		"/Completion/src/CompletionVariableNameOfArray1.java",
2449
		"/Completion/src/CompletionCatchArgumentName.java",
2582
		"public class CompletionVariableNameOfArray1 {\n"+
2450
		"public class CompletionCatchArgumentName {\n"+
2583
		"	Object[] ob\n"+
2451
		"	public void foo(){\n"+
2452
		"		try{\n"+
2453
		"			\n"+
2454
		"		} catch (Exception ex)\n"+
2455
		"	}\n"+
2584
		"}\n");
2456
		"}\n");
2585
	
2457
	
2586
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2458
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2587
	String str = this.workingCopies[0].getSource();
2459
	String str = this.workingCopies[0].getSource();
2588
	String completeBehind = "ob";
2460
	String completeBehind = "ex";
2589
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2461
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2590
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2462
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2591
	
2463
	
2592
	assertResults(
2464
	assertResults(
2593
		"objects[VARIABLE_DECLARATION]{objects, null, [Ljava.lang.Object;, objects, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED) + "}",
2465
		"exception[VARIABLE_DECLARATION]{exception, null, Ljava.lang.Exception;, exception, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED) + "}",
2594
		requestor.getResults());
2466
		requestor.getResults());
2595
}
2467
}
2596
2468
2597
2469
public void testCompletionCatchArgumentName2() throws JavaModelException {
2598
public void testCompletionVariableNameOfArray2() throws JavaModelException {
2470
	Hashtable options = JavaCore.getOptions();
2599
	this.workingCopies = new ICompilationUnit[1];
2600
	this.workingCopies[0] = getWorkingCopy(
2601
		"/Completion/src/CompletionVariableNameOfArray2.java",
2602
		"public class CompletionVariableNameOfArray2 {\n"+
2603
		"	Class[] cl\n"+
2604
		"}\n");
2605
	
2471
	
2606
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2472
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_ARGUMENT_PREFIXES);
2607
	String str = this.workingCopies[0].getSource();
2473
	options.put(JavaCore.CODEASSIST_ARGUMENT_PREFIXES,"arg"); //$NON-NLS-1$
2608
	String completeBehind = "cl";
2474
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
2609
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2475
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"loc"); //$NON-NLS-1$
2610
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2611
	
2476
	
2612
	assertResults(
2477
	JavaCore.setOptions(options);
2613
		"classes[VARIABLE_DECLARATION]{classes, null, [Ljava.lang.Class;, classes, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED) + "}",
2478
	
2614
		requestor.getResults());
2479
	try {
2480
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2481
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionCatchArgumentName2.java");
2482
	
2483
		String str = cu.getSource();
2484
		String completeBehind = "Exception ";
2485
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2486
		cu.codeComplete(cursorLocation, requestor);
2487
	
2488
		assertEquals(
2489
			"element:exception    completion:exception    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
2490
			"element:locException    completion:locException    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX+ R_NON_RESTRICTED),
2491
			requestor.getResults());
2492
	} finally {
2493
		options.put(JavaCore.CODEASSIST_ARGUMENT_PREFIXES,argumentPrefixPreviousValue);
2494
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,localPrefixPreviousValue);
2495
		JavaCore.setOptions(options);
2496
	}
2615
}
2497
}
2616
2498
2499
public void testCompletionClassLiteralAfterAnonymousType1() throws JavaModelException {
2500
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2501
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionClassLiteralAfterAnonymousType1.java");
2617
2502
2618
public void testCompletionVariableNameOfArray3() throws JavaModelException {
2503
	String str = cu.getSource();
2619
	this.workingCopies = new ICompilationUnit[1];
2504
	String completeBehind = "double.";
2620
	this.workingCopies[0] = getWorkingCopy(
2621
		"/Completion/src/CompletionVariableNameOfArray3.java",
2622
		"public class CompletionVariableNameOfArray3 {\n"+
2623
		"	Object[][] ob\n"+
2624
		"}\n");
2625
	
2626
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2627
	String str = this.workingCopies[0].getSource();
2628
	String completeBehind = "ob";
2629
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2505
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2630
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2506
	cu.codeComplete(cursorLocation, requestor);
2631
	
2507
2632
	assertResults(
2508
	assertEquals(
2633
		"objects[VARIABLE_DECLARATION]{objects, null, [[Ljava.lang.Object;, objects, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED) + "}",
2509
		"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED),
2634
		requestor.getResults());
2510
		requestor.getResults());
2635
}
2511
}
2636
2512
2513
public void testCompletionConditionalExpression1() throws JavaModelException {
2514
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2515
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionConditionalExpression1.java");
2637
2516
2638
public void testCompletionVariableNameOfArray4() throws JavaModelException {
2517
		String str = cu.getSource();
2639
	this.workingCopies = new ICompilationUnit[1];
2518
		String completeBehind = "var";
2640
	this.workingCopies[0] = getWorkingCopy(
2519
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2641
		"/Completion/src/CompletionVariableNameOfArray4.java",
2520
		cu.codeComplete(cursorLocation, requestor);
2642
		"public class CompletionVariableNameOfArray4 {\n"+
2521
2643
		"	Objectz[] ob\n"+
2522
		assertEquals(
2644
		"}\n");
2523
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
2645
	
2524
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2646
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2525
			"element:var3    completion:var3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2647
	String str = this.workingCopies[0].getSource();
2526
			"element:var4    completion:var4    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
2648
	String completeBehind = "ob";
2527
			requestor.getResults());
2649
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2650
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
2651
	
2652
	assertResults(
2653
		"",
2654
		requestor.getResults());
2655
}
2528
}
2656
2529
2530
public void testCompletionConditionalExpression2() throws JavaModelException {
2531
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2532
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionConditionalExpression2.java");
2533
2534
		String str = cu.getSource();
2535
		String completeBehind = "var";
2536
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2537
		cu.codeComplete(cursorLocation, requestor);
2657
2538
2658
public void testCompletionVariableNameUnresolvedType() throws JavaModelException {
2539
		assertEquals(
2540
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
2541
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2542
			"element:var3    completion:var3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2543
			"element:var4    completion:var4    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
2544
			requestor.getResults());
2545
}
2546
2547
public void testCompletionConditionalExpression3() throws JavaModelException {
2548
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2549
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionConditionalExpression3.java");
2550
2551
		String str = cu.getSource();
2552
		String completeBehind = "var";
2553
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2554
		cu.codeComplete(cursorLocation, requestor);
2555
2556
		assertEquals(
2557
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
2558
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2559
			"element:var3    completion:var3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2560
			"element:var4    completion:var4    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
2561
			requestor.getResults());
2562
}
2563
2564
2565
/*
2566
* http://dev.eclipse.org/bugs/show_bug.cgi?id=24939
2567
*/
2568
public void testCompletionConstructorForAnonymousType() throws JavaModelException {
2659
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2569
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2660
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableNameUnresolvedType.java");
2570
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionConstructorForAnonymousType.java");
2661
2571
2662
	String str = cu.getSource();
2572
	String str = cu.getSource();
2663
	String completeBehind = "ob";
2573
	String completeBehind = "TypeWithConstructor(";
2664
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2574
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2665
	cu.codeComplete(cursorLocation, requestor);
2575
	cu.codeComplete(cursorLocation, requestor);
2666
2576
2667
	assertEquals(
2577
	assertEquals(
2668
		"should have no completion",
2578
		"element:TypeWithConstructor    completion:    relevance:"+(R_DEFAULT + R_INTERESTING+ R_NON_RESTRICTED),
2669
		"",
2670
		requestor.getResults());
2579
		requestor.getResults());
2671
}
2580
}
2672
2581
2582
public void testCompletionEmptyToken1() throws JavaModelException {
2583
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2584
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionEmptyToken1.java");
2673
2585
2674
public void testCompletionSameSuperClass() throws JavaModelException {
2586
	String str = cu.getSource();
2675
	this.wc = getWorkingCopy(
2587
	String completeBehind = "zz";
2676
            "/Completion/src/CompletionSameSuperClass.java",
2588
	// completion is just at start of 'zz'
2677
            "public class CompletionSameSuperClass extends A {\n" +
2589
	int cursorLocation = str.lastIndexOf(completeBehind);
2678
            "	class Inner extends A {\n" +
2590
	int start = cursorLocation;
2679
            "		void foo(int bar){\n" +
2591
	int end = start + 4;
2680
            "			bar\n" +
2592
	cu.codeComplete(cursorLocation, requestor);
2681
            "		}\n" +
2593
2682
            "	}	\n" +
2594
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
2683
            "}");
2595
		assertEquals(
2596
			"element:clone    completion:clone()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2597
			"element:equals    completion:equals()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2598
			"element:finalize    completion:finalize()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2599
			"element:foo    completion:foo()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2600
			"element:getClass    completion:getClass()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2601
			"element:hashCode    completion:hashCode()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2602
			"element:notify    completion:notify()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2603
			"element:notifyAll    completion:notifyAll()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2604
			"element:toString    completion:toString()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2605
			"element:wait    completion:wait()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2606
			"element:wait    completion:wait()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2607
			"element:wait    completion:wait()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2608
			"element:zzyy    completion:zzyy    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
2609
			requestor.getResultsWithPosition());
2610
	} else {
2611
		assertEquals(
2612
			"element:CompletionEmptyToken1    completion:CompletionEmptyToken1    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2613
			"element:clone    completion:clone()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2614
			"element:equals    completion:equals()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2615
			"element:finalize    completion:finalize()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2616
			"element:foo    completion:foo()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2617
			"element:getClass    completion:getClass()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2618
			"element:hashCode    completion:hashCode()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2619
			"element:notify    completion:notify()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2620
			"element:notifyAll    completion:notifyAll()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2621
			"element:toString    completion:toString()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2622
			"element:wait    completion:wait()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2623
			"element:wait    completion:wait()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2624
			"element:wait    completion:wait()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
2625
			"element:zzyy    completion:zzyy    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
2626
			requestor.getResultsWithPosition());
2627
	}
2628
}
2629
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=100808
2630
public void testCompletionEmptyToken2() throws JavaModelException {
2631
    this.wc = getWorkingCopy(
2632
            "/Completion/src/testCompletionEmptyToken2/Test.java",
2633
            "package testCompletionEmptyToken2.");
2684
    
2634
    
2635
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true);
2685
    
2636
    
2686
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2687
    String str = this.wc.getSource();
2637
    String str = this.wc.getSource();
2688
    String completeBehind = "bar";
2638
    String completeBehind = "testCompletionEmptyToken2.";
2689
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2639
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2690
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2640
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2691
2641
2642
    int start = str.lastIndexOf(completeBehind);
2643
    int end = start + completeBehind.length();
2644
    
2645
    assertResults(
2646
            "expectedTypesSignatures=null\n"+
2647
            "expectedTypesKeys=null",
2648
            requestor.getContext());
2649
    
2692
	assertResults(
2650
	assertResults(
2693
		"bar[FIELD_REF]{CompletionSameSuperClass.this.bar, LA;, I, bar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}\n"+
2651
            "testCompletionEmptyToken2[PACKAGE_REF]{testCompletionEmptyToken2, testCompletionEmptyToken2, null, null, null, ["+start+", "+end+"], " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}",
2694
		"bar[FIELD_REF]{this.bar, LA;, I, bar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}\n"+
2652
            requestor.getResults());
2695
		"bar[METHOD_REF]{CompletionSameSuperClass.this.bar(), LA;, ()V, bar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}\n"+
2696
		"bar[LOCAL_VARIABLE_REF]{bar, null, I, bar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
2697
		"bar[METHOD_REF]{bar(), LA;, ()V, bar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
2698
		requestor.getResults());
2699
}
2653
}
2700
2654
2701
public void testCompletionSuperType() throws JavaModelException {
2655
/*
2702
	ICompilationUnit superClass = null;
2656
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25221
2703
	try {
2657
*/
2704
		superClass = getWorkingCopy(
2658
public void testCompletionEmptyTypeName1() throws JavaModelException {
2705
	            "/Completion/src/CompletionSuperClass.java",
2659
	this.wc = getWorkingCopy(
2706
	            "public class CompletionSuperClass{\n" +
2660
            "/Completion/src/CompletionEmptyTypeName1.java",
2707
	            "	public class Inner {}\n" +
2661
            "public class CompletionEmptyTypeName1 {\n"+
2708
	            "	public int eqFoo(int a,Object b){\n" +
2662
           "	void foo() {\n"+
2709
	            "		return 1;\n" +
2663
           "		A a = new \n"+
2710
	            "	}\n" +
2664
           "	}\n"+
2711
	            "}");
2665
           "}");
2712
		
2666
    
2713
		this.wc = getWorkingCopy(
2667
    
2714
	            "/Completion/src/CompletionSuperType.java",
2668
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2715
	            "public class CompletionSuperType extends CompletionSuperClass.");
2669
    String str = this.wc.getSource();
2716
	    
2670
    String completeBehind = "new ";
2717
	    
2671
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2718
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2672
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2719
	    String str = this.wc.getSource();
2673
2720
	    String completeBehind = "CompletionSuperClass.";
2674
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
2721
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2722
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2723
	
2724
		assertResults(
2675
		assertResults(
2725
			"CompletionSuperClass.Inner[TYPE_REF]{Inner, , LCompletionSuperClass$Inner;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_CLASS+ R_NON_RESTRICTED)+"}",
2676
			"A[TYPE_REF]{A, , LA;, null, null, " +(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
2677
			requestor.getResults());
2678
	} else {
2679
		assertResults(
2680
			"CompletionEmptyTypeName1[TYPE_REF]{CompletionEmptyTypeName1, , LCompletionEmptyTypeName1;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED)+"}\n"+
2681
			"A[TYPE_REF]{A, , LA;, null, null, " +(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
2726
			requestor.getResults());
2682
			requestor.getResults());
2727
	} finally {
2728
		if(superClass != null) {
2729
			superClass.discardWorkingCopy();
2730
		}
2731
	}
2683
	}
2732
}
2684
}
2733
2685
2734
public void testCompletionSuperType2() throws JavaModelException {
2686
/*
2735
	ICompilationUnit superClass = null;
2687
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25221
2736
	ICompilationUnit superClass2 = null;
2688
*/
2737
	ICompilationUnit superInterface = null;
2689
public void testCompletionEmptyTypeName2() throws JavaModelException {
2738
	ICompilationUnit superInterface2 = null;
2690
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2691
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionEmptyTypeName2.java");
2692
2693
	String str = cu.getSource();
2694
	String completeBehind = " = ";
2695
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2696
	cu.codeComplete(cursorLocation, requestor);
2697
2698
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
2699
		assertEquals(
2700
			"element:a    completion:a    relevance:"+(R_DEFAULT + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2701
			"element:clone    completion:clone()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2702
			"element:equals    completion:equals()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2703
			"element:finalize    completion:finalize()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +		
2704
			"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2705
			"element:getClass    completion:getClass()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2706
			"element:hashCode    completion:hashCode()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2707
			"element:notify    completion:notify()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2708
			"element:notifyAll    completion:notifyAll()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2709
			"element:toString    completion:toString()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2710
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2711
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2712
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
2713
			requestor.getResults());
2714
	} else {
2715
		assertEquals(
2716
			"element:A    completion:A    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2717
			"element:CompletionEmptyTypeName2    completion:CompletionEmptyTypeName2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2718
			"element:a    completion:a    relevance:"+(R_DEFAULT + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2719
			"element:clone    completion:clone()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2720
			"element:equals    completion:equals()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2721
			"element:finalize    completion:finalize()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +		
2722
			"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2723
			"element:getClass    completion:getClass()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2724
			"element:hashCode    completion:hashCode()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2725
			"element:notify    completion:notify()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2726
			"element:notifyAll    completion:notifyAll()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2727
			"element:toString    completion:toString()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2728
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2729
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2730
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
2731
			requestor.getResults());
2732
	}
2733
}
2734
2735
/*
2736
* http://dev.eclipse.org/bugs/show_bug.cgi?id=41643
2737
*/
2738
public void testCompletionEmptyTypeName3() throws JavaModelException {
2739
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2740
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionEmptyTypeName3.java");
2741
2742
	String str = cu.getSource();
2743
	String completeBehind = " = ";
2744
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2745
	cu.codeComplete(cursorLocation, requestor);
2746
2747
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
2748
		assertEquals(
2749
			"element:clone    completion:clone()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2750
			"element:equals    completion:equals()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2751
			"element:finalize    completion:finalize()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +		
2752
			"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2753
			"element:getClass    completion:getClass()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2754
			"element:hashCode    completion:hashCode()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2755
			"element:notify    completion:notify()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2756
			"element:notifyAll    completion:notifyAll()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2757
			"element:toString    completion:toString()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2758
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2759
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2760
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2761
			"element:x    completion:x    relevance:"+(R_DEFAULT + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE+ R_NON_RESTRICTED),
2762
			requestor.getResults());
2763
	} else {
2764
		assertEquals(
2765
			"element:CompletionEmptyTypeName2    completion:CompletionEmptyTypeName2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
2766
			"element:CompletionEmptyTypeName3    completion:CompletionEmptyTypeName3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2767
			"element:CompletionEmptyTypeName3.CompletionEmptyTypeName3_1    completion:CompletionEmptyTypeName3_1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2768
			"element:CompletionEmptyTypeName3_2    completion:CompletionEmptyTypeName3_2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2769
			"element:clone    completion:clone()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2770
			"element:equals    completion:equals()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2771
			"element:finalize    completion:finalize()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +		
2772
			"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2773
			"element:getClass    completion:getClass()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2774
			"element:hashCode    completion:hashCode()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2775
			"element:notify    completion:notify()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2776
			"element:notifyAll    completion:notifyAll()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2777
			"element:toString    completion:toString()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2778
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2779
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2780
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2781
			"element:x    completion:x    relevance:"+(R_DEFAULT + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE+ R_NON_RESTRICTED),
2782
			requestor.getResults());
2783
	}
2784
}
2785
2786
/**
2787
 * Complete at end of file.
2788
 */
2789
public void testCompletionEndOfCompilationUnit() throws JavaModelException {
2790
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2791
	ICompilationUnit cu = getCompilationUnit("Completion", "src", "", "CompletionEndOfCompilationUnit.java");
2792
	cu.codeComplete(cu.getSourceRange().getOffset() + cu.getSourceRange().getLength(), requestor);
2793
	assertEquals(
2794
		"should have two methods of 'foo'", 
2795
		"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2796
		"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED),
2797
		requestor.getResults());	
2798
}
2799
/*
2800
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=66570
2801
 */
2802
public void testCompletionExactNameCaseInsensitive() throws JavaModelException {
2803
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2804
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionExactNameCaseInsensitive.java");
2805
2806
	String str = cu.getSource();
2807
	String completeBehind = "(compleTionexactnamecaseInsensitive";
2808
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
2809
	cu.codeComplete(cursorLocation, requestor);
2810
2811
	assertEquals(
2812
			"element:CompletionExactNameCaseInsensitive    completion:CompletionExactNameCaseInsensitive    relevance:"+(R_DEFAULT + R_INTERESTING + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+ "\n" +
2813
			"element:CompletionExactNameCaseInsensitivePlus    completion:CompletionExactNameCaseInsensitivePlus    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
2814
			requestor.getResults());
2815
}
2816
/*
2817
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25820
2818
*/
2819
public void testCompletionExpectedTypeIsNotValid() throws JavaModelException {
2820
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2821
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionExpectedTypeIsNotValid.java");
2822
2823
	String str = cu.getSource();
2824
	String completeBehind = "new U";
2825
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2826
	cu.codeComplete(cursorLocation, requestor);
2827
2828
	assertEquals(
2829
		"",
2830
		requestor.getResults());
2831
}
2832
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=95505
2833
public void testCompletionExpectedTypeOnEmptyToken1() throws JavaModelException {
2834
	ICompilationUnit aType = null;
2739
	try {
2835
	try {
2740
		superClass = getWorkingCopy(
2741
	            "/Completion/src/CompletionSuperClass.java",
2742
	            "public class CompletionSuperClass{\n" +
2743
	            "	public class Inner {}\n" +
2744
	            "	public int eqFoo(int a,Object b){\n" +
2745
	            "		return 1;\n" +
2746
	            "	}\n" +
2747
	            "}");
2748
		
2749
		superClass2 = getWorkingCopy(
2750
	            "/Completion/src/CompletionSuperClass2.java",
2751
	            "public class CompletionSuperClass2 {\n" +
2752
	            "	public class InnerClass {}\n" +
2753
	            "	public interface InnerInterface {}\n" +
2754
	            "}");
2755
		
2836
		
2756
		superInterface = getWorkingCopy(
2837
		aType = getWorkingCopy(
2757
	            "/Completion/src/CompletionSuperInterface.java",
2838
	            "/Completion/src/test/AType.java",
2758
	            "public interface CompletionSuperInterface{\n" +
2839
	            "package test;\n" +
2759
	            "	public int eqFoo(int a,Object b);\n" +
2840
	            "public class AType{\n"+
2760
	            "}");
2841
	            "}");
2761
		
2842
		
2762
		superInterface2 = getWorkingCopy(
2843
	    this.wc = getWorkingCopy(
2763
	            "/Completion/src/CompletionSuperInterface2.java",
2844
	            "/Completion/src/test/Test.java",
2764
	            "public interface CompletionSuperInterface2 {\n" +
2845
	            "package test;\n" +
2765
	            "	public class InnerClass {}\n" +
2846
	            "public class Test{\n"+
2766
	            "	public interface InnerInterface {}\n" +
2847
	            "  void foo() {\n"+
2848
	            "    AType a = new \n"+
2849
	            "  }\n"+
2767
	            "}");
2850
	            "}");
2768
		
2769
		this.wc = getWorkingCopy(
2770
	            "/Completion/src/CompletionSuperType2.java",
2771
	            "public class CompletionSuperType2 extends CompletionSuper");
2772
	    
2851
	    
2773
	    
2852
	    
2774
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2853
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2775
	    String str = this.wc.getSource();
2854
	    String str = this.wc.getSource();
2776
	    String completeBehind = "CompletionSuper";
2855
	    String completeBehind = "AType a = new ";
2777
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2856
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2778
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2857
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2779
	
2858
	
2780
		assertResults(
2859
	    assertResults(
2781
			"CompletionSuperClass[TYPE_REF]{CompletionSuperClass, , LCompletionSuperClass;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_CLASS + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2860
	            "expectedTypesSignatures={Ltest.AType;}\n"+
2782
			"CompletionSuperClass2[TYPE_REF]{CompletionSuperClass2, , LCompletionSuperClass2;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_CLASS + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
2861
	            "expectedTypesKeys={Ltest/AType;}",
2783
			requestor.getResults());
2862
	            requestor.getContext());
2863
	    if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
2864
			assertResults(
2865
		            "AType[TYPE_REF]{AType, test, Ltest.AType;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
2866
		            requestor.getResults());
2867
	    } else {
2868
	    	assertResults(
2869
		            "Test[TYPE_REF]{Test, test, Ltest.Test;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
2870
					"AType[TYPE_REF]{AType, test, Ltest.AType;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
2871
		            requestor.getResults());
2872
	    }
2784
	} finally {
2873
	} finally {
2785
		if(superClass != null) {
2874
		if(aType != null) {
2786
			superClass.discardWorkingCopy();
2875
			aType.discardWorkingCopy();
2787
		}
2788
		if(superClass2 != null) {
2789
			superClass2.discardWorkingCopy();
2790
		}
2791
		if(superInterface != null) {
2792
			superInterface.discardWorkingCopy();
2793
		}
2794
		if(superInterface2 != null) {
2795
			superInterface2.discardWorkingCopy();
2796
		}
2876
		}
2797
	}
2877
	}
2798
}
2878
}
2799
2879
2800
public void testCompletionSuperType3() throws JavaModelException {
2880
2801
	ICompilationUnit superClass = null;
2881
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=95505
2802
	ICompilationUnit superClass2 = null;
2882
public void testCompletionExpectedTypeOnEmptyToken3() throws JavaModelException {
2803
	ICompilationUnit superInterface = null;
2883
	ICompilationUnit aType = null;
2804
	ICompilationUnit superInterface2 = null;
2805
	try {
2884
	try {
2806
		superClass = getWorkingCopy(
2885
		aType = getWorkingCopy(
2807
	            "/Completion/src/CompletionSuperClass.java",
2886
	            "/Completion/src/test/AType.java",
2808
	            "public class CompletionSuperClass{\n" +
2887
	            "package test;\n" +
2809
	            "	public class Inner {}\n" +
2888
	            "public class AType{\n"+
2810
	            "	public int eqFoo(int a,Object b){\n" +
2811
	            "		return 1;\n" +
2812
	            "	}\n" +
2813
	            "}");
2814
		
2815
		superClass2 = getWorkingCopy(
2816
	            "/Completion/src/CompletionSuperClass2.java",
2817
	            "public class CompletionSuperClass2 {\n" +
2818
	            "	public class InnerClass {}\n" +
2819
	            "	public interface InnerInterface {}\n" +
2820
	            "}");
2821
		
2822
		superInterface = getWorkingCopy(
2823
	            "/Completion/src/CompletionSuperInterface.java",
2824
	            "public interface CompletionSuperInterface{\n" +
2825
	            "	public int eqFoo(int a,Object b);\n" +
2826
	            "}");
2889
	            "}");
2827
		
2890
		
2828
		superInterface2 = getWorkingCopy(
2891
	    this.wc = getWorkingCopy(
2829
	            "/Completion/src/CompletionSuperInterface2.java",
2892
	            "/Completion/src/test/Test.java",
2830
	            "public interface CompletionSuperInterface2 {\n" +
2893
	            "package test;\n" +
2831
	            "	public class InnerClass {}\n" +
2894
	            "public class Test{\n"+
2832
	            "	public interface InnerInterface {}\n" +
2895
	            "  void foo() {\n"+
2896
	            "    AType a = \n"+
2897
	            "  }\n"+
2833
	            "}");
2898
	            "}");
2834
		
2835
		this.wc = getWorkingCopy(
2836
	            "/Completion/src/CompletionSuperType3.java",
2837
	            "public class CompletionSuperType3 implements CompletionSuper");
2838
	    
2899
	    
2839
	    
2900
	    
2840
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2901
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2841
	    String str = this.wc.getSource();
2902
	    requestor.setIgnored(CompletionProposal.METHOD_REF, true);
2842
	    String completeBehind = "CompletionSuper";
2903
	    requestor.setIgnored(CompletionProposal.FIELD_REF, true);
2843
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2904
	    requestor.setIgnored(CompletionProposal.LOCAL_VARIABLE_REF, true);
2844
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2845
	
2846
		assertResults(
2847
			"CompletionSuperInterface[TYPE_REF]{CompletionSuperInterface, , LCompletionSuperInterface;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_INTERFACE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
2848
			"CompletionSuperInterface2[TYPE_REF]{CompletionSuperInterface2, , LCompletionSuperInterface2;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_INTERFACE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
2849
			requestor.getResults());
2850
	} finally {
2851
		if(superClass != null) {
2852
			superClass.discardWorkingCopy();
2853
		}
2854
		if(superClass2 != null) {
2855
			superClass2.discardWorkingCopy();
2856
		}
2857
		if(superInterface != null) {
2858
			superInterface.discardWorkingCopy();
2859
		}
2860
		if(superInterface2 != null) {
2861
			superInterface2.discardWorkingCopy();
2862
		}
2863
	}
2864
}
2865
2866
public void testCompletionSuperType4() throws JavaModelException {
2867
	ICompilationUnit superClass2 = null;
2868
	try {
2869
		superClass2 = getWorkingCopy(
2870
	            "/Completion/src/CompletionSuperClass2.java",
2871
	            "public class CompletionSuperClass2 {\n" +
2872
	            "	public class InnerClass {}\n" +
2873
	            "	public interface InnerInterface {}\n" +
2874
	            "}");
2875
		
2876
		this.wc = getWorkingCopy(
2877
	            "/Completion/src/CompletionSuperType4.java",
2878
	            "public class CompletionSuperType4 extends CompletionSuperClass2.Inner");
2879
	    
2880
	    
2905
	    
2881
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2882
	    String str = this.wc.getSource();
2906
	    String str = this.wc.getSource();
2883
	    String completeBehind = "CompletionSuperClass2.Inner";
2907
	    String completeBehind = "AType a = ";
2884
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2908
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2885
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2909
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2886
	
2910
	
2887
		assertResults(
2911
	    assertResults(
2888
			"CompletionSuperClass2.InnerInterface[TYPE_REF]{InnerInterface, , LCompletionSuperClass2$InnerInterface;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED)+ "}\n"+
2912
	            "expectedTypesSignatures={Ltest.AType;}\n"+
2889
			"CompletionSuperClass2.InnerClass[TYPE_REF]{InnerClass, , LCompletionSuperClass2$InnerClass;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_CLASS + R_NON_RESTRICTED)+"}",
2913
	            "expectedTypesKeys={Ltest/AType;}",
2890
			requestor.getResults());
2914
	            requestor.getContext());
2915
	    if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
2916
			assertResults(
2917
		            "",
2918
		            requestor.getResults());
2919
	    } else {
2920
	    	assertResults(
2921
		            "Test[TYPE_REF]{Test, test, Ltest.Test;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
2922
					"AType[TYPE_REF]{AType, test, Ltest.AType;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
2923
		            requestor.getResults());
2924
	    }
2891
	} finally {
2925
	} finally {
2892
		if(superClass2 != null) {
2926
		if(aType != null) {
2893
			superClass2.discardWorkingCopy();
2927
			aType.discardWorkingCopy();
2894
		}
2928
		}
2895
	}
2929
	}
2896
}
2930
}
2897
2931
2898
public void testCompletionSuperType5() throws JavaModelException {
2899
	ICompilationUnit superInterface2 = null;
2900
	try {
2901
		superInterface2 = getWorkingCopy(
2902
	            "/Completion/src/CompletionSuperInterface2.java",
2903
	            "public interface CompletionSuperInterface2 {\n" +
2904
	            "	public class InnerClass {}\n" +
2905
	            "	public interface InnerInterface {}\n" +
2906
	            "}");
2907
		
2908
		this.wc = getWorkingCopy(
2909
	            "/Completion/src/CompletionSuperType5.java",
2910
	            "public class CompletionSuperType5 implements CompletionSuperInterface2.Inner");
2911
	    
2912
	    
2913
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2914
	    String str = this.wc.getSource();
2915
	    String completeBehind = "CompletionSuperInterface2.Inner";
2916
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2917
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2918
	
2919
		assertResults(
2920
			"CompletionSuperInterface2.InnerClass[TYPE_REF]{InnerClass, , LCompletionSuperInterface2$InnerClass;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2921
			"CompletionSuperInterface2.InnerInterface[TYPE_REF]{InnerInterface, , LCompletionSuperInterface2$InnerInterface;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_INTERFACE+ R_NON_RESTRICTED)+"}",
2922
			requestor.getResults());
2923
	} finally {
2924
		if(superInterface2 != null) {
2925
			superInterface2.discardWorkingCopy();
2926
		}
2927
	}
2928
}
2929
2932
2930
public void testCompletionSuperType6() throws JavaModelException {
2933
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=95505
2931
	ICompilationUnit superClass = null;
2934
public void testCompletionExpectedTypeOnEmptyToken4() throws JavaModelException {
2932
	ICompilationUnit superClass2 = null;
2935
	ICompilationUnit aType = null;
2933
	ICompilationUnit superInterface = null;
2934
	ICompilationUnit superInterface2 = null;
2935
	try {
2936
	try {
2936
		superClass = getWorkingCopy(
2937
		aType = getWorkingCopy(
2937
	            "/Completion/src/CompletionSuperClass.java",
2938
	            "/Completion/src/test/AInterface.java",
2938
	            "public class CompletionSuperClass{\n" +
2939
	            "package test;\n" +
2939
	            "	public class Inner {}\n" +
2940
	            "public interface AInterface{\n"+
2940
	            "	public int eqFoo(int a,Object b){\n" +
2941
	            "		return 1;\n" +
2942
	            "	}\n" +
2943
	            "}");
2944
		
2945
		superClass2 = getWorkingCopy(
2946
	            "/Completion/src/CompletionSuperClass2.java",
2947
	            "public class CompletionSuperClass2 {\n" +
2948
	            "	public class InnerClass {}\n" +
2949
	            "	public interface InnerInterface {}\n" +
2950
	            "}");
2951
		
2952
		superInterface = getWorkingCopy(
2953
	            "/Completion/src/CompletionSuperInterface.java",
2954
	            "public interface CompletionSuperInterface{\n" +
2955
	            "	public int eqFoo(int a,Object b);\n" +
2956
	            "}");
2941
	            "}");
2957
		
2942
		
2958
		superInterface2 = getWorkingCopy(
2943
	    this.wc = getWorkingCopy(
2959
	            "/Completion/src/CompletionSuperInterface2.java",
2944
	            "/Completion/src/test/Test.java",
2960
	            "public interface CompletionSuperInterface2 {\n" +
2945
	            "package test;\n" +
2961
	            "	public class InnerClass {}\n" +
2946
	            "public class Test{\n"+
2962
	            "	public interface InnerInterface {}\n" +
2947
	            "  void foo() {\n"+
2948
	            "    AInterface a = new \n"+
2949
	            "  }\n"+
2963
	            "}");
2950
	            "}");
2964
		
2965
		this.wc = getWorkingCopy(
2966
	            "/Completion/src/CompletionSuperType6.java",
2967
	            "public interface CompletionSuperType6 extends CompletionSuper");
2968
	    
2951
	    
2969
	    
2952
	    
2970
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2953
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
2971
	    String str = this.wc.getSource();
2972
	    String completeBehind = "CompletionSuper";
2973
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2974
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2975
	
2976
		assertResults(
2977
				"CompletionSuperInterface[TYPE_REF]{CompletionSuperInterface, , LCompletionSuperInterface;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_INTERFACE + R_NON_RESTRICTED)+"}\n" +
2978
				"CompletionSuperInterface2[TYPE_REF]{CompletionSuperInterface2, , LCompletionSuperInterface2;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_INTERFACE+ R_NON_RESTRICTED)+"}",
2979
				requestor.getResults());
2980
	} finally {
2981
		if(superClass != null) {
2982
			superClass.discardWorkingCopy();
2983
		}
2984
		if(superClass2 != null) {
2985
			superClass2.discardWorkingCopy();
2986
		}
2987
		if(superInterface != null) {
2988
			superInterface.discardWorkingCopy();
2989
		}
2990
		if(superInterface2 != null) {
2991
			superInterface2.discardWorkingCopy();
2992
		}
2993
	}
2994
}
2995
2996
public void testCompletionSuperType7() throws JavaModelException {
2997
	ICompilationUnit superClass2 = null;
2998
	try {
2999
		superClass2 = getWorkingCopy(
3000
	            "/Completion/src/CompletionSuperClass2.java",
3001
	            "public class CompletionSuperClass2 {\n" +
3002
	            "	public class InnerClass {}\n" +
3003
	            "	public interface InnerInterface {}\n" +
3004
	            "}");
3005
		
3006
		this.wc = getWorkingCopy(
3007
	            "/Completion/src/CompletionSuperType7.java",
3008
	            "public interface CompletionSuperType7 extends CompletionSuperClass2.Inner");
3009
	    
2954
	    
3010
	    
3011
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3012
	    String str = this.wc.getSource();
2955
	    String str = this.wc.getSource();
3013
	    String completeBehind = "CompletionSuperClass2.Inner";
2956
	    String completeBehind = "AInterface a = new ";
3014
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2957
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3015
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
2958
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3016
	
2959
	
3017
		assertResults(
2960
	    assertResults(
3018
			"CompletionSuperClass2.InnerClass[TYPE_REF]{InnerClass, , LCompletionSuperClass2$InnerClass;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2961
	            "expectedTypesSignatures={Ltest.AInterface;}\n"+
3019
			"CompletionSuperClass2.InnerInterface[TYPE_REF]{InnerInterface, , LCompletionSuperClass2$InnerInterface;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_INTERFACE+ R_NON_RESTRICTED)+"}",
2962
	            "expectedTypesKeys={Ltest/AInterface;}",
3020
			requestor.getResults());
2963
	            requestor.getContext());
2964
	    
2965
	    if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
2966
			assertResults(
2967
		            "AInterface[TYPE_REF]{AInterface, test, Ltest.AInterface;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
2968
		            requestor.getResults());
2969
	    } else {
2970
	    	assertResults(
2971
		            "Test[TYPE_REF]{Test, test, Ltest.Test;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
2972
					"AInterface[TYPE_REF]{AInterface, test, Ltest.AInterface;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
2973
		            requestor.getResults());
2974
	    }
3021
	} finally {
2975
	} finally {
3022
		if(superClass2 != null) {
2976
		if(aType != null) {
3023
			superClass2.discardWorkingCopy();
2977
			aType.discardWorkingCopy();
3024
		}
2978
		}
3025
	}
2979
	}
3026
}
2980
}
3027
2981
3028
public void testCompletionSuperType8() throws JavaModelException {
3029
	ICompilationUnit superInterface2 = null;
3030
	try {
3031
		superInterface2 = getWorkingCopy(
3032
	            "/Completion/src/CompletionSuperInterface2.java",
3033
	            "public interface CompletionSuperInterface2 {\n" +
3034
	            "	public class InnerClass {}\n" +
3035
	            "	public interface InnerInterface {}\n" +
3036
	            "}");
3037
		
3038
		this.wc = getWorkingCopy(
3039
	            "/Completion/src/CompletionSuperType8.java",
3040
	            "public interface CompletionSuperType8 extends CompletionSuperInterface2.Inner");
3041
	    
3042
	    
3043
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3044
	    String str = this.wc.getSource();
3045
	    String completeBehind = "CompletionSuperInterface2.Inner";
3046
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3047
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3048
	
3049
		assertResults(
3050
			"CompletionSuperInterface2.InnerClass[TYPE_REF]{InnerClass, , LCompletionSuperInterface2$InnerClass;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
3051
			"CompletionSuperInterface2.InnerInterface[TYPE_REF]{InnerInterface, , LCompletionSuperInterface2$InnerInterface;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_INTERFACE+ R_NON_RESTRICTED)+"}",
3052
			requestor.getResults());
3053
	} finally {
3054
		if(superInterface2 != null) {
3055
			superInterface2.discardWorkingCopy();
3056
		}
3057
	}
3058
}
3059
2982
3060
public void testCompletionMethodThrowsClause() throws JavaModelException {
2983
public void testCompletionFieldInitializer1() throws JavaModelException {
3061
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
2984
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3062
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMethodThrowsClause.java");
2985
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFieldInitializer1.java");
3063
2986
3064
	String str = cu.getSource();
2987
	String str = cu.getSource();
3065
	String completeBehind = "Ex";
2988
	String completeBehind = "zz";
3066
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2989
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3067
	cu.codeComplete(cursorLocation, requestor);
2990
	cu.codeComplete(cursorLocation, requestor);
3068
2991
3069
	assertEquals(
2992
	assertEquals(
3070
		"element:Exception    completion:Exception    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXCEPTION + R_UNQUALIFIED+ R_NON_RESTRICTED),
2993
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2994
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2995
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2996
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
2997
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3071
		requestor.getResults());
2998
		requestor.getResults());
3072
}
2999
}
3073
3000
3074
public void testCompletionMethodThrowsClause2() throws JavaModelException {
3001
3002
public void testCompletionFieldInitializer2() throws JavaModelException {
3075
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3003
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3076
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMethodThrowsClause2.java");
3004
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFieldInitializer2.java");
3077
3005
3078
	String str = cu.getSource();
3006
	String str = cu.getSource();
3079
	String completeBehind = "Ex";
3007
	String completeBehind = "zz";
3080
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3008
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3081
	cu.codeComplete(cursorLocation, requestor);
3009
	cu.codeComplete(cursorLocation, requestor);
3082
3010
3083
	assertEquals(
3011
	assertEquals(
3084
		"element:Exception    completion:Exception    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXCEPTION+ R_NON_RESTRICTED),
3012
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3013
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3014
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3015
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3016
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3085
		requestor.getResults());
3017
		requestor.getResults());
3086
}
3018
}
3087
3019
3088
public void testCompletionThrowStatement() throws JavaModelException {
3020
3021
public void testCompletionFieldInitializer3() throws JavaModelException {
3089
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3022
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3090
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionThrowStatement.java");
3023
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFieldInitializer3.java");
3091
3024
3092
	String str = cu.getSource();
3025
	String str = cu.getSource();
3093
	String completeBehind = "Ex";
3026
	String completeBehind = "Objec";
3094
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3027
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3095
	cu.codeComplete(cursorLocation, requestor);
3028
	cu.codeComplete(cursorLocation, requestor);
3096
3029
3097
	assertEquals(
3030
	assertEquals(
3098
		"element:Exception    completion:Exception    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXCEPTION + R_UNQUALIFIED+ R_NON_RESTRICTED),
3031
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3099
		requestor.getResults());
3032
		requestor.getResults());
3100
}
3033
}
3101
3034
3102
public void testCompletionUnresolvedReturnType() throws JavaModelException {
3035
3036
public void testCompletionFieldInitializer4() throws JavaModelException {
3103
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3037
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3104
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionUnresolvedReturnType.java");
3038
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFieldInitializer4.java");
3105
3039
3106
	String str = cu.getSource();
3040
	String str = cu.getSource();
3107
	String completeBehind = "bar";
3041
	String completeBehind = "Objec";
3108
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3042
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3109
	cu.codeComplete(cursorLocation, requestor);
3043
	cu.codeComplete(cursorLocation, requestor);
3110
3044
3111
	assertEquals(
3045
	assertEquals(
3112
		"element:barPlus    completion:barPlus()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
3046
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3113
		requestor.getResults());
3047
		requestor.getResults());
3114
}
3048
}
3115
3049
3116
public void testCompletionUnresolvedParameterType() throws JavaModelException {
3050
3051
public void testCompletionFieldName() throws JavaModelException {
3117
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3052
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3118
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionUnresolvedParameterType.java");
3053
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFieldName.java");
3119
3054
3120
	String str = cu.getSource();
3055
	String str = cu.getSource();
3121
	String completeBehind = "bar";
3056
	String completeBehind = "ClassWithComplexName ";
3122
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3057
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3123
	cu.codeComplete(cursorLocation, requestor);
3058
	cu.codeComplete(cursorLocation, requestor);
3124
3059
3125
	assertEquals(
3060
	assertEquals(
3126
		"element:barPlus    completion:barPlus()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
3061
		"should have two completions",
3062
		"element:classWithComplexName    completion:classWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
3063
		"element:complexName2    completion:complexName2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
3064
		"element:name    completion:name    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
3065
		"element:withComplexName    completion:withComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
3127
		requestor.getResults());
3066
		requestor.getResults());
3128
}
3067
}
3129
3068
3130
public void testCompletionUnresolvedFieldType() throws JavaModelException {
3131
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3132
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionUnresolvedFieldType.java");
3133
3134
	String str = cu.getSource();
3135
	String completeBehind = "bar";
3136
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3137
	cu.codeComplete(cursorLocation, requestor);
3138
3069
3139
	assertEquals(
3070
/**
3140
		"element:barPlus    completion:barPlus()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
3071
 * Complete the type "A" from "new A".
3141
		requestor.getResults());
3142
}
3143
/*
3144
 * bug : http://dev.eclipse.org/bugs/show_bug.cgi?id=24440
3145
 */
3072
 */
3146
public void testCompletionUnresolvedEnclosingType() throws JavaModelException {
3073
public void testCompletionFindClass() throws JavaModelException {
3147
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3074
	this.wc = getWorkingCopy(
3148
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionUnresolvedEnclosingType.java");
3075
            "/Completion/src/CompletionFindClass.java",
3149
3076
            "public class CompletionFindClass {\n" +
3150
	String str = cu.getSource();
3077
            "	private    A[] a;\n" +
3151
	String completeBehind = "new ZZZ(";
3078
            "	public CompletionFindClass () {\n" +
3152
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3079
            "		this.a = new A\n" +
3153
	cu.codeComplete(cursorLocation, requestor);
3080
            "	}\n" +
3081
            "}");
3082
    
3083
    
3084
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3085
    String str = this.wc.getSource();
3086
    String completeBehind = "A";
3087
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3088
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3154
3089
3155
	assertTrue(
3090
    assertResults(
3156
		requestor.getResults().length() == 0);
3091
    		"ABC[TYPE_REF]{p1.ABC, p1, Lp1.ABC;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
3092
    		"ABC[TYPE_REF]{p2.ABC, p2, Lp2.ABC;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
3093
			"A3[TYPE_REF]{A3, , LA3;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
3094
			"A[TYPE_REF]{A, , LA;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
3095
            requestor.getResults());
3157
}
3096
}
3158
public void testCompletionReturnStatementIsParent1() throws JavaModelException {
3159
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3160
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionReturnStatementIsParent1.java");
3161
3162
	String str = cu.getSource();
3163
	String completeBehind = "zz";
3164
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3165
	cu.codeComplete(cursorLocation, requestor);
3166
3097
3167
	assertEquals(
3168
		"element:zz00    completion:zz00    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3169
		"element:zz00M    completion:zz00M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3170
		"element:zz01    completion:zz01    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3171
		"element:zz01M    completion:zz01M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3172
		"element:zz02    completion:zz02    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3173
		"element:zz02M    completion:zz02M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3174
		"element:zz10    completion:zz10    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3175
		"element:zz10M    completion:zz10M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3176
		"element:zz11    completion:zz11    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3177
		"element:zz11M    completion:zz11M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3178
		"element:zz12    completion:zz12    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3179
		"element:zz12M    completion:zz12M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3180
		"element:zz20    completion:zz20    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3181
		"element:zz20M    completion:zz20M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3182
		"element:zz21    completion:zz21    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3183
		"element:zz21M    completion:zz21M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3184
		"element:zz22    completion:zz22    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3185
		"element:zz22M    completion:zz22M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3186
		"element:zzOb    completion:zzOb    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3187
		"element:zzObM    completion:zzObM()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3188
		requestor.getResults());
3189
}
3190
3098
3191
public void testCompletionReturnStatementIsParent2() throws JavaModelException {
3099
/**
3100
 * The same type must be find only once
3101
 */
3102
public void testCompletionFindClass2() throws JavaModelException {
3192
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3103
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3193
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionReturnStatementIsParent2.java");
3104
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindClass2.java");
3194
3105
3195
	String str = cu.getSource();
3106
	String str = cu.getSource();
3196
	String completeBehind = "xx";
3107
	String completeBehind = "PX";
3197
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3108
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
3198
	cu.codeComplete(cursorLocation, requestor);
3109
	cu.codeComplete(cursorLocation, requestor);
3199
3110
3200
	assertEquals(
3111
	assertEquals(
3201
		"element:XX00    completion:XX00    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3112
		"should have one classe", 
3202
		"element:XX01    completion:XX01    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3113
		"element:PX    completion:pack1.PX    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_QUALIFIED + R_NON_RESTRICTED),
3203
		"element:XX02    completion:XX02    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3204
		"element:XX10    completion:XX10    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3205
		"element:XX11    completion:XX11    relevance:"+(R_DEFAULT + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3206
		"element:XX12    completion:XX12    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3207
		"element:XX20    completion:XX20    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3208
		"element:XX21    completion:XX21    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3209
		"element:XX22    completion:XX22    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
3210
		requestor.getResults());
3114
		requestor.getResults());
3211
}
3115
}
3212
3116
3213
public void testCompletionCastIsParent1() throws JavaModelException {
3117
3118
/**
3119
 * Complete the type "Default" in the default package example.
3120
 */
3121
public void testCompletionFindClassDefaultPackage() throws JavaModelException {
3214
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3122
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3215
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionCastIsParent1.java");
3123
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionDefaultPackage.java");
3216
3124
3217
	String str = cu.getSource();
3125
	String str = cu.getSource();
3218
	String completeBehind = "zz";
3126
	String completeBehind = "Def";
3219
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3127
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3220
	cu.codeComplete(cursorLocation, requestor);
3128
	cu.codeComplete(cursorLocation, requestor);
3221
3129
3222
	assertEquals(
3130
	assertEquals(
3223
		"element:zz00    completion:zz00    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3131
		"should have one class", 
3224
		"element:zz00M    completion:zz00M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3132
		"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
3225
		"element:zz01    completion:zz01    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3133
		requestor.getResults());	
3226
		"element:zz01M    completion:zz01M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3227
		"element:zz02    completion:zz02    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3228
		"element:zz02M    completion:zz02M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3229
		"element:zz10    completion:zz10    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3230
		"element:zz10M    completion:zz10M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3231
		"element:zz11    completion:zz11    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3232
		"element:zz11M    completion:zz11M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3233
		"element:zz12    completion:zz12    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3234
		"element:zz12M    completion:zz12M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3235
		"element:zz20    completion:zz20    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3236
		"element:zz20M    completion:zz20M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3237
		"element:zz21    completion:zz21    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3238
		"element:zz21M    completion:zz21M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3239
		"element:zz22    completion:zz22    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3240
		"element:zz22M    completion:zz22M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3241
		"element:zzOb    completion:zzOb    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3242
		"element:zzObM    completion:zzObM()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3243
		requestor.getResults());
3244
}
3134
}
3245
3135
3246
public void testCompletionCastIsParent2() throws JavaModelException {
3247
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3248
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionCastIsParent2.java");
3249
3136
3250
	String str = cu.getSource();
3137
/**
3251
	String completeBehind = "xx";
3138
 * Complete the constructor "CompletionFindConstructor" from "new CompletionFindConstructor(".
3252
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3139
 */
3253
	cu.codeComplete(cursorLocation, requestor);
3140
public void testCompletionFindConstructor() throws JavaModelException {
3141
	this.wc = getWorkingCopy(
3142
            "/Completion/src/CompletionFindConstructor.java",
3143
            "public class CompletionFindConstructor {\n"+
3144
            "	public CompletionFindConstructor (int i) {\n"+
3145
            "	}\n"+
3146
            "	publuc void foo(){\n"+
3147
            "		int x = 45;\n"+
3148
            "		new CompletionFindConstructor(i);\n"+
3149
            "	}\n"+
3150
            "}");
3151
    
3152
    
3153
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3154
    
3155
    String str = this.wc.getSource();
3156
    String completeBehind = "CompletionFindConstructor(";
3157
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3158
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3254
3159
3255
	assertEquals(
3160
    assertResults(
3256
		"element:XX00    completion:XX00    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3161
            "expectedTypesSignatures=null\n"+
3257
		"element:XX01    completion:XX01    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3162
            "expectedTypesKeys=null",
3258
		"element:XX02    completion:XX02    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3163
            requestor.getContext());
3259
		"element:XX10    completion:XX10    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3164
    
3260
		"element:XX11    completion:XX11    relevance:"+(R_DEFAULT + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3165
   assertResults(
3261
		"element:XX12    completion:XX12    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3166
			"CompletionFindConstructor[ANONYMOUS_CLASS_DECLARATION]{, LCompletionFindConstructor;, (I)V, null, (i), "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n" +
3262
		"element:XX20    completion:XX20    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3167
			"CompletionFindConstructor[METHOD_REF<CONSTRUCTOR>]{, LCompletionFindConstructor;, (I)V, CompletionFindConstructor, (i), "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}",
3263
		"element:XX21    completion:XX21    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3168
			requestor.getResults());
3264
		"element:XX22    completion:XX22    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
3265
		requestor.getResults());
3266
}
3169
}
3267
3170
3268
public void testCompletionMessageSendIsParent1() throws JavaModelException {
3269
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3270
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMessageSendIsParent1.java");
3271
3171
3272
	String str = cu.getSource();
3172
/**
3273
	String completeBehind = "zz";
3173
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78801
3274
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3174
 */
3275
	cu.codeComplete(cursorLocation, requestor);
3175
public void testCompletionFindConstructor2() throws JavaModelException {
3176
	this.wc = getWorkingCopy(
3177
            "/Completion/src/CompletionFindConstructor2.java",
3178
            "import zconstructors.*;\n"+
3179
            "public class CompletionFindConstructor2 {\n"+
3180
            "	Constructor2 c = new Constructor2();\n"+
3181
            "}");
3182
    
3183
    
3184
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3185
    
3186
    String str = this.wc.getSource();
3187
    String completeBehind = "Constructor2(";
3188
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3189
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3276
3190
3277
	assertEquals(
3191
    assertResults(
3278
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3192
            "expectedTypesSignatures=null\n"+
3279
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3193
            "expectedTypesKeys=null",
3280
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3194
            requestor.getContext());
3281
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3195
    
3282
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3196
    assertEquals(
3283
		requestor.getResults());
3197
			"Constructor2[ANONYMOUS_CLASS_DECLARATION]{, Lzconstructors.Constructor2;, ()V, null, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
3198
			"Constructor2[METHOD_REF<CONSTRUCTOR>]{, Lzconstructors.Constructor2;, ()V, Constructor2, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}",
3199
			requestor.getResults());
3284
}
3200
}
3285
3201
3286
public void testCompletionMessageSendIsParent2() throws JavaModelException {
3202
/**
3287
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3203
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78801
3288
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMessageSendIsParent2.java");
3204
 */
3205
public void testCompletionFindConstructor3() throws JavaModelException {
3206
	this.wc = getWorkingCopy(
3207
            "/Completion/src/CompletionFindConstructor3.java",
3208
            "import zconstructors.*;\n"+
3209
            "public class CompletionFindConstructor3 {\n"+
3210
            "	Constructor3 c = new Constructor3();\n"+
3211
            "}");
3212
    
3213
    
3214
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3215
    
3216
    String str = this.wc.getSource();
3217
    String completeBehind = "Constructor3(";
3218
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3219
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3289
3220
3290
	String str = cu.getSource();
3221
    assertResults(
3291
	String completeBehind = "zz";
3222
            "expectedTypesSignatures=null\n"+
3292
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3223
            "expectedTypesKeys=null",
3293
	cu.codeComplete(cursorLocation, requestor);
3224
            requestor.getContext());
3225
    
3226
    assertEquals(
3227
			"Constructor3[ANONYMOUS_CLASS_DECLARATION]{, Lzconstructors.Constructor3;, ()V, null, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
3228
			"Constructor3[METHOD_REF<CONSTRUCTOR>]{, Lzconstructors.Constructor3;, ()V, Constructor3, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}",
3229
			requestor.getResults());
3230
}
3231
3232
/**
3233
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78801
3234
 */
3235
public void testCompletionFindConstructor4() throws JavaModelException {
3236
	this.wc = getWorkingCopy(
3237
            "/Completion/src/CompletionFindConstructor4.java",
3238
            "import zconstructors.*;\n"+
3239
            "public class CompletionFindConstructor4 {\n"+
3240
            "	Constructor4 c = new Constructor4();\n"+
3241
            "}");
3242
    
3243
    
3244
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3245
    
3246
    String str = this.wc.getSource();
3247
    String completeBehind = "Constructor4(";
3248
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3249
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3294
3250
3251
    assertResults(
3252
            "expectedTypesSignatures=null\n"+
3253
            "expectedTypesKeys=null",
3254
            requestor.getContext());
3255
    
3295
	assertEquals(
3256
	assertEquals(
3296
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3257
			"Constructor4[ANONYMOUS_CLASS_DECLARATION]{, Lzconstructors.Constructor4;, (I)V, null, (i), " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
3297
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3258
			"Constructor4[METHOD_REF<CONSTRUCTOR>]{, Lzconstructors.Constructor4;, (I)V, Constructor4, (i), " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}",
3298
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3259
			requestor.getResults());
3299
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3300
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3301
		requestor.getResults());
3302
}
3260
}
3303
3261
3304
public void testCompletionMessageSendIsParent3() throws JavaModelException {
3262
/**
3263
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=78801
3264
 */
3265
public void testCompletionFindConstructor5() throws JavaModelException {
3266
	this.wc = getWorkingCopy(
3267
            "/Completion/src/CompletionFindConstructor5.java",
3268
            "import zconstructors.*;\n"+
3269
            "public class CompletionFindConstructor5 {\n"+
3270
            "	Constructor5 c = new Constructor5();\n"+
3271
            "}");
3272
    
3273
    
3274
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3275
    
3276
    String str = this.wc.getSource();
3277
    String completeBehind = "Constructor5(";
3278
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3279
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3280
3281
    assertResults(
3282
            "expectedTypesSignatures=null\n"+
3283
            "expectedTypesKeys=null",
3284
            requestor.getContext());
3285
    
3286
	assertEquals(
3287
			"Constructor5[ANONYMOUS_CLASS_DECLARATION]{, Lzconstructors.Constructor5;, (I)V, null, (arg0), " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
3288
			"Constructor5[METHOD_REF<CONSTRUCTOR>]{, Lzconstructors.Constructor5;, (I)V, Constructor5, (arg0), " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}",
3289
			requestor.getResults());
3290
}
3291
3292
/**
3293
 * Complete the exception "Exception" in a catch clause.
3294
 */
3295
public void testCompletionFindExceptions1() throws JavaModelException {
3305
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3296
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3306
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMessageSendIsParent3.java");
3297
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindException1.java");
3307
3298
3308
	String str = cu.getSource();
3299
	String str = cu.getSource();
3309
	String completeBehind = "zz";
3300
	String completeBehind = "Ex";
3310
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3301
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3311
	cu.codeComplete(cursorLocation, requestor);
3302
	cu.codeComplete(cursorLocation, requestor);
3312
3303
	
3313
	assertEquals(
3304
	assertEquals(
3314
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3305
		"should have one class", 
3315
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3306
		"element:Exception    completion:Exception    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXCEPTION + R_UNQUALIFIED + R_NON_RESTRICTED),
3316
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3317
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3318
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3319
		requestor.getResults());
3307
		requestor.getResults());
3320
}
3308
}
3321
3309
3322
public void testCompletionMessageSendIsParent4() throws JavaModelException {
3310
/**
3311
 * Complete the exception "Exception" in a throws clause.
3312
 */
3313
public void testCompletionFindExceptions2() throws JavaModelException {
3323
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3314
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3324
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMessageSendIsParent4.java");
3315
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindException2.java");
3325
3316
3326
	String str = cu.getSource();
3317
	String str = cu.getSource();
3327
	String completeBehind = "zz";
3318
	String completeBehind = "Ex";
3328
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3319
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3329
	cu.codeComplete(cursorLocation, requestor);
3320
	cu.codeComplete(cursorLocation, requestor);
3330
3321
3331
	assertEquals(
3322
	assertEquals(
3332
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3323
		"should have one class",
3333
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3324
		"element:Exception    completion:Exception    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXCEPTION + R_UNQUALIFIED + R_NON_RESTRICTED),
3334
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3335
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3336
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3337
		requestor.getResults());
3325
		requestor.getResults());
3338
}
3326
}
3339
3327
3340
public void testCompletionMessageSendIsParent5() throws JavaModelException {
3328
/**
3329
 * Complete the field "var" from "va";
3330
 */
3331
public void testCompletionFindField1() throws JavaModelException {
3341
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3332
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3342
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMessageSendIsParent5.java");
3333
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindField1.java");
3343
3334
3344
	String str = cu.getSource();
3335
	String str = cu.getSource();
3345
	String completeBehind = "zz";
3336
	String completeBehind = "va";
3346
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3337
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3347
	cu.codeComplete(cursorLocation, requestor);
3338
	cu.codeComplete(cursorLocation, requestor);
3348
3339
	
3349
	assertEquals(
3340
	assertEquals(
3350
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3341
		"should have one field: 'var' and one variable: 'var'", 
3351
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3342
		"element:var    completion:this.var    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n"+
3352
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3343
		"element:var    completion:var    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED),
3353
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3344
		requestor.getResults());	
3354
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3355
		requestor.getResults());
3356
}
3345
}
3357
3346
3358
public void testCompletionMessageSendIsParent6() throws JavaModelException {
3347
/**
3348
 * Complete the field "var" from "this.va";
3349
 */
3350
public void testCompletionFindField2() throws JavaModelException {
3359
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3351
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3360
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMessageSendIsParent6.java");
3352
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindField2.java");
3361
3353
3362
	String str = cu.getSource();
3354
	String str = cu.getSource();
3363
	String completeBehind = "zz";
3355
	String completeBehind = "va";
3364
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3356
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3365
	cu.codeComplete(cursorLocation, requestor);
3357
	cu.codeComplete(cursorLocation, requestor);
3366
3358
	
3367
	assertEquals(
3359
	assertEquals(
3368
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3360
		"should have 1 field of starting with 'va'",
3369
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3361
		"element:var    completion:var    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED),
3370
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3371
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3372
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3373
		requestor.getResults());
3362
		requestor.getResults());
3374
}
3363
}
3375
3364
3376
public void testCompletionAllocationExpressionIsParent1() throws JavaModelException {
3365
public void testCompletionFindField3() throws JavaModelException {
3377
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3366
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3378
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAllocationExpressionIsParent1.java");
3367
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindField3.java");
3379
3368
3380
	String str = cu.getSource();
3369
	String str = cu.getSource();
3381
	String completeBehind = "zz";
3370
	String completeBehind = "b.ba";
3382
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3371
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3383
	cu.codeComplete(cursorLocation, requestor);
3372
	cu.codeComplete(cursorLocation, requestor);
3384
3373
3385
	assertEquals(
3374
	assertEquals(
3386
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3375
		"element:bar    completion:bar    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED),
3387
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3388
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3389
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3390
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3391
		requestor.getResults());
3376
		requestor.getResults());
3392
}
3377
}
3393
3378
3394
public void testCompletionAllocationExpressionIsParent2() throws JavaModelException {
3379
/**
3380
 * Complete the import, "import pac"
3381
 */
3382
public void testCompletionFindImport1() throws JavaModelException {
3395
	this.wc = getWorkingCopy(
3383
	this.wc = getWorkingCopy(
3396
            "/Completion/src/CompletionAllocationExpressionIsParent2.java",
3384
            "/Completion/src/CompletionFindImport1.java",
3397
            "public class CompletionAllocationExpressionIsParent2 {\n" +
3385
            "import pac\n"+
3398
            "	public class Inner {\n" +
3386
            "\n"+
3399
            "		public Inner(long i, long j){super();}\n" +
3387
            "public class CompletionFindImport1 {\n"+
3400
            "		public Inner(Object i, Object j){super();}\n" +
3388
            "\n"+
3401
            "		\n" +
3402
            "	}\n" +
3403
            "	\n" +
3404
            "	long zzlong;\n" +
3405
            "	int zzint;\n" +
3406
            "	double zzdouble;\n" +
3407
            "	boolean zzboolean;\n" +
3408
            "	Object zzObject;\n" +
3409
            "	\n" +
3410
            "	void foo() {\n" +
3411
            "		this.new Inner(1, zz\n" +
3412
            "	}\n" +
3413
            "}");
3389
            "}");
3414
    
3390
    
3415
    
3391
    
3416
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3392
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3417
    String str = this.wc.getSource();
3393
    String str = this.wc.getSource();
3418
    String completeBehind = "zz";
3394
    String completeBehind = "pac";
3419
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3395
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3420
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3396
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3421
3397
    
3422
    assertResults(
3398
	assertResults(
3423
            "zzObject[FIELD_REF]{zzObject, LCompletionAllocationExpressionIsParent2;, Ljava.lang.Object;, zzObject, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
3399
			"pack[PACKAGE_REF]{pack.*;, pack, null, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
3424
            "zzboolean[FIELD_REF]{zzboolean, LCompletionAllocationExpressionIsParent2;, Z, zzboolean, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
3400
			"pack1[PACKAGE_REF]{pack1.*;, pack1, null, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
3425
            "zzdouble[FIELD_REF]{zzdouble, LCompletionAllocationExpressionIsParent2;, D, zzdouble, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
3401
			"pack1.pack3[PACKAGE_REF]{pack1.pack3.*;, pack1.pack3, null, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
3426
            "zzint[FIELD_REF]{zzint, LCompletionAllocationExpressionIsParent2;, I, zzint, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
3402
			"pack2[PACKAGE_REF]{pack2.*;, pack2, null, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) +"}",
3427
            "zzlong[FIELD_REF]{zzlong, LCompletionAllocationExpressionIsParent2;, J, zzlong, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED)+"}",
3403
			requestor.getResults());
3428
            requestor.getResults());
3429
}
3404
}
3430
3405
3431
public void testCompletionAllocationExpressionIsParent3() throws JavaModelException {
3406
public void testCompletionFindImport2() throws JavaModelException {
3432
	this.wc = getWorkingCopy(
3407
	this.wc = getWorkingCopy(
3433
            "/Completion/src/CompletionAllocationExpressionIsParent3.java",
3408
            "/Completion/src/CompletionFindImport2.java",
3434
            "public class CompletionAllocationExpressionIsParent3 {\n" +
3409
            "import pack1.P\n"+
3435
            "	public class Inner {\n" +
3410
            "\n"+
3436
            "		public Inner(long i, long j){super();}\n" +
3411
            "public class CompletionFindImport2 {\n"+
3437
            "		public Inner(Object i, Object j){super();}\n" +
3412
            "\n"+
3438
            "		\n" +
3439
            "	}\n" +
3440
            "	\n" +
3441
            "	long zzlong;\n" +
3442
            "	int zzint;\n" +
3443
            "	double zzdouble;\n" +
3444
            "	boolean zzboolean;\n" +
3445
            "	Object zzObject;\n" +
3446
            "	\n" +
3447
            "	void foo() {\n" +
3448
            "		new CompletionAllocationExpressionIsParent3().new Inner(1, zz\n" +
3449
            "	}\n" +
3450
            "}");
3413
            "}");
3451
    
3414
    
3452
    
3415
    
3453
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3416
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3454
    String str = this.wc.getSource();
3417
    String str = this.wc.getSource();
3455
    String completeBehind = "zz";
3418
    String completeBehind = "pack1.P";
3456
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3419
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3457
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3420
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3458
3421
    
3459
    assertResults(
3422
	assertResults(
3460
            "zzObject[FIELD_REF]{zzObject, LCompletionAllocationExpressionIsParent3;, Ljava.lang.Object;, zzObject, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
3423
			"pack1.pack3[PACKAGE_REF]{pack1.pack3.*;, pack1.pack3, null, null, null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n"+
3461
            "zzboolean[FIELD_REF]{zzboolean, LCompletionAllocationExpressionIsParent3;, Z, zzboolean, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
3424
			"PX[TYPE_REF]{pack1.PX;, pack1, Lpack1.PX;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
3462
            "zzdouble[FIELD_REF]{zzdouble, LCompletionAllocationExpressionIsParent3;, D, zzdouble, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
3425
			requestor.getResults());
3463
            "zzint[FIELD_REF]{zzint, LCompletionAllocationExpressionIsParent3;, I, zzint, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
3464
            "zzlong[FIELD_REF]{zzlong, LCompletionAllocationExpressionIsParent3;, J, zzlong, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED)+"}",
3465
            requestor.getResults());
3466
}
3426
}
3467
3427
3468
public void testCompletionAllocationExpressionIsParent4() throws JavaModelException {
3428
/**
3429
 * Complete the local variable "var";
3430
 */
3431
public void testCompletionFindLocalVariable() throws JavaModelException {
3469
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3432
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3470
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAllocationExpressionIsParent4.java");
3433
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindLocalVariable.java");
3471
3434
3472
	String str = cu.getSource();
3435
	String str = cu.getSource();
3473
	String completeBehind = "zz";
3436
	String completeBehind = "va";
3474
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3437
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3475
	cu.codeComplete(cursorLocation, requestor);
3438
	cu.codeComplete(cursorLocation, requestor);
3476
3477
	assertEquals(
3439
	assertEquals(
3478
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3440
		"should have one local variable of 'var'", 
3479
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3441
		"element:var    completion:var    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED),
3480
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3442
		requestor.getResults());	
3481
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3482
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3483
		requestor.getResults());
3484
}
3443
}
3485
3444
3486
public void testCompletionAllocationExpressionIsParent5() throws JavaModelException {
3445
public void testCompletionFindMemberType1() throws JavaModelException {
3487
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3446
	this.wc = getWorkingCopy(
3488
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAllocationExpressionIsParent5.java");
3447
            "/Completion/src/CompletionFindMemberType1.java",
3489
3448
            "interface A1 {\n"+
3490
	String str = cu.getSource();
3449
            "	class Inner1 {\n"+
3491
	String completeBehind = "zz";
3450
            "	}\n"+
3492
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3451
            "}\n"+
3493
	cu.codeComplete(cursorLocation, requestor);
3452
            "interface B1 extends A1 {\n"+
3453
            "	class Inner1 {\n"+
3454
            "	}\n"+
3455
            "}\n"+
3456
            "public class CompletionFindMemberType1 {\n"+
3457
            "	public void foo() {\n"+
3458
            "		B1.Inner\n"+
3459
            "	}\n"+
3460
            "}");
3461
    
3462
    
3463
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3464
    String str = this.wc.getSource();
3465
    String completeBehind = "Inner";
3466
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3467
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3494
3468
3495
	assertEquals(
3469
	assertResults(
3496
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3470
		"B1.Inner1[TYPE_REF]{Inner1, , LB1$Inner1;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) +"}",
3497
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3498
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3499
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3500
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3501
		requestor.getResults());
3471
		requestor.getResults());
3502
}
3472
}
3503
3473
3504
public void testCompletionAllocationExpressionIsParent6() throws JavaModelException {
3474
public void testCompletionFindMemberType2() throws JavaModelException {
3505
	this.wc = getWorkingCopy(
3475
	this.wc = getWorkingCopy(
3506
            "/Completion/src/CompletionAllocationExpressionIsParent6.java",
3476
            "/Completion/src/CompletionPrefixMethodName2.java",
3507
            "public class CompletionAllocationExpressionIsParent6 {\n" +
3477
            "interface A2 {\n"+
3508
            "	\n" +
3478
            "	class ZInner2{\n"+
3509
            "	long zzlong;\n" +
3479
            "	}\n"+
3510
            "	int zzint;\n" +
3480
            "}\n"+
3511
            "	double zzdouble;\n" +
3481
            "interface B2 extends A2 {\n"+
3512
            "	boolean zzboolean;\n" +
3482
            "	class ZInner2 {\n"+
3513
            "	Object zzObject;\n" +
3483
            "	}\n"+
3514
            "	\n" +
3484
            "}\n"+
3515
            "	void foo() {\n" +
3485
            "public class CompletionFindMemberType2 implements B2{\n"+
3516
            "		new CompletionAllocation_ERROR_ExpressionIsParent6Plus().new Inner(1, zz\n" +
3486
            "	public void foo() {\n"+
3517
            "	}\n" +
3487
            "		ZInner\n"+
3518
            "}\n" +
3488
            "	}\n"+
3519
            "class CompletionAllocationExpressionIsParent6Plus {\n" +
3520
            "	public class Inner {\n" +
3521
            "		public Inner(long i, long j){\n" +
3522
            "			\n" +
3523
            "		}	\n" +
3524
            "	}	\n" +
3525
            "}");
3489
            "}");
3526
    
3490
    
3527
    
3528
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3491
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3529
    String str = this.wc.getSource();
3492
    String str = this.wc.getSource();
3530
    String completeBehind = "zz";
3493
    String completeBehind = "ZInner";
3531
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3494
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3532
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3495
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3533
3496
3534
    assertResults(
3497
	assertResults(
3535
            "zzObject[FIELD_REF]{zzObject, LCompletionAllocationExpressionIsParent6;, Ljava.lang.Object;, zzObject, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
3498
		"B2.ZInner2[TYPE_REF]{ZInner2, , LB2$ZInner2;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE+ R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
3536
            "zzboolean[FIELD_REF]{zzboolean, LCompletionAllocationExpressionIsParent6;, Z, zzboolean, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
3499
		requestor.getResults());
3537
            "zzdouble[FIELD_REF]{zzdouble, LCompletionAllocationExpressionIsParent6;, D, zzdouble, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
3538
            "zzint[FIELD_REF]{zzint, LCompletionAllocationExpressionIsParent6;, I, zzint, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
3539
            "zzlong[FIELD_REF]{zzlong, LCompletionAllocationExpressionIsParent6;, J, zzlong, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED)+"}",
3540
            requestor.getResults());
3541
}
3500
}
3542
3501
3543
public void testCompletionFieldInitializer1() throws JavaModelException {
3502
/**
3503
 * Complete the method call "a.foobar" from "a.fooba";
3504
 */
3505
public void testCompletionFindMethod1() throws JavaModelException {
3544
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3506
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3545
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFieldInitializer1.java");
3507
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindMethod1.java");
3546
3508
3547
	String str = cu.getSource();
3509
	String str = cu.getSource();
3548
	String completeBehind = "zz";
3510
	String completeBehind = "fooba";
3549
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3511
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3550
	cu.codeComplete(cursorLocation, requestor);
3512
	cu.codeComplete(cursorLocation, requestor);
3551
3552
	assertEquals(
3513
	assertEquals(
3553
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3514
		"should have two methods of 'foobar'", 
3554
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3515
		"element:foobar    completion:foobar()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED)+"\n" +
3555
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3516
		"element:foobar    completion:foobar()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED),
3556
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3517
		requestor.getResults());		
3557
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3558
		requestor.getResults());
3559
}
3518
}
3560
3519
/**
3561
public void testCompletionFieldInitializer2() throws JavaModelException {
3520
 * Too much Completion match on interface
3521
 */
3522
public void testCompletionFindMethod2() throws JavaModelException {
3523
	
3562
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3524
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3563
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFieldInitializer2.java");
3525
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindMethod2.java");
3564
3526
3565
	String str = cu.getSource();
3527
	String str = cu.getSource();
3566
	String completeBehind = "zz";
3528
	String completeBehind = "fooba";
3567
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3529
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
3568
	cu.codeComplete(cursorLocation, requestor);
3530
	cu.codeComplete(cursorLocation, requestor);
3569
3531
3570
	assertEquals(
3532
	assertEquals(
3571
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3533
		"should have two completions", 
3572
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3534
		"element:foobar    completion:foobar()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED)+"\n" +
3573
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3535
		"element:foobar    completion:foobar()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED),
3574
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3536
		requestor.getResults());	
3575
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3576
		requestor.getResults());
3577
}
3537
}
3578
3538
/**
3579
public void testCompletionFieldInitializer3() throws JavaModelException {
3539
 * Complete the method call "foobar" from "fooba";
3540
 */
3541
public void testCompletionFindMethodInThis() throws JavaModelException {
3580
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3542
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3581
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFieldInitializer3.java");
3543
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindMethodInThis.java");
3582
3544
3583
	String str = cu.getSource();
3545
	String str = cu.getSource();
3584
	String completeBehind = "Objec";
3546
	String completeBehind = "fooba";
3585
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3547
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3586
	cu.codeComplete(cursorLocation, requestor);
3548
	cu.codeComplete(cursorLocation, requestor);
3587
3588
	assertEquals(
3549
	assertEquals(
3589
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3550
		"should have one method of 'foobar'", 
3590
		requestor.getResults());
3551
		"element:foobar    completion:foobar    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
3552
		requestor.getResults());		
3591
}
3553
}
3592
3554
3593
public void testCompletionFieldInitializer4() throws JavaModelException {
3555
/**
3556
 * Complete the method call "foobar" from "fooba".  The compilation
3557
 * unit simulates typing in process; ie it has incomplete structure/syntax errors.
3558
 */
3559
public void testCompletionFindMethodWhenInProcess() throws JavaModelException {
3594
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3560
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3595
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFieldInitializer4.java");
3561
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindMethodInProcess.java");
3596
3562
3597
	String str = cu.getSource();
3563
	String str = cu.getSource();
3598
	String completeBehind = "Objec";
3564
	String completeBehind = "fooba";
3599
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3565
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3600
	cu.codeComplete(cursorLocation, requestor);
3566
	cu.codeComplete(cursorLocation, requestor);
3601
3602
	assertEquals(
3567
	assertEquals(
3603
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3568
		"should have a method of 'foobar'", 
3569
		"element:foobar    completion:foobar()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
3604
		requestor.getResults());
3570
		requestor.getResults());
3571
	cu.close();
3605
}
3572
}
3606
public void testCompletionVariableInitializerInInitializer1() throws JavaModelException {
3573
3574
public void testCompletionFindSecondaryType1() throws JavaModelException {
3607
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3575
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3608
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableInitializerInInitializer1.java");
3576
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindSecondaryType1.java");
3609
3577
3610
	String str = cu.getSource();
3578
	String str = cu.getSource();
3611
	String completeBehind = "zz";
3579
	String completeBehind = "/**/Secondary";
3612
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3580
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3613
	cu.codeComplete(cursorLocation, requestor);
3581
	cu.codeComplete(cursorLocation, requestor);
3614
3582
3615
	assertEquals(
3583
	assertEquals(
3616
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3584
		"element:SecondaryType1    completion:SecondaryType1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
3617
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3585
		"element:SecondaryType2    completion:SecondaryType2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3618
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3619
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3620
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3621
		requestor.getResults());
3586
		requestor.getResults());
3622
}
3587
}
3623
3588
3624
public void testCompletionVariableInitializerInInitializer2() throws JavaModelException {
3589
public void testCompletionFindSuperInterface() throws JavaModelException {
3625
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3590
	this.wc = getWorkingCopy(
3626
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableInitializerInInitializer2.java");
3591
            "/Completion/src/CompletionFindSuperInterface.java",
3627
3592
            "public class CompletionFindSuperInterface implements SuperInterface {\n"+
3628
	String str = cu.getSource();
3593
            "}");
3629
	String completeBehind = "zz";
3594
    
3630
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3595
    
3631
	cu.codeComplete(cursorLocation, requestor);
3596
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3632
3597
    String str = this.wc.getSource();
3633
	assertEquals(
3598
    String completeBehind = "Super";
3634
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3599
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3635
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3600
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3636
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3601
3637
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3602
    assertResults(
3638
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3603
           "SuperInterface[TYPE_REF]{SuperInterface, , LSuperInterface;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_INTERFACE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
3639
		requestor.getResults());
3604
			requestor.getResults());
3640
}
3605
}
3641
3606
3642
public void testCompletionVariableInitializerInInitializer3() throws JavaModelException {
3607
/**
3608
 * Complete the field "bar" from "this.ba"
3609
 */
3610
public void testCompletionFindThisDotField() throws JavaModelException {
3643
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3611
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3644
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableInitializerInInitializer3.java");
3612
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindThisDotField.java");
3645
3613
3646
	String str = cu.getSource();
3614
	String str = cu.getSource();
3647
	String completeBehind = "Objec";
3615
	String completeBehind = "this.ba";
3648
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3616
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3649
	cu.codeComplete(cursorLocation, requestor);
3617
	cu.codeComplete(cursorLocation, requestor);
3650
3651
	assertEquals(
3618
	assertEquals(
3652
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3619
		"should have one result of 'bar'", 
3620
		"element:bar    completion:bar    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED),
3653
		requestor.getResults());
3621
		requestor.getResults());
3654
}
3622
}
3655
3623
3656
public void testCompletionVariableInitializerInInitializer4() throws JavaModelException {
3624
public void testCompletionImportedType1() throws JavaModelException {
3657
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3625
    this.workingCopies = new ICompilationUnit[2];
3658
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableInitializerInInitializer4.java");
3626
    this.workingCopies[0] = getWorkingCopy(
3627
		"/Completion/src/test/imported/ZZZZ.java",
3628
		"package test.imported;"+
3629
		"public class ZZZZ {\n"+
3630
		"  \n"+
3631
		"}");
3632
		
3633
	this.workingCopies[1] = getWorkingCopy(
3634
			"/Completion/src/test/CompletionImportedType1.java",
3635
			"package test;"+
3636
			"public class CompletionImportedType1 {"+
3637
			"  ZZZ\n"+
3638
			"}");
3659
3639
3660
	String str = cu.getSource();
3640
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3661
	String completeBehind = "Objec";
3641
	String str = this.workingCopies[1].getSource();
3642
	String completeBehind = "ZZZ";
3662
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3643
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3663
	cu.codeComplete(cursorLocation, requestor);
3644
	this.workingCopies[1].codeComplete(cursorLocation, requestor, this.wcOwner);
3664
3645
3665
	assertEquals(
3646
	assertResults(
3666
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3647
			"ZZZ[POTENTIAL_METHOD_DECLARATION]{ZZZ, Ltest.CompletionImportedType1;, ()V, ZZZ, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
3667
		requestor.getResults());
3648
			"ZZZZ[TYPE_REF]{test.imported.ZZZZ, test.imported, Ltest.imported.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
3649
			requestor.getResults());
3668
}
3650
}
3669
public void testCompletionVariableInitializerInMethod1() throws JavaModelException {
3670
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3671
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableInitializerInMethod1.java");
3672
3651
3673
	String str = cu.getSource();
3652
public void testCompletionImportedType2() throws JavaModelException {
3674
	String completeBehind = "zz";
3653
	this.workingCopies = new ICompilationUnit[4];
3654
	this.workingCopies[0] = getWorkingCopy(
3655
		"/Completion/src/test/imported1/ZZZZ.java",
3656
		"package test.imported1;"+
3657
		"public class ZZZZ {\n"+
3658
		"  \n"+
3659
		"}");
3660
	this.workingCopies[1] = getWorkingCopy(
3661
		"/Completion/src/test/imported2/ZZZZ.java",
3662
		"package test.imported2;"+
3663
		"public class ZZZZ {\n"+
3664
		"  \n"+
3665
		"}");
3666
	this.workingCopies[2] = getWorkingCopy(
3667
		"/Completion/src/test/imported3/ZZZZ.java",
3668
		"package test.imported3;"+
3669
		"public class ZZZZ {\n"+
3670
		"  \n"+
3671
		"}");
3672
	
3673
	this.workingCopies[3] = getWorkingCopy(
3674
		"/Completion/src/test/CompletionImportedType2.java",
3675
		"package test;"+
3676
		"import test.imported1.*;"+
3677
		"import test.imported2.*;"+
3678
		"import test.imported3.*;"+
3679
		"public class CompletionImportedType2 {"+
3680
		"  ZZZ\n"+
3681
		"}");
3682
	
3683
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3684
	String str = this.workingCopies[3].getSource();
3685
	String completeBehind = "ZZZ";
3675
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3686
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3676
	cu.codeComplete(cursorLocation, requestor);
3687
	this.workingCopies[3].codeComplete(cursorLocation, requestor, this.wcOwner);
3677
3688
3678
	assertEquals(
3689
	assertResults(
3679
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3690
			"ZZZ[POTENTIAL_METHOD_DECLARATION]{ZZZ, Ltest.CompletionImportedType2;, ()V, ZZZ, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
3680
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3691
			"ZZZZ[TYPE_REF]{test.imported1.ZZZZ, test.imported1, Ltest.imported1.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
3681
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3692
			"ZZZZ[TYPE_REF]{test.imported2.ZZZZ, test.imported2, Ltest.imported2.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
3682
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3693
			"ZZZZ[TYPE_REF]{test.imported3.ZZZZ, test.imported3, Ltest.imported3.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
3683
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3694
			requestor.getResults());
3684
		requestor.getResults());
3685
}
3695
}
3686
3696
3687
public void testCompletionVariableInitializerInMethod2() throws JavaModelException {
3697
public void testCompletionImportedType3() throws JavaModelException {
3688
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3698
	this.workingCopies = new ICompilationUnit[4];
3689
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableInitializerInMethod2.java");
3699
	this.workingCopies[0] = getWorkingCopy(
3690
3700
		"/Completion/src/test/imported1/ZZZZ.java",
3691
	String str = cu.getSource();
3701
		"package test.imported1;"+
3692
	String completeBehind = "zz";
3702
		"public class ZZZZ {\n"+
3703
		"  \n"+
3704
		"}");
3705
	this.workingCopies[1] = getWorkingCopy(
3706
		"/Completion/src/test/imported2/ZZZZ.java",
3707
		"package test.imported2;"+
3708
		"public class ZZZZ {\n"+
3709
		"  \n"+
3710
		"}");
3711
	this.workingCopies[2] = getWorkingCopy(
3712
		"/Completion/src/test/imported3/ZZZZ.java",
3713
		"package test.imported3;"+
3714
		"public class ZZZZ {\n"+
3715
		"  \n"+
3716
		"}");
3717
	
3718
	this.workingCopies[3] = getWorkingCopy(
3719
		"/Completion/src/test/CompletionImportedType3.java",
3720
		"package test;"+
3721
		"import test.imported2.*;"+
3722
		"public class CompletionImportedType3 {"+
3723
		"  ZZZ\n"+
3724
			"}");
3725
	
3726
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3727
	String str = this.workingCopies[3].getSource();
3728
	String completeBehind = "ZZZ";
3693
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3729
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3694
	cu.codeComplete(cursorLocation, requestor);
3730
	this.workingCopies[3].codeComplete(cursorLocation, requestor, this.wcOwner);
3695
3731
3696
	assertEquals(
3732
	assertResults(
3697
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3733
			"ZZZ[POTENTIAL_METHOD_DECLARATION]{ZZZ, Ltest.CompletionImportedType3;, ()V, ZZZ, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
3698
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3734
			"ZZZZ[TYPE_REF]{test.imported1.ZZZZ, test.imported1, Ltest.imported1.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
3699
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3735
			"ZZZZ[TYPE_REF]{test.imported3.ZZZZ, test.imported3, Ltest.imported3.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
3700
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3736
			"ZZZZ[TYPE_REF]{ZZZZ, test.imported2, Ltest.imported2.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
3701
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3737
			requestor.getResults());
3702
		requestor.getResults());
3703
}
3738
}
3704
3739
3705
public void testCompletionVariableInitializerInMethod3() throws JavaModelException {
3740
public void testCompletionImportedType4() throws JavaModelException {
3706
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3741
	this.workingCopies = new ICompilationUnit[3];
3707
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableInitializerInMethod3.java");
3742
	this.workingCopies[0] = getWorkingCopy(
3708
3743
		"/Completion/src/test/imported1/ZZZZ.java",
3709
	String str = cu.getSource();
3744
		"package test.imported1;"+
3710
	String completeBehind = "Objec";
3745
		"public class ZZZZ {\n"+
3746
		"  \n"+
3747
		"}");
3748
	this.workingCopies[1] = getWorkingCopy(
3749
		"/Completion/src/test/imported2/ZZZZ.java",
3750
		"package test.imported2;"+
3751
		"public class ZZZZ {\n"+
3752
		"  \n"+
3753
		"}");
3754
		
3755
	this.workingCopies[2] = getWorkingCopy(
3756
		"/Completion/src/test/CompletionImportedType4.java",
3757
		"package test;"+
3758
		"import test.imported1.*;"+
3759
		"public class CompletionImportedType4 {"+
3760
		"  ZZZ\n"+
3761
		"}");
3762
	
3763
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3764
	String str = this.workingCopies[2].getSource();
3765
	String completeBehind = "ZZZ";
3711
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3766
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3712
	cu.codeComplete(cursorLocation, requestor);
3767
	this.workingCopies[2].codeComplete(cursorLocation, requestor, this.wcOwner);
3713
3768
3714
	assertEquals(
3769
	assertResults(
3715
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3770
			"ZZZ[POTENTIAL_METHOD_DECLARATION]{ZZZ, Ltest.CompletionImportedType4;, ()V, ZZZ, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
3716
		requestor.getResults());
3771
			"ZZZZ[TYPE_REF]{test.imported2.ZZZZ, test.imported2, Ltest.imported2.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
3772
			"ZZZZ[TYPE_REF]{ZZZZ, test.imported1, Ltest.imported1.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
3773
			requestor.getResults());
3717
}
3774
}
3718
3775
3719
public void testCompletionVariableInitializerInMethod4() throws JavaModelException {
3776
public void testCompletionImportedType5() throws JavaModelException {
3720
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3777
	this.workingCopies = new ICompilationUnit[3];
3721
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableInitializerInMethod4.java");
3778
	this.workingCopies[0] = getWorkingCopy(
3779
		"/Completion/src/test/imported1/ZZZZ.java",
3780
		"package test.imported1;"+
3781
		"public class ZZZZ {\n"+
3782
		"  \n"+
3783
		"}");
3784
	this.workingCopies[1] = getWorkingCopy(
3785
		"/Completion/src/test/imported2/ZZZZ.java",
3786
		"package test.imported2;"+
3787
		"public class ZZZZ {\n"+
3788
		"  \n"+
3789
		"}");
3790
		
3791
	this.workingCopies[2] = getWorkingCopy(
3792
		"/Completion/src/test/CompletionImportedType5.java",
3793
		"package test;"+
3794
		"import test.imported2.*;"+
3795
		"public class CompletionImportedType5 {"+
3796
		"  ZZZ\n"+
3797
		"}");
3722
3798
3723
	String str = cu.getSource();
3799
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3724
	String completeBehind = "Objec";
3800
	String str = this.workingCopies[2].getSource();
3801
	String completeBehind = "ZZZ";
3725
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3802
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3726
	cu.codeComplete(cursorLocation, requestor);
3803
	this.workingCopies[2].codeComplete(cursorLocation, requestor, this.wcOwner);
3727
3804
3728
	assertEquals(
3805
	assertResults(
3729
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3806
			"ZZZ[POTENTIAL_METHOD_DECLARATION]{ZZZ, Ltest.CompletionImportedType5;, ()V, ZZZ, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
3730
		requestor.getResults());
3807
			"ZZZZ[TYPE_REF]{test.imported1.ZZZZ, test.imported1, Ltest.imported1.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
3808
			"ZZZZ[TYPE_REF]{ZZZZ, test.imported2, Ltest.imported2.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
3809
			requestor.getResults());
3731
}
3810
}
3732
public void testCompletionAssignmentInMethod1() throws JavaModelException {
3733
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3734
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAssignmentInMethod1.java");
3735
3811
3736
	String str = cu.getSource();
3812
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
3737
	String completeBehind = "zz";
3813
public void testCompletionInsideExtends1() throws JavaModelException {
3814
	this.wc = getWorkingCopy(
3815
			"/Completion/src/test/CompletionInsideExtends1.java",
3816
			"package test;\n" +
3817
			"public class CompletionInsideExtends1 extends  {\n" +
3818
			"  public class CompletionInsideExtends1Inner {}\n" +
3819
			"}\n" +
3820
			"class CompletionInsideExtends1TopLevel {\n" +
3821
			"}");
3822
	
3823
	
3824
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3825
	String str = this.wc.getSource();
3826
	String completeBehind = "extends ";
3738
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3827
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3739
	cu.codeComplete(cursorLocation, requestor);
3828
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3740
3829
3741
	assertEquals(
3830
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
3742
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3831
		assertResults(
3743
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3832
				"",
3744
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3833
				requestor.getResults());
3745
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3834
	} else {
3746
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3835
		assertResults(
3747
		requestor.getResults());
3836
				"CompletionInsideExtends1TopLevel[TYPE_REF]{CompletionInsideExtends1TopLevel, test, Ltest.CompletionInsideExtends1TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
3837
				requestor.getResults());
3838
	}
3839
	
3748
}
3840
}
3749
3841
3750
public void testCompletionAssignmentInMethod2() throws JavaModelException {
3842
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
3751
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3843
public void testCompletionInsideExtends10() throws JavaModelException {
3752
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAssignmentInMethod2.java");
3844
	this.wc = getWorkingCopy(
3753
3845
			"/Completion/src/test/CompletionInsideExtends10.java",
3754
	String str = cu.getSource();
3846
			"package test;\n" +
3755
	String completeBehind = "zz";
3847
			"public interface CompletionInsideExtends10 {\n" +
3848
			"  public interface CompletionInsideExtends10Inner extends CompletionInsideExtends{\n" +
3849
			"    public interface CompletionInsideExtends10InnerInner {\n" +
3850
			"    }\n" +
3851
			"  }\n" +
3852
			"}\n" +
3853
			"interface CompletionInsideExtends10TopLevel {\n" +
3854
			"}");
3855
	
3856
	
3857
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3858
	String str = this.wc.getSource();
3859
	String completeBehind = "extends CompletionInsideExtends";
3756
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3860
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3757
	cu.codeComplete(cursorLocation, requestor);
3861
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3758
3862
3759
	assertEquals(
3863
	assertResults(
3760
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3864
			"CompletionInsideExtends10.CompletionInsideExtends10Inner.CompletionInsideExtends10InnerInner[TYPE_REF]{test.CompletionInsideExtends10.CompletionInsideExtends10Inner.CompletionInsideExtends10InnerInner, test, Ltest.CompletionInsideExtends10$CompletionInsideExtends10Inner$CompletionInsideExtends10InnerInner;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_NON_RESTRICTED) + "}\n" +
3761
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3865
			"CompletionInsideExtends10[TYPE_REF]{CompletionInsideExtends10, test, Ltest.CompletionInsideExtends10;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
3762
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3866
			"CompletionInsideExtends10TopLevel[TYPE_REF]{CompletionInsideExtends10TopLevel, test, Ltest.CompletionInsideExtends10TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
3763
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3867
			requestor.getResults());
3764
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3765
		requestor.getResults());
3766
}
3868
}
3767
3869
3768
public void testCompletionAssignmentInMethod3() throws JavaModelException {
3870
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
3769
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3871
public void testCompletionInsideExtends11() throws JavaModelException {
3770
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAssignmentInMethod3.java");
3872
	this.wc = getWorkingCopy(
3771
3873
			"/Completion/src/test/CompletionInsideExtends11.java",
3772
	String str = cu.getSource();
3874
			"package test;\n" +
3773
	String completeBehind = "Objec";
3875
			"public class CompletionInsideExtends11 implements {\n" +
3876
			"  public class CompletionInsideExtends11Inner {\n" +
3877
			"  }\n" +
3878
			"}\n" +
3879
			"class CompletionInsideExtends11TopLevel {\n" +
3880
			"}");
3881
	
3882
	
3883
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3884
	String str = this.wc.getSource();
3885
	String completeBehind = "implements ";
3774
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3886
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3775
	cu.codeComplete(cursorLocation, requestor);
3887
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3776
3888
3777
	assertEquals(
3889
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
3778
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3890
		assertResults(
3779
		requestor.getResults());
3891
				"",
3892
				requestor.getResults());
3893
	} else {
3894
		assertResults(
3895
				"",
3896
				requestor.getResults());
3897
	}
3780
}
3898
}
3781
3899
3782
public void testCompletionAssignmentInMethod4() throws JavaModelException {
3900
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
3783
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3901
public void testCompletionInsideExtends12() throws JavaModelException {
3784
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAssignmentInMethod4.java");
3902
	this.wc = getWorkingCopy(
3785
3903
			"/Completion/src/test/CompletionInsideExtends12.java",
3786
	String str = cu.getSource();
3904
			"package test;\n" +
3787
	String completeBehind = "Objec";
3905
			"public class CompletionInsideExtends12 implements CompletionInsideExtends {\n" +
3906
			"  public class CompletionInsideExtends12Inner {\n" +
3907
			"  }\n" +
3908
			"}\n" +
3909
			"class CompletionInsideExtends12TopLevel {\n" +
3910
			"}");
3911
	
3912
	
3913
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3914
	String str = this.wc.getSource();
3915
	String completeBehind = "implements CompletionInsideExtends";
3788
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3916
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3789
	cu.codeComplete(cursorLocation, requestor);
3917
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3790
3918
3791
	assertEquals(
3919
	assertResults(
3792
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3920
			"",
3793
		requestor.getResults());
3921
			requestor.getResults());
3794
}
3922
}
3795
/*
3796
* http://dev.eclipse.org/bugs/show_bug.cgi?id=24565
3797
*/
3798
public void testCompletionObjectsMethodWithInterfaceReceiver() throws JavaModelException {
3799
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3800
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionObjectsMethodWithInterfaceReceiver.java");
3801
3923
3802
	String str = cu.getSource();
3924
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
3803
	String completeBehind = "hash";
3925
public void testCompletionInsideExtends2() throws JavaModelException {
3926
	this.wc = getWorkingCopy(
3927
			"/Completion/src/test/CompletionInsideExtends2.java",
3928
			"package test;\n" +
3929
			"public class CompletionInsideExtends2 extends CompletionInsideExtends {\n" +
3930
			"  public class CompletionInsideExtends2Inner {}\n" +
3931
			"}\n" +
3932
			"class CompletionInsideExtends2TopLevel {\n" +
3933
			"}");
3934
	
3935
	
3936
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3937
	String str = this.wc.getSource();
3938
	String completeBehind = "extends CompletionInsideExtends";
3804
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3939
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3805
	cu.codeComplete(cursorLocation, requestor);
3940
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3806
3941
3807
	assertEquals(
3942
	assertResults(
3808
		"element:hashCode    completion:hashCode()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_EXACT_EXPECTED_TYPE+ R_NON_RESTRICTED),
3943
			"CompletionInsideExtends2TopLevel[TYPE_REF]{CompletionInsideExtends2TopLevel, test, Ltest.CompletionInsideExtends2TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
3809
		requestor.getResults());
3944
			requestor.getResults());
3810
}
3945
}
3811
/*
3812
* http://dev.eclipse.org/bugs/show_bug.cgi?id=24939
3813
*/
3814
public void testCompletionConstructorForAnonymousType() throws JavaModelException {
3815
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3816
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionConstructorForAnonymousType.java");
3817
3818
	String str = cu.getSource();
3819
	String completeBehind = "TypeWithConstructor(";
3820
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3821
	cu.codeComplete(cursorLocation, requestor);
3822
3946
3823
	assertEquals(
3947
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
3824
		"element:TypeWithConstructor    completion:    relevance:"+(R_DEFAULT + R_INTERESTING+ R_NON_RESTRICTED),
3948
public void testCompletionInsideExtends3() throws JavaModelException {
3825
		requestor.getResults());
3826
}
3827
/*
3828
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25221
3829
*/
3830
public void testCompletionEmptyTypeName1() throws JavaModelException {
3831
	this.wc = getWorkingCopy(
3949
	this.wc = getWorkingCopy(
3832
            "/Completion/src/CompletionEmptyTypeName1.java",
3950
			"/Completion/src/test/CompletionInsideExtends3.java",
3833
            "public class CompletionEmptyTypeName1 {\n"+
3951
			"package test;\n" +
3834
           "	void foo() {\n"+
3952
			"public class CompletionInsideExtends3 {\n" +
3835
           "		A a = new \n"+
3953
			"  public class CompletionInsideExtends3Inner extends {\n" +
3836
           "	}\n"+
3954
			"    public class CompletionInsideExtends3InnerInner {\n" +
3837
           "}");
3955
			"    }\n" +
3838
    
3956
			"  }\n" +
3839
    
3957
			"}\n" +
3840
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3958
			"class CompletionInsideExtends3TopLevel {\n" +
3841
    String str = this.wc.getSource();
3959
			"}");
3842
    String completeBehind = "new ";
3960
	
3843
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3961
	
3844
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3962
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3963
	String str = this.wc.getSource();
3964
	String completeBehind = "extends ";
3965
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3966
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3845
3967
3846
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
3968
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
3847
		assertResults(
3969
		assertResults(
3848
			"A[TYPE_REF]{A, , LA;, null, null, " +(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
3970
				"",
3849
			requestor.getResults());
3971
				requestor.getResults());
3850
	} else {
3972
	} else {
3851
		assertResults(
3973
		assertResults(
3852
			"CompletionEmptyTypeName1[TYPE_REF]{CompletionEmptyTypeName1, , LCompletionEmptyTypeName1;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED)+"}\n"+
3974
				"CompletionInsideExtends3[TYPE_REF]{CompletionInsideExtends3, test, Ltest.CompletionInsideExtends3;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
3853
			"A[TYPE_REF]{A, , LA;, null, null, " +(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
3975
				"CompletionInsideExtends3TopLevel[TYPE_REF]{CompletionInsideExtends3TopLevel, test, Ltest.CompletionInsideExtends3TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
3854
			requestor.getResults());
3976
				requestor.getResults());
3855
	}
3977
	}
3856
}
3978
}
3857
/*
3858
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25221
3859
*/
3860
public void testCompletionEmptyTypeName2() throws JavaModelException {
3861
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3862
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionEmptyTypeName2.java");
3863
3864
	String str = cu.getSource();
3865
	String completeBehind = " = ";
3866
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3867
	cu.codeComplete(cursorLocation, requestor);
3868
3979
3869
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
3980
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
3870
		assertEquals(
3981
public void testCompletionInsideExtends4() throws JavaModelException {
3871
			"element:a    completion:a    relevance:"+(R_DEFAULT + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3982
	this.wc = getWorkingCopy(
3872
			"element:clone    completion:clone()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3983
			"/Completion/src/test/CompletionInsideExtends4.java",
3873
			"element:equals    completion:equals()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3984
			"package test;\n" +
3874
			"element:finalize    completion:finalize()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +		
3985
			"public class CompletionInsideExtends4 {\n" +
3875
			"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3986
			"  public class CompletionInsideExtends4Inner extends CompletionInsideExtends{\n" +
3876
			"element:getClass    completion:getClass()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3987
			"    public class CompletionInsideExtends4InnerInner {\n" +
3877
			"element:hashCode    completion:hashCode()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3988
			"    }\n" +
3878
			"element:notify    completion:notify()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3989
			"  }\n" +
3879
			"element:notifyAll    completion:notifyAll()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3990
			"\n}" +
3880
			"element:toString    completion:toString()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3991
			"class CompletionInsideExtends4TopLevel {\n" +
3881
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3992
			"}");
3882
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3993
	
3883
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3994
	
3884
			requestor.getResults());
3995
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3885
	} else {
3996
	String str = this.wc.getSource();
3886
		assertEquals(
3997
	String completeBehind = "extends CompletionInsideExtends";
3887
			"element:A    completion:A    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3998
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3888
			"element:CompletionEmptyTypeName2    completion:CompletionEmptyTypeName2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3999
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3889
			"element:a    completion:a    relevance:"+(R_DEFAULT + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
4000
3890
			"element:clone    completion:clone()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
4001
	assertResults(
3891
			"element:equals    completion:equals()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
4002
			"CompletionInsideExtends4[TYPE_REF]{CompletionInsideExtends4, test, Ltest.CompletionInsideExtends4;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
3892
			"element:finalize    completion:finalize()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +		
4003
			"CompletionInsideExtends4TopLevel[TYPE_REF]{CompletionInsideExtends4TopLevel, test, Ltest.CompletionInsideExtends4TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
3893
			"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3894
			"element:getClass    completion:getClass()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3895
			"element:hashCode    completion:hashCode()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3896
			"element:notify    completion:notify()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3897
			"element:notifyAll    completion:notifyAll()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3898
			"element:toString    completion:toString()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3899
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3900
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3901
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
3902
			requestor.getResults());
4004
			requestor.getResults());
3903
	}
3904
}
4005
}
3905
/*
3906
* http://dev.eclipse.org/bugs/show_bug.cgi?id=41643
3907
*/
3908
public void testCompletionEmptyTypeName3() throws JavaModelException {
3909
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
3910
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionEmptyTypeName3.java");
3911
4006
3912
	String str = cu.getSource();
4007
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
3913
	String completeBehind = " = ";
4008
public void testCompletionInsideExtends5() throws JavaModelException {
4009
	this.wc = getWorkingCopy(
4010
			"/Completion/src/test/CompletionInsideExtends5.java",
4011
			"package test;\n" +
4012
			"public class CompletionInsideExtends5 {\n" +
4013
			"  void foo() {\n" +
4014
			"    public class CompletionInsideExtends5Inner extends {\n" +
4015
			"      public class CompletionInsideExtends5InnerInner {\n" +
4016
			"      }\n" +
4017
			"    }\n" +
4018
			"  }\n" +
4019
			"}\n" +
4020
			"class CompletionInsideExtends5TopLevel {\n" +
4021
			"}");
4022
	
4023
	
4024
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
4025
	String str = this.wc.getSource();
4026
	String completeBehind = "extends ";
3914
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4027
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3915
	cu.codeComplete(cursorLocation, requestor);
4028
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3916
4029
3917
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
4030
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
3918
		assertEquals(
3919
			"element:clone    completion:clone()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3920
			"element:equals    completion:equals()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3921
			"element:finalize    completion:finalize()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +		
3922
			"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3923
			"element:getClass    completion:getClass()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3924
			"element:hashCode    completion:hashCode()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3925
			"element:notify    completion:notify()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3926
			"element:notifyAll    completion:notifyAll()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3927
			"element:toString    completion:toString()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3928
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3929
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3930
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3931
			"element:x    completion:x    relevance:"+(R_DEFAULT + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE+ R_NON_RESTRICTED),
3932
			requestor.getResults());
3933
	} else {
3934
		assertEquals(
3935
			"element:CompletionEmptyTypeName2    completion:CompletionEmptyTypeName2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
3936
			"element:CompletionEmptyTypeName3    completion:CompletionEmptyTypeName3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3937
			"element:CompletionEmptyTypeName3.CompletionEmptyTypeName3_1    completion:CompletionEmptyTypeName3_1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3938
			"element:CompletionEmptyTypeName3_2    completion:CompletionEmptyTypeName3_2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3939
			"element:clone    completion:clone()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3940
			"element:equals    completion:equals()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3941
			"element:finalize    completion:finalize()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +		
3942
			"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3943
			"element:getClass    completion:getClass()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3944
			"element:hashCode    completion:hashCode()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3945
			"element:notify    completion:notify()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3946
			"element:notifyAll    completion:notifyAll()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3947
			"element:toString    completion:toString()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3948
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3949
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3950
			"element:wait    completion:wait()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
3951
			"element:x    completion:x    relevance:"+(R_DEFAULT + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE+ R_NON_RESTRICTED),
3952
			requestor.getResults());
3953
	}
3954
}
3955
/*
3956
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25578
3957
*/
3958
public void testCompletionAbstractMethodRelevance1() throws JavaModelException {
3959
	ICompilationUnit superClass = null;
3960
	try {
3961
		superClass = getWorkingCopy(
3962
	            "/Completion/src/CompletionAbstractSuperClass.java",
3963
	            "public abstract class CompletionAbstractSuperClass {\n"+
3964
	            "	public void foo1(){}\n"+
3965
	            "	public abstract void foo2();\n"+
3966
	            "	public void foo3(){}\n"+
3967
	            "}");
3968
		
3969
		this.wc = getWorkingCopy(
3970
	            "/Completion/src/CompletionAbstractMethodRelevance1.java",
3971
	            "public class CompletionAbstractMethodRelevance1 extends CompletionAbstractSuperClass {\n"+
3972
	            "	foo\n"+
3973
	            "}");
3974
	    
3975
	    
3976
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
3977
	    String str = this.wc.getSource();
3978
	    String completeBehind = "foo";
3979
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
3980
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
3981
	
3982
		assertResults(
4031
		assertResults(
3983
			"foo[POTENTIAL_METHOD_DECLARATION]{foo, LCompletionAbstractMethodRelevance1;, ()V, foo, null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n" +
4032
				"",
3984
			"foo1[METHOD_DECLARATION]{public void foo1(), LCompletionAbstractSuperClass;, ()V, foo1, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n" +
4033
				requestor.getResults());
3985
			"foo3[METHOD_DECLARATION]{public void foo3(), LCompletionAbstractSuperClass;, ()V, foo3, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n" +
4034
	} else {
3986
			"foo2[METHOD_DECLARATION]{public void foo2(), LCompletionAbstractSuperClass;, ()V, foo2, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_ABSTRACT_METHOD + R_METHOD_OVERIDE+ R_NON_RESTRICTED)+"}",
3987
			requestor.getResults());
3988
	} finally {
3989
		if(superClass != null) {
3990
			superClass.discardWorkingCopy();
3991
		}
3992
	}
3993
}
3994
/*
3995
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25578
3996
*/
3997
public void testCompletionAbstractMethodRelevance2() throws JavaModelException {
3998
	ICompilationUnit superClass = null;
3999
	try {
4000
		superClass = getWorkingCopy(
4001
	            "/Completion/src/CompletionSuperInterface.java",
4002
	            "public interface CompletionSuperInterface{\n"+
4003
	            "	public int eqFoo(int a,Object b);\n"+
4004
	            "}");
4005
		
4006
		this.wc = getWorkingCopy(
4007
	            "/Completion/src/CompletionAbstractMethodRelevance2.java",
4008
	            "public class CompletionAbstractMethodRelevance2 implements CompletionSuperInterface {\n"+
4009
	            "	eq\n"+
4010
	            "}");
4011
	    
4012
	    
4013
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
4014
	    String str = this.wc.getSource();
4015
	    String completeBehind = "eq";
4016
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4017
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
4018
	
4019
		assertResults(
4035
		assertResults(
4020
			"eq[POTENTIAL_METHOD_DECLARATION]{eq, LCompletionAbstractMethodRelevance2;, ()V, eq, null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n" +
4036
				"CompletionInsideExtends5[TYPE_REF]{CompletionInsideExtends5, test, Ltest.CompletionInsideExtends5;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
4021
			"equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n" +
4037
				"CompletionInsideExtends5TopLevel[TYPE_REF]{CompletionInsideExtends5TopLevel, test, Ltest.CompletionInsideExtends5TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
4022
			"eqFoo[METHOD_DECLARATION]{public int eqFoo(int a, Object b), LCompletionSuperInterface;, (ILjava.lang.Object;)I, eqFoo, (a, b), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_ABSTRACT_METHOD + R_METHOD_OVERIDE+ R_NON_RESTRICTED)+"}",
4038
				requestor.getResults());
4023
			requestor.getResults());
4024
	} finally {
4025
		if(superClass != null) {
4026
			superClass.discardWorkingCopy();
4027
		}
4028
	}
4039
	}
4029
}
4040
}
4030
/*
4031
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25591
4032
*/
4033
public void testCompletionReturnInInitializer() throws JavaModelException {
4034
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4035
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionReturnInInitializer.java");
4036
4041
4037
	String str = cu.getSource();
4042
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
4038
	String completeBehind = "eq";
4043
public void testCompletionInsideExtends6() throws JavaModelException {
4044
	this.wc = getWorkingCopy(
4045
			"/Completion/src/test/CompletionInsideExtends6.java",
4046
			"package test;\n" +
4047
			"public class CompletionInsideExtends6 {\n" +
4048
			"  void foo() {\n" +
4049
			"    public class CompletionInsideExtends6Inner extends CompletionInsideExtends {\n" +
4050
			"      public class CompletionInsideExtends6InnerInner {\n" +
4051
			"      }\n" +
4052
			"    }\n" +
4053
			"  }\n" +
4054
			"}\n" +
4055
			"class CompletionInsideExtends6TopLevel {\n" +
4056
			"}");
4057
	
4058
	
4059
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
4060
	String str = this.wc.getSource();
4061
	String completeBehind = "extends CompletionInsideExtends";
4039
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4062
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4040
	cu.codeComplete(cursorLocation, requestor);
4063
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
4041
4064
4042
	assertEquals(
4065
	assertResults(
4043
		"element:equals    completion:equals()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
4066
			"CompletionInsideExtends6[TYPE_REF]{CompletionInsideExtends6, test, Ltest.CompletionInsideExtends6;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
4044
		requestor.getResults());
4067
			"CompletionInsideExtends6TopLevel[TYPE_REF]{CompletionInsideExtends6TopLevel, test, Ltest.CompletionInsideExtends6TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
4068
			requestor.getResults());
4045
}
4069
}
4046
/*
4047
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25811
4048
*/
4049
public void testCompletionVariableName1() throws JavaModelException {
4050
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4051
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableName1.java");
4052
4070
4053
	String str = cu.getSource();
4071
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
4054
	String completeBehind = "TEST_FOO_MyClass ";
4072
public void testCompletionInsideExtends7() throws JavaModelException {
4073
	this.wc = getWorkingCopy(
4074
			"/Completion/src/test/CompletionInsideExtends7.java",
4075
			"package test;\n" +
4076
			"public interface CompletionInsideExtends7 extends  {\n" +
4077
			"  public interface CompletionInsideExtends7Inner {}\n" +
4078
			"}\n" +
4079
			"interface CompletionInsideExtends7TopLevel {\n" +
4080
			"}");
4081
	
4082
	
4083
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
4084
	String str = this.wc.getSource();
4085
	String completeBehind = "extends ";
4055
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4086
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4056
	cu.codeComplete(cursorLocation, requestor);
4087
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
4057
4088
4058
	assertEquals(
4089
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
4059
		"element:class1    completion:class1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
4090
		assertResults(
4060
		"element:myClass    completion:myClass    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4091
				"",
4061
		requestor.getResults());
4092
				requestor.getResults());
4093
	} else {
4094
		assertResults(
4095
				"CompletionInsideExtends7TopLevel[TYPE_REF]{CompletionInsideExtends7TopLevel, test, Ltest.CompletionInsideExtends7TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
4096
				requestor.getResults());
4097
	}
4062
}
4098
}
4063
/*
4099
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
4064
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25811
4100
public void testCompletionInsideExtends8() throws JavaModelException {
4065
*/
4101
	this.wc = getWorkingCopy(
4066
public void testCompletionVariableName2() throws JavaModelException {
4102
			"/Completion/src/test/CompletionInsideExtends8.java",
4067
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4103
			"package test;\n" +
4068
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableName2.java");
4104
			"public interface CompletionInsideExtends8 extends CompletionInsideExtends {\n" +
4069
4105
			"  public interface CompletionInsideExtends8Inner {}\n" +
4070
	String str = cu.getSource();
4106
			"}\n" +
4071
	String completeBehind = "Test_Bar_MyClass ";
4107
			"interface CompletionInsideExtends8TopLevel {\n" +
4108
			"}");
4109
	
4110
	
4111
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
4112
	String str = this.wc.getSource();
4113
	String completeBehind = "extends CompletionInsideExtends";
4072
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4114
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4073
	cu.codeComplete(cursorLocation, requestor);
4115
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
4074
4116
4075
	assertEquals(
4117
	assertResults(
4076
		"element:bar_MyClass    completion:bar_MyClass    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
4118
			"CompletionInsideExtends8TopLevel[TYPE_REF]{CompletionInsideExtends8TopLevel, test, Ltest.CompletionInsideExtends8TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
4077
		"element:class1    completion:class1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
4119
			requestor.getResults());
4078
		"element:myClass    completion:myClass    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
4079
		"element:test_Bar_MyClass    completion:test_Bar_MyClass    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4080
		requestor.getResults());
4081
}
4120
}
4082
/*
4083
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25820
4084
*/
4085
public void testCompletionExpectedTypeIsNotValid() throws JavaModelException {
4086
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4087
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionExpectedTypeIsNotValid.java");
4088
4121
4089
	String str = cu.getSource();
4122
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
4090
	String completeBehind = "new U";
4123
public void testCompletionInsideExtends9() throws JavaModelException {
4124
	this.wc = getWorkingCopy(
4125
			"/Completion/src/test/CompletionInsideExtends9.java",
4126
			"package test;\n" +
4127
			"public interface CompletionInsideExtends9 {\n" +
4128
			"  public interface CompletionInsideExtends9Inner extends {\n" +
4129
			"    public interface CompletionInsideExtends9InnerInner {\n" +
4130
			"    }\n" +
4131
			"  }\n" +
4132
			"}\n" +
4133
			"interface CompletionInsideExtends9TopLevel {\n" +
4134
			"}");
4135
	
4136
	
4137
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
4138
	String str = this.wc.getSource();
4139
	String completeBehind = "extends ";
4091
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4140
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4092
	cu.codeComplete(cursorLocation, requestor);
4141
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
4093
4142
4094
	assertEquals(
4143
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
4095
		"",
4144
		assertResults(
4096
		requestor.getResults());
4145
				"",
4146
				requestor.getResults());
4147
	} else {
4148
		assertResults(
4149
				"CompletionInsideExtends9[TYPE_REF]{CompletionInsideExtends9, test, Ltest.CompletionInsideExtends9;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
4150
				"CompletionInsideExtends9TopLevel[TYPE_REF]{CompletionInsideExtends9TopLevel, test, Ltest.CompletionInsideExtends9TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
4151
				requestor.getResults());
4152
	}
4097
}
4153
}
4098
/*
4154
4099
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25815
4155
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=82740
4100
*/
4156
public void testCompletionInsideGenericClass() throws JavaModelException {
4101
public void testCompletionMemberType() throws JavaModelException {
4102
	this.wc = getWorkingCopy(
4157
	this.wc = getWorkingCopy(
4103
            "/Completion/src/CompletionMemberType.java",
4158
			"/Completion/src/test/CompletionInsideGenericClass.java",
4104
            "public class CompletionMemberType {\n"+
4159
			"package test;\n" +
4105
            "	public class Y {\n"+
4160
			"public class CompletionInsideGenericClass <CompletionInsideGenericClassParameter> {\n" +
4106
            "		public void foo(){\n"+
4161
			"  CompletionInsideGenericClas\n" +
4107
            "			Y var = new Y\n"+
4162
			"}");
4108
            "		}\n"+
4163
	
4109
            "	}\n"+
4164
	
4110
            "}");
4165
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
4111
    
4166
	String str = this.wc.getSource();
4112
    
4167
	String completeBehind = "CompletionInsideGenericClas";
4113
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
4168
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4114
    String str = this.wc.getSource();
4169
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
4115
    String completeBehind = "new Y";
4116
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4117
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
4118
4170
4119
    assertResults(
4171
	assertResults(
4120
		"CompletionMemberType.Y[TYPE_REF]{Y, , LCompletionMemberType$Y;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_EXACT_NAME+ R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
4172
			"CompletionInsideGenericClas[POTENTIAL_METHOD_DECLARATION]{CompletionInsideGenericClas, Ltest.CompletionInsideGenericClass;, ()V, CompletionInsideGenericClas, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
4121
		requestor.getResults());
4173
			"CompletionInsideGenericClass[TYPE_REF]{CompletionInsideGenericClass, test, Ltest.CompletionInsideGenericClass;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
4174
			requestor.getResults());
4122
}
4175
}
4123
/*
4176
4124
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25815
4177
public void testCompletionInsideStaticMethod() throws JavaModelException {
4125
*/
4126
public void testCompletionVoidMethod() throws JavaModelException {
4127
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4178
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4128
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVoidMethod.java");
4179
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionInsideStaticMethod.java");
4129
4180
4130
	String str = cu.getSource();
4181
	String str = cu.getSource();
4131
	String completeBehind = "foo";
4182
	String completeBehind = "doT";
4132
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4183
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
4133
	cu.codeComplete(cursorLocation, requestor);
4184
	cu.codeComplete(cursorLocation, requestor);
4134
4185
4135
	assertEquals(
4186
	assertEquals(
4136
		"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
4187
			"element:doTheThing    completion:doTheThing()    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
4137
		"element:foo1    completion:foo1()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
4188
			requestor.getResults());
4138
		"element:foo3    completion:foo3()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
4139
		requestor.getResults());
4140
}
4189
}
4141
/*
4190
public void testCompletionInstanceofOperator1() throws JavaModelException {
4142
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25890
4143
*/
4144
public void testCompletionOnStaticMember1() throws JavaModelException {
4145
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4191
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4146
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionOnStaticMember1.java");
4192
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionInstanceofOperator1.java");
4147
4193
4148
		String str = cu.getSource();
4194
		String str = cu.getSource();
4149
		String completeBehind = "var";
4195
		String completeBehind = "x instanceof WWWCompletionInstanceof";
4150
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4196
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4151
		cu.codeComplete(cursorLocation, requestor);
4197
		cu.codeComplete(cursorLocation, requestor);
4152
4198
4153
		assertEquals(
4199
		assertEquals(
4154
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
4200
			"element:WWWCompletionInstanceof1    completion:WWWCompletionInstanceof1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
4155
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
4201
			"element:WWWCompletionInstanceof2    completion:WWWCompletionInstanceof2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
4202
			"element:WWWCompletionInstanceof3    completion:WWWCompletionInstanceof3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
4203
			"element:WWWCompletionInstanceof4    completion:WWWCompletionInstanceof4    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
4156
			requestor.getResults());
4204
			requestor.getResults());
4157
}
4205
}
4158
/*
4206
4159
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25890
4207
public void testCompletionKeywordAbstract1() throws JavaModelException {
4160
*/
4161
public void testCompletionOnStaticMember2() throws JavaModelException {
4162
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4208
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4163
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionOnStaticMember2.java");
4209
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract1.java");
4164
4210
4165
		String str = cu.getSource();
4211
		String str = cu.getSource();
4166
		String completeBehind = "method";
4212
		String completeBehind = "abs";
4167
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4213
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4168
		cu.codeComplete(cursorLocation, requestor);
4214
		cu.codeComplete(cursorLocation, requestor);
4169
4215
4170
		assertEquals(
4216
		assertEquals(
4171
			"element:method1    completion:method1()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
4217
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4172
			"element:method2    completion:method2()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
4173
			requestor.getResults());
4218
			requestor.getResults());
4174
}
4219
}
4175
/*
4176
* http://dev.eclipse.org/bugs/show_bug.cgi?id=26677
4177
*/
4178
public void testCompletionQualifiedExpectedType() throws JavaModelException {
4179
	this.wc = getWorkingCopy(
4180
            "/Completion/src/test/CompletionQualifiedExpectedType.java",
4181
            "import pack1.PX;\n"+
4182
            "\n"+
4183
            "public class CompletionQualifiedExpectedType {\n"+
4184
            "	void foo() {\n"+
4185
            "		pack2.PX var = new \n"+
4186
            "	}\n"+
4187
            "}");
4188
    
4189
    
4190
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
4191
    String str = this.wc.getSource();
4192
    String completeBehind = "new ";
4193
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4194
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
4195
4220
4196
    if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
4221
public void testCompletionKeywordAbstract10() throws JavaModelException {
4197
    	assertResults(
4198
	            "PX[TYPE_REF]{pack2.PX, pack2, Lpack2.PX;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE+ R_NON_RESTRICTED)+ "}",
4199
				requestor.getResults());
4200
    } else {
4201
	    assertResults(
4202
	            "CompletionQualifiedExpectedType[TYPE_REF]{CompletionQualifiedExpectedType, test, Ltest.CompletionQualifiedExpectedType;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
4203
				"PX[TYPE_REF]{pack2.PX, pack2, Lpack2.PX;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE+ R_NON_RESTRICTED)+ "}",
4204
				requestor.getResults());
4205
    }
4206
}
4207
public void testCompletionUnaryOperator1() throws JavaModelException {
4208
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4222
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4209
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionUnaryOperator1.java");
4223
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract10.java");
4210
4224
4211
		String str = cu.getSource();
4225
		String str = cu.getSource();
4212
		String completeBehind = "var";
4226
		String completeBehind = "abs";
4213
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4227
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4214
		cu.codeComplete(cursorLocation, requestor);
4228
		cu.codeComplete(cursorLocation, requestor);
4215
4229
4216
		assertEquals(
4230
		assertEquals(
4217
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
4231
			"",
4218
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
4219
			"element:var3    completion:var3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
4220
			requestor.getResults());
4232
			requestor.getResults());
4221
}
4233
}
4222
public void testCompletionUnaryOperator2() throws JavaModelException {
4234
4235
public void testCompletionKeywordAbstract11() throws JavaModelException {
4223
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4236
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4224
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionUnaryOperator2.java");
4237
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract11.java");
4225
4238
4226
		String str = cu.getSource();
4239
		String str = cu.getSource();
4227
		String completeBehind = "var";
4240
		String completeBehind = "abs";
4228
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4241
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4229
		cu.codeComplete(cursorLocation, requestor);
4242
		cu.codeComplete(cursorLocation, requestor);
4230
4243
4231
		assertEquals(
4244
		assertEquals(
4232
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
4245
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4233
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
4234
			"element:var3    completion:var3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
4235
			requestor.getResults());
4246
			requestor.getResults());
4236
}
4247
}
4237
public void testCompletionBinaryOperator1() throws JavaModelException {
4248
public void testCompletionKeywordAbstract12() throws JavaModelException {
4238
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4249
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4239
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBinaryOperator1.java");
4250
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract12.java");
4240
4251
4241
		String str = cu.getSource();
4252
		String str = cu.getSource();
4242
		String completeBehind = "var";
4253
		String completeBehind = "abs";
4243
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4254
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4244
		cu.codeComplete(cursorLocation, requestor);
4255
		cu.codeComplete(cursorLocation, requestor);
4245
4256
4246
		assertEquals(
4257
		assertEquals(
4247
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
4258
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4248
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
4249
			"element:var3    completion:var3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
4250
			"element:var4    completion:var4    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE+ R_NON_RESTRICTED),
4251
			requestor.getResults());
4259
			requestor.getResults());
4252
}
4260
}
4253
public void testCompletionBinaryOperator2() throws JavaModelException {
4261
4262
public void testCompletionKeywordAbstract13() throws JavaModelException {
4254
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4263
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4255
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBinaryOperator2.java");
4264
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract13.java");
4256
4265
4257
		String str = cu.getSource();
4266
		String str = cu.getSource();
4258
		String completeBehind = "var";
4267
		String completeBehind = "abs";
4259
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4268
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4260
		cu.codeComplete(cursorLocation, requestor);
4269
		cu.codeComplete(cursorLocation, requestor);
4261
4270
4262
		assertEquals(
4271
		assertEquals(
4263
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
4272
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4264
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
4265
			"element:var3    completion:var3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
4266
			requestor.getResults());
4273
			requestor.getResults());
4267
}
4274
}
4268
public void testCompletionBinaryOperator3() throws JavaModelException {
4275
4276
public void testCompletionKeywordAbstract14() throws JavaModelException {
4269
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4277
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4270
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBinaryOperator3.java");
4278
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract14.java");
4271
4279
4272
		String str = cu.getSource();
4280
		String str = cu.getSource();
4273
		String completeBehind = "var";
4281
		String completeBehind = "abs";
4274
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4282
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4275
		cu.codeComplete(cursorLocation, requestor);
4283
		cu.codeComplete(cursorLocation, requestor);
4276
4284
4277
		assertEquals(
4285
		assertEquals(
4278
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
4286
			"",
4279
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
4280
			"element:var3    completion:var3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
4281
			requestor.getResults());
4287
			requestor.getResults());
4282
}
4288
}
4283
public void testCompletionInstanceofOperator1() throws JavaModelException {
4289
4290
public void testCompletionKeywordAbstract15() throws JavaModelException {
4284
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4291
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4285
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionInstanceofOperator1.java");
4292
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract15.java");
4286
4293
4287
		String str = cu.getSource();
4294
		String str = cu.getSource();
4288
		String completeBehind = "x instanceof WWWCompletionInstanceof";
4295
		String completeBehind = "abs";
4289
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4296
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4290
		cu.codeComplete(cursorLocation, requestor);
4297
		cu.codeComplete(cursorLocation, requestor);
4291
4298
4292
		assertEquals(
4299
		assertEquals(
4293
			"element:WWWCompletionInstanceof1    completion:WWWCompletionInstanceof1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
4300
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4294
			"element:WWWCompletionInstanceof2    completion:WWWCompletionInstanceof2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
4295
			"element:WWWCompletionInstanceof3    completion:WWWCompletionInstanceof3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
4296
			"element:WWWCompletionInstanceof4    completion:WWWCompletionInstanceof4    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
4297
			requestor.getResults());
4301
			requestor.getResults());
4298
}
4302
}
4299
public void testCompletionConditionalExpression1() throws JavaModelException {
4303
public void testCompletionKeywordAbstract16() throws JavaModelException {
4300
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4304
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4301
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionConditionalExpression1.java");
4305
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract16.java");
4302
4306
4303
		String str = cu.getSource();
4307
		String str = cu.getSource();
4304
		String completeBehind = "var";
4308
		String completeBehind = "abs";
4305
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4309
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4306
		cu.codeComplete(cursorLocation, requestor);
4310
		cu.codeComplete(cursorLocation, requestor);
4307
4311
4308
		assertEquals(
4312
		assertEquals(
4309
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
4313
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4310
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
4311
			"element:var3    completion:var3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
4312
			"element:var4    completion:var4    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
4313
			requestor.getResults());
4314
			requestor.getResults());
4314
}
4315
}
4315
public void testCompletionConditionalExpression2() throws JavaModelException {
4316
public void testCompletionKeywordAbstract2() throws JavaModelException {
4316
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4317
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4317
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionConditionalExpression2.java");
4318
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract2.java");
4318
4319
4319
		String str = cu.getSource();
4320
		String str = cu.getSource();
4320
		String completeBehind = "var";
4321
		String completeBehind = "abs";
4321
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4322
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4322
		cu.codeComplete(cursorLocation, requestor);
4323
		cu.codeComplete(cursorLocation, requestor);
4323
4324
4324
		assertEquals(
4325
		assertEquals(
4325
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
4326
			"",
4326
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
4327
			"element:var3    completion:var3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
4328
			"element:var4    completion:var4    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
4329
			requestor.getResults());
4327
			requestor.getResults());
4330
}
4328
}
4331
public void testCompletionConditionalExpression3() throws JavaModelException {
4329
public void testCompletionKeywordAbstract3() throws JavaModelException {
4332
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4330
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4333
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionConditionalExpression3.java");
4331
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract3.java");
4334
4332
4335
		String str = cu.getSource();
4333
		String str = cu.getSource();
4336
		String completeBehind = "var";
4334
		String completeBehind = "abs";
4337
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4335
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4338
		cu.codeComplete(cursorLocation, requestor);
4336
		cu.codeComplete(cursorLocation, requestor);
4339
4337
4340
		assertEquals(
4338
		assertEquals(
4341
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
4339
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4342
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
4343
			"element:var3    completion:var3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
4344
			"element:var4    completion:var4    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
4345
			requestor.getResults());
4340
			requestor.getResults());
4346
}
4341
}
4347
public void testCompletionKeywordThis1() throws JavaModelException {
4342
public void testCompletionKeywordAbstract4() throws JavaModelException {
4348
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4343
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4349
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis1.java");
4344
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract4.java");
4350
4345
4351
		String str = cu.getSource();
4346
		String str = cu.getSource();
4352
		String completeBehind = "thi";
4347
		String completeBehind = "abs";
4353
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4348
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4354
		cu.codeComplete(cursorLocation, requestor);
4349
		cu.codeComplete(cursorLocation, requestor);
4355
4350
4356
		assertEquals(
4351
		assertEquals(
4357
			"element:this    completion:this    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4352
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4358
			requestor.getResults());
4353
			requestor.getResults());
4359
}
4354
}
4360
public void testCompletionKeywordThis2() throws JavaModelException {
4355
public void testCompletionKeywordAbstract5() throws JavaModelException {
4361
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4356
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4362
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis2.java");
4357
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract5.java");
4363
4358
4364
		String str = cu.getSource();
4359
		String str = cu.getSource();
4365
		String completeBehind = "thi";
4360
		String completeBehind = "abs";
4366
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4361
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4367
		cu.codeComplete(cursorLocation, requestor);
4362
		cu.codeComplete(cursorLocation, requestor);
4368
4363
4369
		assertEquals(
4364
		assertEquals(
4370
			"element:this    completion:this    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4365
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4371
			requestor.getResults());
4366
			requestor.getResults());
4372
}
4367
}
4373
public void testCompletionKeywordThis3() throws JavaModelException {
4368
public void testCompletionKeywordAbstract6() throws JavaModelException {
4374
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4369
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4375
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis3.java");
4370
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract6.java");
4376
4371
4377
		String str = cu.getSource();
4372
		String str = cu.getSource();
4378
		String completeBehind = "thi";
4373
		String completeBehind = "abs";
4379
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4374
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4380
		cu.codeComplete(cursorLocation, requestor);
4375
		cu.codeComplete(cursorLocation, requestor);
4381
4376
Lines 4383-4693 Link Here
4383
			"",
4378
			"",
4384
			requestor.getResults());
4379
			requestor.getResults());
4385
}
4380
}
4386
public void testCompletionKeywordThis4() throws JavaModelException {
4381
public void testCompletionKeywordAbstract7() throws JavaModelException {
4387
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4382
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4388
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis4.java");
4383
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract7.java");
4389
4384
4390
		String str = cu.getSource();
4385
		String str = cu.getSource();
4391
		String completeBehind = "thi";
4386
		String completeBehind = "abs";
4392
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4387
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4393
		cu.codeComplete(cursorLocation, requestor);
4388
		cu.codeComplete(cursorLocation, requestor);
4394
4389
4395
		assertEquals(
4390
		assertEquals(
4396
			"element:this    completion:this    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4391
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4397
			requestor.getResults());
4392
			requestor.getResults());
4398
}
4393
}
4399
public void testCompletionKeywordThis5() throws JavaModelException {
4394
public void testCompletionKeywordAbstract8() throws JavaModelException {
4400
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4395
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4401
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis5.java");
4396
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract8.java");
4402
4397
4403
		String str = cu.getSource();
4398
		String str = cu.getSource();
4404
		String completeBehind = "thi";
4399
		String completeBehind = "abs";
4405
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4400
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4406
		cu.codeComplete(cursorLocation, requestor);
4401
		cu.codeComplete(cursorLocation, requestor);
4407
4402
4408
		assertEquals(
4403
		assertEquals(
4409
			"",
4404
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4410
			requestor.getResults());
4405
			requestor.getResults());
4411
}
4406
}
4412
public void testCompletionKeywordThis6() throws JavaModelException {
4407
public void testCompletionKeywordAbstract9() throws JavaModelException {
4413
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4408
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4414
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis6.java");
4409
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract9.java");
4415
4410
4416
		String str = cu.getSource();
4411
		String str = cu.getSource();
4417
		String completeBehind = "thi";
4412
		String completeBehind = "abs";
4418
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4413
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4419
		cu.codeComplete(cursorLocation, requestor);
4414
		cu.codeComplete(cursorLocation, requestor);
4420
4415
4421
		assertEquals(
4416
		assertEquals(
4422
			"element:this    completion:this    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED),
4417
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4423
			requestor.getResults());
4418
			requestor.getResults());
4424
}
4419
}
4425
public void testCompletionKeywordThis7() throws JavaModelException {
4420
public void testCompletionKeywordAssert1() throws JavaModelException {
4426
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4421
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4427
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis7.java");
4422
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAssert1.java");
4428
4423
4429
		String str = cu.getSource();
4424
		String str = cu.getSource();
4430
		String completeBehind = "thi";
4425
		String completeBehind = "as";
4431
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4426
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4432
		cu.codeComplete(cursorLocation, requestor);
4427
		cu.codeComplete(cursorLocation, requestor);
4433
4428
4434
		assertEquals(
4429
		assertEquals(
4435
			"",
4430
			"element:assert    completion:assert    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4436
			requestor.getResults());
4431
			requestor.getResults());
4437
}
4432
}
4438
public void testCompletionKeywordSuper1() throws JavaModelException {
4433
public void testCompletionKeywordAssert2() throws JavaModelException {
4439
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4434
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4440
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper1.java");
4435
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAssert2.java");
4441
4436
4442
		String str = cu.getSource();
4437
		String str = cu.getSource();
4443
		String completeBehind = "sup";
4438
		String completeBehind = "as";
4444
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4439
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4445
		cu.codeComplete(cursorLocation, requestor);
4440
		cu.codeComplete(cursorLocation, requestor);
4446
4441
4447
		assertEquals(
4442
		assertEquals(
4448
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
4443
			"",
4449
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
4450
			"element:super    completion:super    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4451
			requestor.getResults());
4444
			requestor.getResults());
4452
}
4445
}
4453
public void testCompletionKeywordSuper2() throws JavaModelException {
4446
public void testCompletionKeywordAssert3() throws JavaModelException {
4454
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4447
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4455
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper2.java");
4448
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAssert3.java");
4456
4449
4457
		String str = cu.getSource();
4450
		String str = cu.getSource();
4458
		String completeBehind = "sup";
4451
		String completeBehind = "as";
4459
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4452
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4460
		cu.codeComplete(cursorLocation, requestor);
4453
		cu.codeComplete(cursorLocation, requestor);
4461
4454
4462
		assertEquals(
4455
		assertEquals(
4463
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
4456
			"",
4464
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
4465
			"element:super    completion:super    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4466
			requestor.getResults());
4457
			requestor.getResults());
4467
}
4458
}
4468
public void testCompletionKeywordSuper3() throws JavaModelException {
4459
public void testCompletionKeywordAssert4() throws JavaModelException {
4469
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4460
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4470
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper3.java");
4461
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAssert4.java");
4471
4462
4472
		String str = cu.getSource();
4463
		String str = cu.getSource();
4473
		String completeBehind = "sup";
4464
		String completeBehind = "as";
4474
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4465
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4475
		cu.codeComplete(cursorLocation, requestor);
4466
		cu.codeComplete(cursorLocation, requestor);
4476
4467
4477
		assertEquals(
4468
		assertEquals(
4478
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
4469
			"element:assert    completion:assert    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4479
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
4480
			requestor.getResults());
4470
			requestor.getResults());
4481
}
4471
}
4482
public void testCompletionKeywordSuper4() throws JavaModelException {
4472
public void testCompletionKeywordAssert5() throws JavaModelException {
4483
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4473
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4484
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper4.java");
4474
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAssert5.java");
4485
4475
4486
		String str = cu.getSource();
4476
		String str = cu.getSource();
4487
		String completeBehind = "sup";
4477
		String completeBehind = "as";
4488
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4478
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4489
		cu.codeComplete(cursorLocation, requestor);
4479
		cu.codeComplete(cursorLocation, requestor);
4490
4480
4491
		assertEquals(
4481
		assertEquals(
4492
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
4482
			"",
4493
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
4494
			"element:super    completion:super    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4495
			requestor.getResults());
4483
			requestor.getResults());
4496
}
4484
}
4497
public void testCompletionKeywordSuper5() throws JavaModelException {
4485
public void testCompletionKeywordAssert6() throws JavaModelException {
4498
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4486
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4499
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper5.java");
4487
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAssert6.java");
4500
4488
4501
		String str = cu.getSource();
4489
		String str = cu.getSource();
4502
		String completeBehind = "sup";
4490
		String completeBehind = "as";
4503
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4491
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4504
		cu.codeComplete(cursorLocation, requestor);
4492
		cu.codeComplete(cursorLocation, requestor);
4505
4493
4506
		assertEquals(
4494
		assertEquals(
4507
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
4495
			"",
4508
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
4509
			requestor.getResults());
4510
}
4511
public void testCompletionKeywordSuper6() throws JavaModelException {
4512
	this.wc = getWorkingCopy(
4513
            "/Completion/src2/CompletionKeywordSuper6.java",
4514
            "public class CompletionKeywordSuper6 {\n"+
4515
            "	public CompletionKeywordSuper6() {\n"+
4516
            "		sup\n"+
4517
            "	}\n"+
4518
            "}");
4519
    
4520
    
4521
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
4522
    
4523
    String str = this.wc.getSource();
4524
    String completeBehind = "sup";
4525
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4526
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
4527
4528
    assertResults(
4529
            "expectedTypesSignatures=null\n"+
4530
            "expectedTypesKeys=null",
4531
            requestor.getContext());
4532
    
4533
    assertResults(
4534
            "SuperClass[TYPE_REF]{SuperClass, , LSuperClass;, null, null, " + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
4535
			"SuperInterface[TYPE_REF]{SuperInterface, , LSuperInterface;, null, null, " + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
4536
			"super[KEYWORD]{super, null, null, super, null, "+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED)+"}\n" +
4537
			"super[METHOD_REF<CONSTRUCTOR>]{super(), Ljava.lang.Object;, ()V, super, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
4538
			requestor.getResults());
4496
			requestor.getResults());
4539
}
4497
}
4540
public void testCompletionKeywordTry1() throws JavaModelException {
4498
public void testCompletionKeywordBreak1() throws JavaModelException {
4541
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4499
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4542
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTry1.java");
4500
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordBreak1.java");
4543
4501
4544
		String str = cu.getSource();
4502
		String str = cu.getSource();
4545
		String completeBehind = "tr";
4503
		String completeBehind = "bre";
4546
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4504
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4547
		cu.codeComplete(cursorLocation, requestor);
4505
		cu.codeComplete(cursorLocation, requestor);
4548
4506
4549
		assertEquals(
4507
		assertEquals(
4550
			"element:try    completion:try    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4508
			"element:break    completion:break    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4551
			requestor.getResults());
4509
			requestor.getResults());
4552
}
4510
}
4553
public void testCompletionKeywordTry2() throws JavaModelException {
4511
public void testCompletionKeywordBreak2() throws JavaModelException {
4554
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4512
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4555
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTry2.java");
4513
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordBreak2.java");
4556
4514
4557
		String str = cu.getSource();
4515
		String str = cu.getSource();
4558
		String completeBehind = "tr";
4516
		String completeBehind = "bre";
4559
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4517
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4560
		cu.codeComplete(cursorLocation, requestor);
4518
		cu.codeComplete(cursorLocation, requestor);
4561
4519
4562
		assertEquals(
4520
		assertEquals(
4563
			"element:true    completion:true    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
4521
			"",
4564
			requestor.getResults());
4522
			requestor.getResults());
4565
}
4523
}
4566
public void testCompletionKeywordTry3() throws JavaModelException {
4524
public void testCompletionKeywordBreak3() throws JavaModelException {
4567
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4525
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4568
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTry3.java");
4526
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordBreak3.java");
4569
4527
4570
		String str = cu.getSource();
4528
		String str = cu.getSource();
4571
		String completeBehind = "try";
4529
		String completeBehind = "bre";
4572
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4530
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4573
		cu.codeComplete(cursorLocation, requestor);
4531
		cu.codeComplete(cursorLocation, requestor);
4574
4532
4575
		assertEquals(
4533
		assertEquals(
4576
			"",
4534
			"element:break    completion:break    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4577
			requestor.getResults());
4535
			requestor.getResults());
4578
}
4536
}
4579
public void testCompletionKeywordDo1() throws JavaModelException {
4537
public void testCompletionKeywordBreak4() throws JavaModelException {
4580
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4538
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4581
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDo1.java");
4539
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordBreak4.java");
4582
4540
4583
		String str = cu.getSource();
4541
		String str = cu.getSource();
4584
		String completeBehind = "do";
4542
		String completeBehind = "bre";
4585
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4543
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4586
		cu.codeComplete(cursorLocation, requestor);
4544
		cu.codeComplete(cursorLocation, requestor);
4587
4545
4588
		assertEquals(
4546
		assertEquals(
4589
			"element:do    completion:do    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"\n"+
4547
			"element:break    completion:break    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4590
			"element:double    completion:double    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4591
			requestor.getResults());
4548
			requestor.getResults());
4592
}
4549
}
4593
public void testCompletionKeywordDo2() throws JavaModelException {
4550
public void testCompletionKeywordBreak5() throws JavaModelException {
4594
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4551
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4595
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDo2.java");
4552
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordBreak5.java");
4596
4553
4597
		String str = cu.getSource();
4554
		String str = cu.getSource();
4598
		String completeBehind = "do";
4555
		String completeBehind = "bre";
4599
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4556
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4600
		cu.codeComplete(cursorLocation, requestor);
4557
		cu.codeComplete(cursorLocation, requestor);
4601
4558
4602
		assertEquals(
4559
		assertEquals(
4603
			"element:double    completion:double    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4560
			"",
4604
			requestor.getResults());
4561
			requestor.getResults());
4605
}
4562
}
4606
public void testCompletionKeywordDo3() throws JavaModelException {
4563
public void testCompletionKeywordBreak6() throws JavaModelException {
4607
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4564
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4608
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDo3.java");
4565
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordBreak6.java");
4609
4566
4610
		String str = cu.getSource();
4567
		String str = cu.getSource();
4611
		String completeBehind = "do";
4568
		String completeBehind = "bre";
4612
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4569
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4613
		cu.codeComplete(cursorLocation, requestor);
4570
		cu.codeComplete(cursorLocation, requestor);
4614
4571
4615
		assertEquals(
4572
		assertEquals(
4616
			"element:double    completion:double    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4573
			"element:break    completion:break    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4617
			requestor.getResults());
4574
			requestor.getResults());
4618
}
4575
}
4619
public void testCompletionKeywordFor1() throws JavaModelException {
4576
public void testCompletionKeywordCase1() throws JavaModelException {
4620
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4577
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4621
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFor1.java");
4578
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase1.java");
4622
4579
4623
		String str = cu.getSource();
4580
		String str = cu.getSource();
4624
		String completeBehind = "fo";
4581
		String completeBehind = "cas";
4625
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4582
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4626
		cu.codeComplete(cursorLocation, requestor);
4583
		cu.codeComplete(cursorLocation, requestor);
4627
4584
4628
		assertEquals(
4585
		assertEquals(
4629
			"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
4586
			"element:case    completion:case    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4630
			"element:for    completion:for    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4631
			requestor.getResults());
4587
			requestor.getResults());
4632
}
4588
}
4633
public void testCompletionKeywordFor2() throws JavaModelException {
4589
public void testCompletionKeywordCase10() throws JavaModelException {
4634
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4590
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4635
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFor2.java");
4591
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase10.java");
4636
4592
4637
		String str = cu.getSource();
4593
		String str = cu.getSource();
4638
		String completeBehind = "fo";
4594
		String completeBehind = "cas";
4639
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4595
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4640
		cu.codeComplete(cursorLocation, requestor);
4596
		cu.codeComplete(cursorLocation, requestor);
4641
4597
4642
		assertEquals(
4598
		assertEquals(
4643
			"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
4599
			"",
4644
			requestor.getResults());
4600
			requestor.getResults());
4645
}
4601
}
4646
public void testCompletionKeywordFor3() throws JavaModelException {
4602
public void testCompletionKeywordCase2() throws JavaModelException {
4647
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4603
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4648
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFor3.java");
4604
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase2.java");
4649
4605
4650
		String str = cu.getSource();
4606
		String str = cu.getSource();
4651
		String completeBehind = "fo";
4607
		String completeBehind = "cas";
4652
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4608
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4653
		cu.codeComplete(cursorLocation, requestor);
4609
		cu.codeComplete(cursorLocation, requestor);
4654
4610
4655
		assertEquals(
4611
		assertEquals(
4656
			"",
4612
			"element:case    completion:case    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4657
			requestor.getResults());
4613
			requestor.getResults());
4658
}
4614
}
4659
public void testCompletionKeywordIf1() throws JavaModelException {
4615
public void testCompletionKeywordCase3() throws JavaModelException {
4660
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4616
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4661
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordIf1.java");
4617
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase3.java");
4662
4618
4663
		String str = cu.getSource();
4619
		String str = cu.getSource();
4664
		String completeBehind = "if";
4620
		String completeBehind = "cas";
4665
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4621
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4666
		cu.codeComplete(cursorLocation, requestor);
4622
		cu.codeComplete(cursorLocation, requestor);
4667
4623
4668
		assertEquals(
4624
		assertEquals(
4669
			"element:if    completion:if    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME+ R_NON_RESTRICTED),
4625
			"element:case    completion:case    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4670
			requestor.getResults());
4626
			requestor.getResults());
4671
}
4627
}
4672
public void testCompletionKeywordIf2() throws JavaModelException {
4628
public void testCompletionKeywordCase4() throws JavaModelException {
4673
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4629
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4674
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordIf2.java");
4630
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase4.java");
4675
4631
4676
		String str = cu.getSource();
4632
		String str = cu.getSource();
4677
		String completeBehind = "if";
4633
		String completeBehind = "cas";
4678
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4634
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4679
		cu.codeComplete(cursorLocation, requestor);
4635
		cu.codeComplete(cursorLocation, requestor);
4680
4636
4681
		assertEquals(
4637
		assertEquals(
4682
			"",
4638
			"element:case    completion:case    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4683
			requestor.getResults());
4639
			requestor.getResults());
4684
}
4640
}
4685
public void testCompletionKeywordIf3() throws JavaModelException {
4641
public void testCompletionKeywordCase5() throws JavaModelException {
4686
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4642
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4687
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordIf3.java");
4643
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase5.java");
4688
4644
4689
		String str = cu.getSource();
4645
		String str = cu.getSource();
4690
		String completeBehind = "if";
4646
		String completeBehind = "cas";
4691
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4647
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4692
		cu.codeComplete(cursorLocation, requestor);
4648
		cu.codeComplete(cursorLocation, requestor);
4693
4649
Lines 4695-4850 Link Here
4695
			"",
4651
			"",
4696
			requestor.getResults());
4652
			requestor.getResults());
4697
}
4653
}
4698
public void testCompletionKeywordReturn1() throws JavaModelException {
4654
public void testCompletionKeywordCase6() throws JavaModelException {
4699
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4655
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4700
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn1.java");
4656
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase6.java");
4701
4657
4702
		String str = cu.getSource();
4658
		String str = cu.getSource();
4703
		String completeBehind = "re";
4659
		String completeBehind = "cas";
4704
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4660
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4705
		cu.codeComplete(cursorLocation, requestor);
4661
		cu.codeComplete(cursorLocation, requestor);
4706
4662
4707
		assertEquals(
4663
		assertEquals(
4708
			"element:return    completion:return    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4664
			"element:case    completion:case    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4709
			requestor.getResults());
4665
			requestor.getResults());
4710
}
4666
}
4711
public void testCompletionKeywordReturn2() throws JavaModelException {
4667
public void testCompletionKeywordCase7() throws JavaModelException {
4712
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4668
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4713
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn2.java");
4669
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase7.java");
4714
4670
4715
		String str = cu.getSource();
4671
		String str = cu.getSource();
4716
		String completeBehind = "re";
4672
		String completeBehind = "cas";
4717
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4673
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4718
		cu.codeComplete(cursorLocation, requestor);
4674
		cu.codeComplete(cursorLocation, requestor);
4719
4675
4720
		assertEquals(
4676
		assertEquals(
4721
			"",
4677
			"element:case    completion:case    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4722
			requestor.getResults());
4678
			requestor.getResults());
4723
}
4679
}
4724
public void testCompletionKeywordReturn3() throws JavaModelException {
4680
public void testCompletionKeywordCase8() throws JavaModelException {
4725
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4681
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4726
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn3.java");
4682
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase8.java");
4727
4683
4728
		String str = cu.getSource();
4684
		String str = cu.getSource();
4729
		String completeBehind = "re";
4685
		String completeBehind = "cas";
4730
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4686
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4731
		cu.codeComplete(cursorLocation, requestor);
4687
		cu.codeComplete(cursorLocation, requestor);
4732
4688
4733
		assertEquals(
4689
		assertEquals(
4734
			"",
4690
			"element:case    completion:case    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4735
			requestor.getResults());
4691
			requestor.getResults());
4736
}
4692
}
4737
public void testCompletionKeywordSwitch1() throws JavaModelException {
4693
public void testCompletionKeywordCase9() throws JavaModelException {
4738
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4694
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4739
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSwitch1.java");
4695
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase9.java");
4740
4696
4741
		String str = cu.getSource();
4697
		String str = cu.getSource();
4742
		String completeBehind = "sw";
4698
		String completeBehind = "cas";
4743
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4699
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4744
		cu.codeComplete(cursorLocation, requestor);
4700
		cu.codeComplete(cursorLocation, requestor);
4745
4701
4746
		assertEquals(
4702
		assertEquals(
4747
			"element:switch    completion:switch    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4703
			"element:case    completion:case    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4748
			requestor.getResults());
4704
			requestor.getResults());
4749
}
4705
}
4750
public void testCompletionKeywordSwitch2() throws JavaModelException {
4706
public void testCompletionKeywordCatch1() throws JavaModelException {
4751
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4707
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4752
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSwitch2.java");
4708
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch1.java");
4753
4709
4754
		String str = cu.getSource();
4710
		String str = cu.getSource();
4755
		String completeBehind = "sw";
4711
		String completeBehind = "cat";
4756
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4712
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4757
		cu.codeComplete(cursorLocation, requestor);
4713
		cu.codeComplete(cursorLocation, requestor);
4758
4714
4759
		assertEquals(
4715
		assertEquals(
4760
			"",
4716
			"element:catch    completion:catch    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4761
			requestor.getResults());
4717
			requestor.getResults());
4762
}
4718
}
4763
public void testCompletionKeywordSwitch3() throws JavaModelException {
4719
public void testCompletionKeywordCatch10() throws JavaModelException {
4764
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4720
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4765
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSwitch3.java");
4721
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch10.java");
4766
4722
4767
		String str = cu.getSource();
4723
		String str = cu.getSource();
4768
		String completeBehind = "sw";
4724
		String completeBehind = "cat";
4769
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4725
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4770
		cu.codeComplete(cursorLocation, requestor);
4726
		cu.codeComplete(cursorLocation, requestor);
4771
4727
4772
		assertEquals(
4728
		assertEquals(
4773
			"",
4729
			"element:catch    completion:catch    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
4730
			"element:catchz    completion:catchz    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
4774
			requestor.getResults());
4731
			requestor.getResults());
4775
}
4732
}
4776
public void testCompletionKeywordThrow1() throws JavaModelException {
4733
public void testCompletionKeywordCatch2() throws JavaModelException {
4777
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4734
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4778
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrow1.java");
4735
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch2.java");
4779
4736
4780
		String str = cu.getSource();
4737
		String str = cu.getSource();
4781
		String completeBehind = "thr";
4738
		String completeBehind = "cat";
4782
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4739
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4783
		cu.codeComplete(cursorLocation, requestor);
4740
		cu.codeComplete(cursorLocation, requestor);
4784
4741
4785
		assertEquals(
4742
		assertEquals(
4786
			"element:Throwable    completion:Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
4743
			"",
4787
			"element:throw    completion:throw    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4788
			requestor.getResults());
4744
			requestor.getResults());
4789
}
4745
}
4790
public void testCompletionKeywordThrow2() throws JavaModelException {
4746
public void testCompletionKeywordCatch3() throws JavaModelException {
4791
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4747
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4792
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrow2.java");
4748
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch3.java");
4793
4749
4794
		String str = cu.getSource();
4750
		String str = cu.getSource();
4795
		String completeBehind = "thr";
4751
		String completeBehind = "cat";
4796
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4752
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4797
		cu.codeComplete(cursorLocation, requestor);
4753
		cu.codeComplete(cursorLocation, requestor);
4798
4754
4799
		assertEquals(
4755
		assertEquals(
4800
			"element:Throwable    completion:Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
4756
			"",
4801
			requestor.getResults());
4757
			requestor.getResults());
4802
}
4758
}
4803
public void testCompletionKeywordThrow3() throws JavaModelException {
4759
public void testCompletionKeywordCatch4() throws JavaModelException {
4804
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4760
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4805
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrow3.java");
4761
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch4.java");
4806
4762
4807
		String str = cu.getSource();
4763
		String str = cu.getSource();
4808
		String completeBehind = "thr";
4764
		String completeBehind = "cat";
4809
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4765
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4810
		cu.codeComplete(cursorLocation, requestor);
4766
		cu.codeComplete(cursorLocation, requestor);
4811
4767
4812
		assertEquals(
4768
		assertEquals(
4813
			"element:Throwable    completion:Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
4769
			"",
4814
			requestor.getResults());
4770
			requestor.getResults());
4815
}
4771
}
4816
public void testCompletionKeywordAssert1() throws JavaModelException {
4772
public void testCompletionKeywordCatch5() throws JavaModelException {
4817
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4773
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4818
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAssert1.java");
4774
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch5.java");
4819
4775
4820
		String str = cu.getSource();
4776
		String str = cu.getSource();
4821
		String completeBehind = "as";
4777
		String completeBehind = "cat";
4822
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4778
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4823
		cu.codeComplete(cursorLocation, requestor);
4779
		cu.codeComplete(cursorLocation, requestor);
4824
4780
4825
		assertEquals(
4781
		assertEquals(
4826
			"element:assert    completion:assert    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4782
			"element:catch    completion:catch    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
4783
			"element:catchz    completion:catchz    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
4827
			requestor.getResults());
4784
			requestor.getResults());
4828
}
4785
}
4829
public void testCompletionKeywordAssert2() throws JavaModelException {
4786
public void testCompletionKeywordCatch6() throws JavaModelException {
4830
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4787
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4831
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAssert2.java");
4788
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch6.java");
4832
4789
4833
		String str = cu.getSource();
4790
		String str = cu.getSource();
4834
		String completeBehind = "as";
4791
		String completeBehind = "cat";
4835
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4792
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4836
		cu.codeComplete(cursorLocation, requestor);
4793
		cu.codeComplete(cursorLocation, requestor);
4837
4794
4838
		assertEquals(
4795
		assertEquals(
4839
			"",
4796
			"element:catch    completion:catch    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4840
			requestor.getResults());
4797
			requestor.getResults());
4841
}
4798
}
4842
public void testCompletionKeywordAssert3() throws JavaModelException {
4799
public void testCompletionKeywordCatch7() throws JavaModelException {
4843
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4800
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4844
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAssert3.java");
4801
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch7.java");
4845
4802
4846
		String str = cu.getSource();
4803
		String str = cu.getSource();
4847
		String completeBehind = "as";
4804
		String completeBehind = "cat";
4848
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4805
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4849
		cu.codeComplete(cursorLocation, requestor);
4806
		cu.codeComplete(cursorLocation, requestor);
4850
4807
Lines 4852-4876 Link Here
4852
			"",
4809
			"",
4853
			requestor.getResults());
4810
			requestor.getResults());
4854
}
4811
}
4855
public void testCompletionKeywordElse1() throws JavaModelException {
4812
public void testCompletionKeywordCatch8() throws JavaModelException {
4856
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4813
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4857
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordElse1.java");
4814
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch8.java");
4858
4815
4859
		String str = cu.getSource();
4816
		String str = cu.getSource();
4860
		String completeBehind = "els";
4817
		String completeBehind = "cat";
4861
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4818
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4862
		cu.codeComplete(cursorLocation, requestor);
4819
		cu.codeComplete(cursorLocation, requestor);
4863
4820
4864
		assertEquals(
4821
		assertEquals(
4865
			"element:else    completion:else    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4822
			"",
4866
			requestor.getResults());
4823
			requestor.getResults());
4867
}
4824
}
4868
public void testCompletionKeywordElse2() throws JavaModelException {
4825
public void testCompletionKeywordCatch9() throws JavaModelException {
4869
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4826
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4870
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordElse2.java");
4827
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch9.java");
4871
4828
4872
		String str = cu.getSource();
4829
		String str = cu.getSource();
4873
		String completeBehind = "els";
4830
		String completeBehind = "cat";
4874
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4831
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4875
		cu.codeComplete(cursorLocation, requestor);
4832
		cu.codeComplete(cursorLocation, requestor);
4876
4833
Lines 4878-5216 Link Here
4878
			"",
4835
			"",
4879
			requestor.getResults());
4836
			requestor.getResults());
4880
}
4837
}
4881
public void testCompletionKeywordElse3() throws JavaModelException {
4838
public void testCompletionKeywordClass1() throws JavaModelException {
4882
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4839
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4883
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordElse3.java");
4840
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass1.java");
4884
4841
4885
		String str = cu.getSource();
4842
		String str = cu.getSource();
4886
		String completeBehind = "els";
4843
		String completeBehind = "cla";
4887
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4844
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4888
		cu.codeComplete(cursorLocation, requestor);
4845
		cu.codeComplete(cursorLocation, requestor);
4889
4846
4890
		assertEquals(
4847
		assertEquals(
4891
			"",
4848
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4892
			requestor.getResults());
4849
			requestor.getResults());
4893
}
4850
}
4894
public void testCompletionKeywordElse4() throws JavaModelException {
4851
public void testCompletionKeywordClass10() throws JavaModelException {
4895
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4852
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4896
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordElse4.java");
4853
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass10.java");
4897
4854
4898
		String str = cu.getSource();
4855
		String str = cu.getSource();
4899
		String completeBehind = "els";
4856
		String completeBehind = "cla";
4900
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4857
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4901
		cu.codeComplete(cursorLocation, requestor);
4858
		cu.codeComplete(cursorLocation, requestor);
4902
4859
4903
		assertEquals(
4860
		assertEquals(
4904
			"",
4861
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
4862
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
4863
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4905
			requestor.getResults());
4864
			requestor.getResults());
4906
}
4865
}
4907
public void testCompletionKeywordCatch1() throws JavaModelException {
4866
public void testCompletionKeywordClass11() throws JavaModelException {
4908
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4867
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4909
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch1.java");
4868
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass11.java");
4910
4869
4911
		String str = cu.getSource();
4870
		String str = cu.getSource();
4912
		String completeBehind = "cat";
4871
		String completeBehind = "cla";
4913
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4872
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4914
		cu.codeComplete(cursorLocation, requestor);
4873
		cu.codeComplete(cursorLocation, requestor);
4915
4874
4916
		assertEquals(
4875
		assertEquals(
4917
			"element:catch    completion:catch    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4876
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
4877
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
4878
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4918
			requestor.getResults());
4879
			requestor.getResults());
4919
}
4880
}
4920
public void testCompletionKeywordCatch2() throws JavaModelException {
4881
public void testCompletionKeywordClass12() throws JavaModelException {
4921
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4882
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4922
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch2.java");
4883
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass12.java");
4923
4884
4924
		String str = cu.getSource();
4885
		String str = cu.getSource();
4925
		String completeBehind = "cat";
4886
		String completeBehind = "cla";
4926
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4887
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4927
		cu.codeComplete(cursorLocation, requestor);
4888
		cu.codeComplete(cursorLocation, requestor);
4928
4889
4929
		assertEquals(
4890
		assertEquals(
4930
			"",
4891
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
4892
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
4893
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4931
			requestor.getResults());
4894
			requestor.getResults());
4932
}
4895
}
4933
public void testCompletionKeywordCatch3() throws JavaModelException {
4896
public void testCompletionKeywordClass13() throws JavaModelException {
4934
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4897
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4935
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch3.java");
4898
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass13.java");
4936
4899
4937
		String str = cu.getSource();
4900
		String str = cu.getSource();
4938
		String completeBehind = "cat";
4901
		String completeBehind = "cla";
4939
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4902
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4940
		cu.codeComplete(cursorLocation, requestor);
4903
		cu.codeComplete(cursorLocation, requestor);
4941
4904
4942
		assertEquals(
4905
		assertEquals(
4943
			"",
4906
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4944
			requestor.getResults());
4907
			requestor.getResults());
4945
}
4908
}
4946
public void testCompletionKeywordCatch4() throws JavaModelException {
4909
public void testCompletionKeywordClass14() throws JavaModelException {
4947
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4910
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4948
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch4.java");
4911
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass14.java");
4949
4912
4950
		String str = cu.getSource();
4913
		String str = cu.getSource();
4951
		String completeBehind = "cat";
4914
		String completeBehind = "cla";
4952
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4915
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4953
		cu.codeComplete(cursorLocation, requestor);
4916
		cu.codeComplete(cursorLocation, requestor);
4954
4917
4955
		assertEquals(
4918
		assertEquals(
4956
			"",
4919
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
4920
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
4921
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4957
			requestor.getResults());
4922
			requestor.getResults());
4958
}
4923
}
4959
public void testCompletionKeywordCatch5() throws JavaModelException {
4924
public void testCompletionKeywordClass15() throws JavaModelException {
4960
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4925
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4961
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch5.java");
4926
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass15.java");
4962
4927
4963
		String str = cu.getSource();
4928
		String str = cu.getSource();
4964
		String completeBehind = "cat";
4929
		String completeBehind = "cla";
4965
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4930
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4966
		cu.codeComplete(cursorLocation, requestor);
4931
		cu.codeComplete(cursorLocation, requestor);
4967
4932
4968
		assertEquals(
4933
		assertEquals(
4969
			"element:catch    completion:catch    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
4934
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
4970
			"element:catchz    completion:catchz    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
4935
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
4936
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4971
			requestor.getResults());
4937
			requestor.getResults());
4972
}
4938
}
4973
public void testCompletionKeywordFinally1() throws JavaModelException {
4939
public void testCompletionKeywordClass16() throws JavaModelException {
4974
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4940
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4975
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally1.java");
4941
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass16.java");
4976
4942
4977
		String str = cu.getSource();
4943
		String str = cu.getSource();
4978
		String completeBehind = "finall";
4944
		String completeBehind = "cla";
4979
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4945
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4980
		cu.codeComplete(cursorLocation, requestor);
4946
		cu.codeComplete(cursorLocation, requestor);
4981
4947
4982
		assertEquals(
4948
		assertEquals(
4983
			"element:finally    completion:finally    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4949
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
4950
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
4951
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4984
			requestor.getResults());
4952
			requestor.getResults());
4985
}
4953
}
4986
public void testCompletionKeywordFinally2() throws JavaModelException {
4954
public void testCompletionKeywordClass17() throws JavaModelException {
4987
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4955
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4988
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally2.java");
4956
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass17.java");
4989
4957
4990
		String str = cu.getSource();
4958
		String str = cu.getSource();
4991
		String completeBehind = "finall";
4959
		String completeBehind = "cla";
4992
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4960
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4993
		cu.codeComplete(cursorLocation, requestor);
4961
		cu.codeComplete(cursorLocation, requestor);
4994
4962
4995
		assertEquals(
4963
		assertEquals(
4996
			"",
4964
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
4997
			requestor.getResults());
4965
			requestor.getResults());
4998
}
4966
}
4999
public void testCompletionKeywordFinally3() throws JavaModelException {
4967
public void testCompletionKeywordClass18() throws JavaModelException {
5000
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4968
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5001
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally3.java");
4969
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass18.java");
5002
4970
5003
		String str = cu.getSource();
4971
		String str = cu.getSource();
5004
		String completeBehind = "finall";
4972
		String completeBehind = "cla";
5005
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4973
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5006
		cu.codeComplete(cursorLocation, requestor);
4974
		cu.codeComplete(cursorLocation, requestor);
5007
4975
5008
		assertEquals(
4976
		assertEquals(
5009
			"",
4977
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5010
			requestor.getResults());
4978
			requestor.getResults());
5011
}
4979
}
5012
public void testCompletionKeywordFinally4() throws JavaModelException {
4980
public void testCompletionKeywordClass19() throws JavaModelException {
5013
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4981
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5014
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally4.java");
4982
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass19.java");
5015
4983
5016
		String str = cu.getSource();
4984
		String str = cu.getSource();
5017
		String completeBehind = "finall";
4985
		String completeBehind = "cla";
5018
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4986
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5019
		cu.codeComplete(cursorLocation, requestor);
4987
		cu.codeComplete(cursorLocation, requestor);
5020
4988
5021
		assertEquals(
4989
		assertEquals(
5022
			"",
4990
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5023
			requestor.getResults());
4991
			requestor.getResults());
5024
}
4992
}
5025
public void testCompletionKeywordFinally5() throws JavaModelException {
4993
public void testCompletionKeywordClass2() throws JavaModelException {
5026
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
4994
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5027
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally5.java");
4995
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass2.java");
5028
4996
5029
		String str = cu.getSource();
4997
		String str = cu.getSource();
5030
		String completeBehind = "finall";
4998
		String completeBehind = "cla";
5031
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
4999
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5032
		cu.codeComplete(cursorLocation, requestor);
5000
		cu.codeComplete(cursorLocation, requestor);
5033
5001
5034
		assertEquals(
5002
		assertEquals(
5035
			"element:finally    completion:finally    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5003
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5036
			requestor.getResults());
5004
			requestor.getResults());
5037
}
5005
}
5038
public void testCompletionKeywordFinally6() throws JavaModelException {
5006
public void testCompletionKeywordClass20() throws JavaModelException {
5039
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5007
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5040
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally6.java");
5008
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass20.java");
5041
5009
5042
		String str = cu.getSource();
5010
		String str = cu.getSource();
5043
		String completeBehind = "finall";
5011
		String completeBehind = "cla";
5044
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5012
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5045
		cu.codeComplete(cursorLocation, requestor);
5013
		cu.codeComplete(cursorLocation, requestor);
5046
5014
5047
		assertEquals(
5015
		assertEquals(
5048
			"element:finally    completion:finally    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
5016
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5049
			"element:finallyz    completion:finallyz    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
5050
			requestor.getResults());
5017
			requestor.getResults());
5051
}
5018
}
5052
public void testCompletionKeywordFinally7() throws JavaModelException {
5019
public void testCompletionKeywordClass21() throws JavaModelException {
5053
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5020
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5054
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally7.java");
5021
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass21.java");
5055
5022
5056
		String str = cu.getSource();
5023
		String str = cu.getSource();
5057
		String completeBehind = "finall";
5024
		String completeBehind = "cla";
5058
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5025
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5059
		cu.codeComplete(cursorLocation, requestor);
5026
		cu.codeComplete(cursorLocation, requestor);
5060
5027
5061
		assertEquals(
5028
		assertEquals(
5062
			"element:finallyz    completion:finallyz    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
5029
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5030
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5031
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5063
			requestor.getResults());
5032
			requestor.getResults());
5064
}
5033
}
5065
public void testCompletionKeywordContinue1() throws JavaModelException {
5034
public void testCompletionKeywordClass22() throws JavaModelException {
5066
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5035
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5067
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordContinue1.java");
5036
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass22.java");
5068
5037
5069
		String str = cu.getSource();
5038
		String str = cu.getSource();
5070
		String completeBehind = "cont";
5039
		String completeBehind = "cla";
5071
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5040
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5072
		cu.codeComplete(cursorLocation, requestor);
5041
		cu.codeComplete(cursorLocation, requestor);
5073
5042
5074
		assertEquals(
5043
		assertEquals(
5075
			"element:continue    completion:continue    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5044
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5045
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5046
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5076
			requestor.getResults());
5047
			requestor.getResults());
5077
}
5048
}
5078
public void testCompletionKeywordContinue2() throws JavaModelException {
5049
public void testCompletionKeywordClass23() throws JavaModelException {
5079
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5050
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5080
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordContinue2.java");
5051
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass23.java");
5081
5052
5082
		String str = cu.getSource();
5053
		String str = cu.getSource();
5083
		String completeBehind = "cont";
5054
		String completeBehind = "cla";
5084
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5055
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5085
		cu.codeComplete(cursorLocation, requestor);
5056
		cu.codeComplete(cursorLocation, requestor);
5086
5057
5087
		assertEquals(
5058
		assertEquals(
5088
			"",
5059
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5060
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5061
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5089
			requestor.getResults());
5062
			requestor.getResults());
5090
}
5063
}
5091
public void testCompletionKeywordBreak1() throws JavaModelException {
5064
public void testCompletionKeywordClass24() throws JavaModelException {
5092
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5065
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5093
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordBreak1.java");
5066
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass24.java");
5094
5067
5095
		String str = cu.getSource();
5068
		String str = cu.getSource();
5096
		String completeBehind = "bre";
5069
		String completeBehind = "cla";
5097
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5070
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5098
		cu.codeComplete(cursorLocation, requestor);
5071
		cu.codeComplete(cursorLocation, requestor);
5099
5072
5100
		assertEquals(
5073
		assertEquals(
5101
			"element:break    completion:break    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5074
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5075
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5076
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5102
			requestor.getResults());
5077
			requestor.getResults());
5103
}
5078
}
5104
public void testCompletionKeywordBreak2() throws JavaModelException {
5079
public void testCompletionKeywordClass3() throws JavaModelException {
5105
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5080
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5106
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordBreak2.java");
5081
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass3.java");
5107
5082
5108
		String str = cu.getSource();
5083
		String str = cu.getSource();
5109
		String completeBehind = "bre";
5084
		String completeBehind = "cla";
5110
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5085
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5111
		cu.codeComplete(cursorLocation, requestor);
5086
		cu.codeComplete(cursorLocation, requestor);
5112
5087
5113
		assertEquals(
5088
		assertEquals(
5114
			"",
5089
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5115
			requestor.getResults());
5090
			requestor.getResults());
5116
}
5091
}
5117
public void testCompletionKeywordBreak3() throws JavaModelException {
5092
public void testCompletionKeywordClass4() throws JavaModelException {
5118
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5093
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5119
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordBreak3.java");
5094
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass4.java");
5120
5095
5121
		String str = cu.getSource();
5096
		String str = cu.getSource();
5122
		String completeBehind = "bre";
5097
		String completeBehind = "cla";
5123
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5098
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5124
		cu.codeComplete(cursorLocation, requestor);
5099
		cu.codeComplete(cursorLocation, requestor);
5125
5100
5126
		assertEquals(
5101
		assertEquals(
5127
			"element:break    completion:break    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5102
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5128
			requestor.getResults());
5103
			requestor.getResults());
5129
}
5104
}
5130
public void testCompletionKeywordWhile1() throws JavaModelException {
5105
public void testCompletionKeywordClass5() throws JavaModelException {
5131
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5106
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5132
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile1.java");
5107
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass5.java");
5133
5108
5134
		String str = cu.getSource();
5109
		String str = cu.getSource();
5135
		String completeBehind = "wh";
5110
		String completeBehind = "cla";
5136
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5111
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5137
		cu.codeComplete(cursorLocation, requestor);
5112
		cu.codeComplete(cursorLocation, requestor);
5138
5113
5139
		assertEquals(
5114
		assertEquals(
5140
			"element:while    completion:while    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5115
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5141
			requestor.getResults());
5116
			requestor.getResults());
5142
}
5117
}
5143
public void testCompletionKeywordWhile2() throws JavaModelException {
5118
public void testCompletionKeywordClass6() throws JavaModelException {
5144
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5119
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5145
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile2.java");
5120
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass6.java");
5146
5121
5147
		String str = cu.getSource();
5122
		String str = cu.getSource();
5148
		String completeBehind = "wh";
5123
		String completeBehind = "cla";
5149
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5124
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5150
		cu.codeComplete(cursorLocation, requestor);
5125
		cu.codeComplete(cursorLocation, requestor);
5151
5126
5152
		assertEquals(
5127
		assertEquals(
5153
			"",
5128
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5129
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5130
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5154
			requestor.getResults());
5131
			requestor.getResults());
5155
}
5132
}
5156
public void testCompletionKeywordWhile3() throws JavaModelException {
5133
public void testCompletionKeywordClass7() throws JavaModelException {
5157
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5134
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5158
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile3.java");
5135
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass7.java");
5159
5136
5160
		String str = cu.getSource();
5137
		String str = cu.getSource();
5161
		String completeBehind = "wh";
5138
		String completeBehind = "cla";
5162
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5139
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5163
		cu.codeComplete(cursorLocation, requestor);
5140
		cu.codeComplete(cursorLocation, requestor);
5164
5141
5165
		assertEquals(
5142
		assertEquals(
5166
			"",
5143
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5144
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5145
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5167
			requestor.getResults());
5146
			requestor.getResults());
5168
}
5147
}
5169
public void testCompletionKeywordWhile4() throws JavaModelException {
5148
public void testCompletionKeywordClass8() throws JavaModelException {
5170
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5149
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5171
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile4.java");
5150
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass8.java");
5172
5151
5173
		String str = cu.getSource();
5152
		String str = cu.getSource();
5174
		String completeBehind = "wh";
5153
		String completeBehind = "cla";
5175
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5154
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5176
		cu.codeComplete(cursorLocation, requestor);
5155
		cu.codeComplete(cursorLocation, requestor);
5177
5156
5178
		assertEquals(
5157
		assertEquals(
5179
			"element:while    completion:while    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5158
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5159
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5160
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5180
			requestor.getResults());
5161
			requestor.getResults());
5181
}
5162
}
5182
public void testCompletionKeywordWhile5() throws JavaModelException {
5163
public void testCompletionKeywordClass9() throws JavaModelException {
5183
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5164
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5184
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile5.java");
5165
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass9.java");
5185
5166
5186
		String str = cu.getSource();
5167
		String str = cu.getSource();
5187
		String completeBehind = "wh";
5168
		String completeBehind = "cla";
5188
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5169
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5189
		cu.codeComplete(cursorLocation, requestor);
5170
		cu.codeComplete(cursorLocation, requestor);
5190
5171
5191
		assertEquals(
5172
		assertEquals(
5192
			"element:while    completion:while    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5173
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5174
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5175
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5193
			requestor.getResults());
5176
			requestor.getResults());
5194
}
5177
}
5195
public void testCompletionKeywordExtends1() throws JavaModelException {
5178
public void testCompletionKeywordContinue1() throws JavaModelException {
5196
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5179
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5197
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends1.java");
5180
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordContinue1.java");
5198
5181
5199
		String str = cu.getSource();
5182
		String str = cu.getSource();
5200
		String completeBehind = "ext";
5183
		String completeBehind = "cont";
5201
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5184
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5202
		cu.codeComplete(cursorLocation, requestor);
5185
		cu.codeComplete(cursorLocation, requestor);
5203
5186
5204
		assertEquals(
5187
		assertEquals(
5205
			"element:extends    completion:extends    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5188
			"element:continue    completion:continue    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5206
			requestor.getResults());
5189
			requestor.getResults());
5207
}
5190
}
5208
public void testCompletionKeywordExtends2() throws JavaModelException {
5191
public void testCompletionKeywordContinue2() throws JavaModelException {
5209
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5192
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5210
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends2.java");
5193
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordContinue2.java");
5211
5194
5212
		String str = cu.getSource();
5195
		String str = cu.getSource();
5213
		String completeBehind = "ext";
5196
		String completeBehind = "cont";
5214
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5197
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5215
		cu.codeComplete(cursorLocation, requestor);
5198
		cu.codeComplete(cursorLocation, requestor);
5216
5199
Lines 5218-5843 Link Here
5218
			"",
5201
			"",
5219
			requestor.getResults());
5202
			requestor.getResults());
5220
}
5203
}
5221
public void testCompletionKeywordExtends3() throws JavaModelException {
5204
public void testCompletionKeywordContinue3() throws JavaModelException {
5222
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5205
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5223
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends3.java");
5206
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordContinue3.java");
5224
5207
5225
		String str = cu.getSource();
5208
		String str = cu.getSource();
5226
		String completeBehind = "ext";
5209
		String completeBehind = "cont";
5227
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5210
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5228
		cu.codeComplete(cursorLocation, requestor);
5211
		cu.codeComplete(cursorLocation, requestor);
5229
5212
5230
		assertEquals(
5213
		assertEquals(
5231
			"",
5214
			"element:continue    completion:continue    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5232
			requestor.getResults());
5215
			requestor.getResults());
5233
}
5216
}
5234
public void testCompletionKeywordExtends4() throws JavaModelException {
5217
public void testCompletionKeywordContinue4() throws JavaModelException {
5235
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5218
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5236
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends4.java");
5219
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordContinue4.java");
5237
5220
5238
		String str = cu.getSource();
5221
		String str = cu.getSource();
5239
		String completeBehind = "ext";
5222
		String completeBehind = "cont";
5240
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5223
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5241
		cu.codeComplete(cursorLocation, requestor);
5224
		cu.codeComplete(cursorLocation, requestor);
5242
5225
5243
		assertEquals(
5226
		assertEquals(
5244
			"element:extends    completion:extends    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5227
			"",
5245
			requestor.getResults());
5228
			requestor.getResults());
5246
}
5229
}
5247
public void testCompletionKeywordExtends5() throws JavaModelException {
5230
public void testCompletionKeywordDefault1() throws JavaModelException {
5248
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5231
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5249
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends5.java");
5232
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault1.java");
5250
5233
5251
		String str = cu.getSource();
5234
		String str = cu.getSource();
5252
		String completeBehind = "ext";
5235
		String completeBehind = "def";
5253
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5236
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5254
		cu.codeComplete(cursorLocation, requestor);
5237
		cu.codeComplete(cursorLocation, requestor);
5255
5238
5256
		assertEquals(
5239
		assertEquals(
5257
			"",
5240
			"element:default    completion:default    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5258
			requestor.getResults());
5241
			requestor.getResults());
5259
}
5242
}
5260
public void testCompletionKeywordImplements1() throws JavaModelException {
5243
public void testCompletionKeywordDefault10() throws JavaModelException {
5261
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5244
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5262
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImplements1.java");
5245
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault10.java");
5263
5246
5264
		String str = cu.getSource();
5247
		String str = cu.getSource();
5265
		String completeBehind = "imp";
5248
		String completeBehind = "def";
5266
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5249
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5267
		cu.codeComplete(cursorLocation, requestor);
5250
		cu.codeComplete(cursorLocation, requestor);
5268
5251
5269
		assertEquals(
5252
		assertEquals(
5270
			"element:implements    completion:implements    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5253
			"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
5271
			requestor.getResults());
5254
			requestor.getResults());
5272
}
5255
}
5273
public void testCompletionKeywordImplements2() throws JavaModelException {
5256
public void testCompletionKeywordDefault2() throws JavaModelException {
5274
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5257
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5275
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImplements2.java");
5258
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault2.java");
5276
5259
5277
		String str = cu.getSource();
5260
		String str = cu.getSource();
5278
		String completeBehind = "imp";
5261
		String completeBehind = "def";
5279
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5262
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5280
		cu.codeComplete(cursorLocation, requestor);
5263
		cu.codeComplete(cursorLocation, requestor);
5281
5264
5282
		assertEquals(
5265
		assertEquals(
5283
			"element:implements    completion:implements    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5266
			"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5267
			"element:default    completion:default    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5284
			requestor.getResults());
5268
			requestor.getResults());
5285
}
5269
}
5286
public void testCompletionKeywordImplements3() throws JavaModelException {
5270
public void testCompletionKeywordDefault3() throws JavaModelException {
5287
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5271
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5288
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImplements3.java");
5272
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault3.java");
5289
5273
5290
		String str = cu.getSource();
5274
		String str = cu.getSource();
5291
		String completeBehind = "imp";
5275
		String completeBehind = "def";
5292
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5276
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5293
		cu.codeComplete(cursorLocation, requestor);
5277
		cu.codeComplete(cursorLocation, requestor);
5294
5278
5295
		assertEquals(
5279
		assertEquals(
5296
			"",
5280
			"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5281
			"element:default    completion:default    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5297
			requestor.getResults());
5282
			requestor.getResults());
5298
}
5283
}
5299
public void testCompletionKeywordPackage1() throws JavaModelException {
5284
public void testCompletionKeywordDefault4() throws JavaModelException {
5300
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5285
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5301
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPackage1.java");
5286
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault4.java");
5302
5287
5303
		String str = cu.getSource();
5288
		String str = cu.getSource();
5304
		String completeBehind = "pac";
5289
		String completeBehind = "def";
5305
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5290
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5306
		cu.codeComplete(cursorLocation, requestor);
5291
		cu.codeComplete(cursorLocation, requestor);
5307
5292
5308
		assertEquals(
5293
		assertEquals(
5309
			"element:package    completion:package    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5294
			"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
5310
			requestor.getResults());
5295
			requestor.getResults());
5311
}
5296
}
5312
public void testCompletionKeywordPackage2() throws JavaModelException {
5297
public void testCompletionKeywordDefault5() throws JavaModelException {
5313
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5298
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5314
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "p", "CompletionKeywordPackage2.java");
5299
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault5.java");
5315
5300
5316
		String str = cu.getSource();
5301
		String str = cu.getSource();
5317
		String completeBehind = "pac";
5302
		String completeBehind = "def";
5318
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5303
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5319
		cu.codeComplete(cursorLocation, requestor);
5304
		cu.codeComplete(cursorLocation, requestor);
5320
5305
5321
		assertEquals(
5306
		assertEquals(
5322
			"",
5307
			"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
5323
			requestor.getResults());
5308
			requestor.getResults());
5324
}
5309
}
5325
public void testCompletionKeywordPackage3() throws JavaModelException {
5310
public void testCompletionKeywordDefault6() throws JavaModelException {
5326
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5311
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5327
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPackage3.java");
5312
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault6.java");
5328
5313
5329
		String str = cu.getSource();
5314
		String str = cu.getSource();
5330
		String completeBehind = "pac";
5315
		String completeBehind = "def";
5331
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5316
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5332
		cu.codeComplete(cursorLocation, requestor);
5317
		cu.codeComplete(cursorLocation, requestor);
5333
5318
5334
		assertEquals(
5319
		assertEquals(
5335
			"",
5320
			"element:default    completion:default    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5336
			requestor.getResults());
5321
			requestor.getResults());
5337
}
5322
}
5338
public void testCompletionKeywordPackage4() throws JavaModelException {
5323
public void testCompletionKeywordDefault7() throws JavaModelException {
5339
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5324
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5340
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPackage4.java");
5325
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault7.java");
5341
5326
5342
		String str = cu.getSource();
5327
		String str = cu.getSource();
5343
		String completeBehind = "pac";
5328
		String completeBehind = "def";
5344
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5329
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5345
		cu.codeComplete(cursorLocation, requestor);
5330
		cu.codeComplete(cursorLocation, requestor);
5346
5331
5347
		assertEquals(
5332
		assertEquals(
5348
			"",
5333
			"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5334
			"element:default    completion:default    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5349
			requestor.getResults());
5335
			requestor.getResults());
5350
}
5336
}
5351
public void testCompletionKeywordImport1() throws JavaModelException {
5337
public void testCompletionKeywordDefault8() throws JavaModelException {
5352
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5338
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5353
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImport1.java");
5339
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault8.java");
5354
5340
5355
		String str = cu.getSource();
5341
		String str = cu.getSource();
5356
		String completeBehind = "imp";
5342
		String completeBehind = "def";
5357
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5343
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5358
		cu.codeComplete(cursorLocation, requestor);
5344
		cu.codeComplete(cursorLocation, requestor);
5359
5345
5360
		assertEquals(
5346
		assertEquals(
5361
			"element:import    completion:import    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5347
			"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5348
			"element:default    completion:default    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5362
			requestor.getResults());
5349
			requestor.getResults());
5363
}
5350
}
5364
public void testCompletionKeywordImport2() throws JavaModelException {
5351
public void testCompletionKeywordDefault9() throws JavaModelException {
5365
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5352
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5366
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "p", "CompletionKeywordImport2.java");
5353
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault9.java");
5367
5354
5368
		String str = cu.getSource();
5355
		String str = cu.getSource();
5369
		String completeBehind = "imp";
5356
		String completeBehind = "def";
5370
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5357
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5371
		cu.codeComplete(cursorLocation, requestor);
5358
		cu.codeComplete(cursorLocation, requestor);
5372
5359
5373
		assertEquals(
5360
		assertEquals(
5374
			"element:import    completion:import    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5361
			"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
5375
			requestor.getResults());
5362
			requestor.getResults());
5376
}
5363
}
5377
public void testCompletionKeywordImport3() throws JavaModelException {
5364
public void testCompletionKeywordDo1() throws JavaModelException {
5378
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5365
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5379
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImport3.java");
5366
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDo1.java");
5380
5367
5381
		String str = cu.getSource();
5368
		String str = cu.getSource();
5382
		String completeBehind = "imp";
5369
		String completeBehind = "do";
5383
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5370
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5384
		cu.codeComplete(cursorLocation, requestor);
5371
		cu.codeComplete(cursorLocation, requestor);
5385
5372
5386
		assertEquals(
5373
		assertEquals(
5387
			"element:import    completion:import    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5374
			"element:do    completion:do    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"\n"+
5375
			"element:double    completion:double    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5388
			requestor.getResults());
5376
			requestor.getResults());
5389
}
5377
}
5390
public void testCompletionKeywordImport4() throws JavaModelException {
5378
public void testCompletionKeywordDo2() throws JavaModelException {
5391
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5379
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5392
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImport4.java");
5380
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDo2.java");
5393
5381
5394
		String str = cu.getSource();
5382
		String str = cu.getSource();
5395
		String completeBehind = "imp";
5383
		String completeBehind = "do";
5396
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5384
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5397
		cu.codeComplete(cursorLocation, requestor);
5385
		cu.codeComplete(cursorLocation, requestor);
5398
5386
5399
		assertEquals(
5387
		assertEquals(
5400
			"",
5388
			"element:double    completion:double    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5401
			requestor.getResults());
5389
			requestor.getResults());
5402
}
5390
}
5403
public void testCompletionKeywordCase1() throws JavaModelException {
5391
public void testCompletionKeywordDo3() throws JavaModelException {
5404
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5392
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5405
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase1.java");
5393
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDo3.java");
5406
5394
5407
		String str = cu.getSource();
5395
		String str = cu.getSource();
5408
		String completeBehind = "cas";
5396
		String completeBehind = "do";
5409
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5397
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5410
		cu.codeComplete(cursorLocation, requestor);
5398
		cu.codeComplete(cursorLocation, requestor);
5411
5399
5412
		assertEquals(
5400
		assertEquals(
5413
			"element:case    completion:case    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5401
			"element:double    completion:double    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5414
			requestor.getResults());
5402
			requestor.getResults());
5415
}
5403
}
5416
public void testCompletionKeywordCase2() throws JavaModelException {
5404
public void testCompletionKeywordDo4() throws JavaModelException {
5417
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5405
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5418
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase2.java");
5406
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDo4.java");
5419
5407
5420
		String str = cu.getSource();
5408
		String str = cu.getSource();
5421
		String completeBehind = "cas";
5409
		String completeBehind = "do";
5422
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5410
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5423
		cu.codeComplete(cursorLocation, requestor);
5411
		cu.codeComplete(cursorLocation, requestor);
5424
5412
5425
		assertEquals(
5413
		assertEquals(
5426
			"element:case    completion:case    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5414
			"element:do    completion:do    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"\n"+
5415
			"element:double    completion:double    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5427
			requestor.getResults());
5416
			requestor.getResults());
5428
}
5417
}
5429
public void testCompletionKeywordCase3() throws JavaModelException {
5418
public void testCompletionKeywordDo5() throws JavaModelException {
5430
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5419
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5431
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase3.java");
5420
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDo5.java");
5432
5421
5433
		String str = cu.getSource();
5422
		String str = cu.getSource();
5434
		String completeBehind = "cas";
5423
		String completeBehind = "do";
5435
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5424
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5436
		cu.codeComplete(cursorLocation, requestor);
5425
		cu.codeComplete(cursorLocation, requestor);
5437
5426
5438
		assertEquals(
5427
		assertEquals(
5439
			"element:case    completion:case    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5428
			"element:double    completion:double    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5440
			requestor.getResults());
5429
			requestor.getResults());
5441
}
5430
}
5442
public void testCompletionKeywordCase4() throws JavaModelException {
5431
public void testCompletionKeywordDo6() throws JavaModelException {
5443
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5432
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5444
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase4.java");
5433
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDo6.java");
5445
5434
5446
		String str = cu.getSource();
5435
		String str = cu.getSource();
5447
		String completeBehind = "cas";
5436
		String completeBehind = "do";
5448
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5437
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5449
		cu.codeComplete(cursorLocation, requestor);
5438
		cu.codeComplete(cursorLocation, requestor);
5450
5439
5451
		assertEquals(
5440
		assertEquals(
5452
			"element:case    completion:case    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5441
			"element:double    completion:double    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5453
			requestor.getResults());
5442
			requestor.getResults());
5454
}
5443
}
5455
public void testCompletionKeywordCase5() throws JavaModelException {
5444
public void testCompletionKeywordElse1() throws JavaModelException {
5456
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5445
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5457
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase5.java");
5446
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordElse1.java");
5458
5447
5459
		String str = cu.getSource();
5448
		String str = cu.getSource();
5460
		String completeBehind = "cas";
5449
		String completeBehind = "els";
5461
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5450
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5462
		cu.codeComplete(cursorLocation, requestor);
5451
		cu.codeComplete(cursorLocation, requestor);
5463
5452
5464
		assertEquals(
5453
		assertEquals(
5465
			"",
5454
			"element:else    completion:else    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5466
			requestor.getResults());
5455
			requestor.getResults());
5467
}
5456
}
5468
public void testCompletionKeywordDefault1() throws JavaModelException {
5457
public void testCompletionKeywordElse2() throws JavaModelException {
5469
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5458
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5470
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault1.java");
5459
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordElse2.java");
5471
5460
5472
		String str = cu.getSource();
5461
		String str = cu.getSource();
5473
		String completeBehind = "def";
5462
		String completeBehind = "els";
5474
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5463
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5475
		cu.codeComplete(cursorLocation, requestor);
5464
		cu.codeComplete(cursorLocation, requestor);
5476
5465
5477
		assertEquals(
5466
		assertEquals(
5478
			"element:default    completion:default    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5467
			"",
5479
			requestor.getResults());
5468
			requestor.getResults());
5480
}
5469
}
5481
public void testCompletionKeywordDefault2() throws JavaModelException {
5470
public void testCompletionKeywordElse3() throws JavaModelException {
5482
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5471
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5483
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault2.java");
5472
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordElse3.java");
5484
5473
5485
		String str = cu.getSource();
5474
		String str = cu.getSource();
5486
		String completeBehind = "def";
5475
		String completeBehind = "els";
5487
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5476
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5488
		cu.codeComplete(cursorLocation, requestor);
5477
		cu.codeComplete(cursorLocation, requestor);
5489
5478
5490
		assertEquals(
5479
		assertEquals(
5491
			"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5480
			"",
5492
			"element:default    completion:default    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5493
			requestor.getResults());
5481
			requestor.getResults());
5494
}
5482
}
5495
public void testCompletionKeywordDefault3() throws JavaModelException {
5483
public void testCompletionKeywordElse4() throws JavaModelException {
5496
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5484
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5497
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault3.java");
5485
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordElse4.java");
5498
5486
5499
		String str = cu.getSource();
5487
		String str = cu.getSource();
5500
		String completeBehind = "def";
5488
		String completeBehind = "els";
5501
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5489
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5502
		cu.codeComplete(cursorLocation, requestor);
5490
		cu.codeComplete(cursorLocation, requestor);
5503
5491
5504
		assertEquals(
5492
		assertEquals(
5505
			"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5493
			"",
5506
			"element:default    completion:default    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5507
			requestor.getResults());
5494
			requestor.getResults());
5508
}
5495
}
5509
public void testCompletionKeywordDefault4() throws JavaModelException {
5496
public void testCompletionKeywordElse5() throws JavaModelException {
5510
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5497
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5511
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault4.java");
5498
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordElse5.java");
5512
5499
5513
		String str = cu.getSource();
5500
		String str = cu.getSource();
5514
		String completeBehind = "def";
5501
		String completeBehind = "els";
5515
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5502
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5516
		cu.codeComplete(cursorLocation, requestor);
5503
		cu.codeComplete(cursorLocation, requestor);
5517
5504
5518
		assertEquals(
5505
		assertEquals(
5519
			"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
5506
			"element:else    completion:else    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5520
			requestor.getResults());
5507
			requestor.getResults());
5521
}
5508
}
5522
public void testCompletionKeywordDefault5() throws JavaModelException {
5509
public void testCompletionKeywordElse6() throws JavaModelException {
5523
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5510
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5524
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault5.java");
5511
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordElse6.java");
5525
5512
5526
		String str = cu.getSource();
5513
		String str = cu.getSource();
5527
		String completeBehind = "def";
5514
		String completeBehind = "els";
5528
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5515
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5529
		cu.codeComplete(cursorLocation, requestor);
5516
		cu.codeComplete(cursorLocation, requestor);
5530
5517
5531
		assertEquals(
5518
		assertEquals(
5532
			"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
5519
			"",
5533
			requestor.getResults());
5520
			requestor.getResults());
5534
}
5521
}
5535
public void testCompletionKeywordClass1() throws JavaModelException {
5522
public void testCompletionKeywordElse7() throws JavaModelException {
5536
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5523
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5537
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass1.java");
5524
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordElse7.java");
5538
5525
5539
		String str = cu.getSource();
5526
		String str = cu.getSource();
5540
		String completeBehind = "cla";
5527
		String completeBehind = "els";
5541
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5528
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5542
		cu.codeComplete(cursorLocation, requestor);
5529
		cu.codeComplete(cursorLocation, requestor);
5543
5530
5544
		assertEquals(
5531
		assertEquals(
5545
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5532
			"",
5546
			requestor.getResults());
5533
			requestor.getResults());
5547
}
5534
}
5548
public void testCompletionKeywordClass2() throws JavaModelException {
5535
public void testCompletionKeywordElse8() throws JavaModelException {
5549
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5536
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5550
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass2.java");
5537
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordElse8.java");
5551
5538
5552
		String str = cu.getSource();
5539
		String str = cu.getSource();
5553
		String completeBehind = "cla";
5540
		String completeBehind = "els";
5554
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5541
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5555
		cu.codeComplete(cursorLocation, requestor);
5542
		cu.codeComplete(cursorLocation, requestor);
5556
5543
5557
		assertEquals(
5544
		assertEquals(
5558
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5545
			"",
5559
			requestor.getResults());
5546
			requestor.getResults());
5560
}
5547
}
5561
public void testCompletionKeywordClass3() throws JavaModelException {
5548
public void testCompletionKeywordExtends1() throws JavaModelException {
5562
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5549
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5563
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass3.java");
5550
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends1.java");
5564
5551
5565
		String str = cu.getSource();
5552
		String str = cu.getSource();
5566
		String completeBehind = "cla";
5553
		String completeBehind = "ext";
5567
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5554
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5568
		cu.codeComplete(cursorLocation, requestor);
5555
		cu.codeComplete(cursorLocation, requestor);
5569
5556
5570
		assertEquals(
5557
		assertEquals(
5571
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5558
			"element:extends    completion:extends    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5572
			requestor.getResults());
5559
			requestor.getResults());
5573
}
5560
}
5574
public void testCompletionKeywordClass4() throws JavaModelException {
5561
public void testCompletionKeywordExtends10() throws JavaModelException {
5575
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5562
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5576
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass4.java");
5563
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends10.java");
5577
5564
5578
		String str = cu.getSource();
5565
		String str = cu.getSource();
5579
		String completeBehind = "cla";
5566
		String completeBehind = "ext";
5580
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5567
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5581
		cu.codeComplete(cursorLocation, requestor);
5568
		cu.codeComplete(cursorLocation, requestor);
5582
5569
5583
		assertEquals(
5570
		assertEquals(
5584
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5571
			"",
5585
			requestor.getResults());
5572
			requestor.getResults());
5586
}
5573
}
5587
public void testCompletionKeywordClass5() throws JavaModelException {
5574
public void testCompletionKeywordExtends2() throws JavaModelException {
5588
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5575
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5589
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass5.java");
5576
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends2.java");
5590
5577
5591
		String str = cu.getSource();
5578
		String str = cu.getSource();
5592
		String completeBehind = "cla";
5579
		String completeBehind = "ext";
5593
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5580
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5594
		cu.codeComplete(cursorLocation, requestor);
5581
		cu.codeComplete(cursorLocation, requestor);
5595
5582
5596
		assertEquals(
5583
		assertEquals(
5597
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5584
			"",
5598
			requestor.getResults());
5585
			requestor.getResults());
5599
}
5586
}
5600
public void testCompletionKeywordClass6() throws JavaModelException {
5587
public void testCompletionKeywordExtends3() throws JavaModelException {
5601
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5588
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5602
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass6.java");
5589
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends3.java");
5603
5590
5604
		String str = cu.getSource();
5591
		String str = cu.getSource();
5605
		String completeBehind = "cla";
5592
		String completeBehind = "ext";
5606
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5593
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5607
		cu.codeComplete(cursorLocation, requestor);
5594
		cu.codeComplete(cursorLocation, requestor);
5608
5595
5609
		assertEquals(
5596
		assertEquals(
5610
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5597
			"",
5611
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5612
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5613
			requestor.getResults());
5598
			requestor.getResults());
5614
}
5599
}
5615
public void testCompletionKeywordClass7() throws JavaModelException {
5600
public void testCompletionKeywordExtends4() throws JavaModelException {
5616
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5601
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5617
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass7.java");
5602
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends4.java");
5618
5603
5619
		String str = cu.getSource();
5604
		String str = cu.getSource();
5620
		String completeBehind = "cla";
5605
		String completeBehind = "ext";
5621
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5606
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5622
		cu.codeComplete(cursorLocation, requestor);
5607
		cu.codeComplete(cursorLocation, requestor);
5623
5608
5624
		assertEquals(
5609
		assertEquals(
5625
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5610
			"element:extends    completion:extends    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5626
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5627
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5628
			requestor.getResults());
5611
			requestor.getResults());
5629
}
5612
}
5630
public void testCompletionKeywordClass8() throws JavaModelException {
5613
public void testCompletionKeywordExtends5() throws JavaModelException {
5631
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5614
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5632
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass8.java");
5615
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends5.java");
5633
5616
5634
		String str = cu.getSource();
5617
		String str = cu.getSource();
5635
		String completeBehind = "cla";
5618
		String completeBehind = "ext";
5636
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5619
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5637
		cu.codeComplete(cursorLocation, requestor);
5620
		cu.codeComplete(cursorLocation, requestor);
5638
5621
5639
		assertEquals(
5622
		assertEquals(
5640
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5623
			"",
5641
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5642
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5643
			requestor.getResults());
5624
			requestor.getResults());
5644
}
5625
}
5645
public void testCompletionKeywordClass9() throws JavaModelException {
5626
public void testCompletionKeywordExtends6() throws JavaModelException {
5646
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5627
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5647
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass9.java");
5628
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends6.java");
5648
5629
5649
		String str = cu.getSource();
5630
		String str = cu.getSource();
5650
		String completeBehind = "cla";
5631
		String completeBehind = "ext";
5651
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5632
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5652
		cu.codeComplete(cursorLocation, requestor);
5633
		cu.codeComplete(cursorLocation, requestor);
5653
5634
5654
		assertEquals(
5635
		assertEquals(
5655
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5636
			"element:extends    completion:extends    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5656
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5657
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5658
			requestor.getResults());
5637
			requestor.getResults());
5659
}
5638
}
5660
public void testCompletionKeywordClass10() throws JavaModelException {
5639
public void testCompletionKeywordExtends7() throws JavaModelException {
5661
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5640
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5662
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass10.java");
5641
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends7.java");
5663
5642
5664
		String str = cu.getSource();
5643
		String str = cu.getSource();
5665
		String completeBehind = "cla";
5644
		String completeBehind = "ext";
5666
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5645
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5667
		cu.codeComplete(cursorLocation, requestor);
5646
		cu.codeComplete(cursorLocation, requestor);
5668
5647
5669
		assertEquals(
5648
		assertEquals(
5670
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5649
			"",
5671
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5672
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5673
			requestor.getResults());
5650
			requestor.getResults());
5674
}
5651
}
5675
public void testCompletionKeywordClass11() throws JavaModelException {
5652
public void testCompletionKeywordExtends8() throws JavaModelException {
5676
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5653
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5677
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass11.java");
5654
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends8.java");
5678
5655
5679
		String str = cu.getSource();
5656
		String str = cu.getSource();
5680
		String completeBehind = "cla";
5657
		String completeBehind = "ext";
5681
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5658
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5682
		cu.codeComplete(cursorLocation, requestor);
5659
		cu.codeComplete(cursorLocation, requestor);
5683
5660
5684
		assertEquals(
5661
		assertEquals(
5685
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5662
			"",
5686
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5687
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5688
			requestor.getResults());
5663
			requestor.getResults());
5689
}
5664
}
5690
public void testCompletionKeywordClass12() throws JavaModelException {
5665
public void testCompletionKeywordExtends9() throws JavaModelException {
5691
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5666
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5692
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass12.java");
5667
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends9.java");
5693
5668
5694
		String str = cu.getSource();
5669
		String str = cu.getSource();
5695
		String completeBehind = "cla";
5670
		String completeBehind = "ext";
5696
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5671
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5697
		cu.codeComplete(cursorLocation, requestor);
5672
		cu.codeComplete(cursorLocation, requestor);
5698
5673
5699
		assertEquals(
5674
		assertEquals(
5700
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5675
			"element:extends    completion:extends    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5701
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
5702
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5703
			requestor.getResults());
5676
			requestor.getResults());
5704
}
5677
}
5705
public void testCompletionKeywordInterface1() throws JavaModelException {
5678
public void testCompletionKeywordFalse1() throws JavaModelException {
5706
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5679
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5707
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface1.java");
5680
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFalse1.java");
5708
5681
5709
		String str = cu.getSource();
5682
		String str = cu.getSource();
5710
		String completeBehind = "interf";
5683
		String completeBehind = "fal";
5711
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5684
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5712
		cu.codeComplete(cursorLocation, requestor);
5685
		cu.codeComplete(cursorLocation, requestor);
5713
5686
5714
		assertEquals(
5687
		assertEquals(
5715
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5688
			"",
5716
			requestor.getResults());
5689
			requestor.getResults());
5717
}
5690
}
5718
public void testCompletionKeywordInterface2() throws JavaModelException {
5691
public void testCompletionKeywordFalse2() throws JavaModelException {
5719
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5692
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5720
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface2.java");
5693
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFalse2.java");
5721
5694
5722
		String str = cu.getSource();
5695
		String str = cu.getSource();
5723
		String completeBehind = "interf";
5696
		String completeBehind = "fal";
5724
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5697
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5725
		cu.codeComplete(cursorLocation, requestor);
5698
		cu.codeComplete(cursorLocation, requestor);
5726
5699
5727
		assertEquals(
5700
		assertEquals(
5728
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5701
			"element:false    completion:false    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
5729
			requestor.getResults());
5702
			requestor.getResults());
5730
}
5703
}
5731
public void testCompletionKeywordInterface3() throws JavaModelException {
5704
public void testCompletionKeywordFalse3() throws JavaModelException {
5732
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5705
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5733
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface3.java");
5706
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFalse3.java");
5734
5707
5735
		String str = cu.getSource();
5708
		String str = cu.getSource();
5736
		String completeBehind = "interf";
5709
		String completeBehind = "fal";
5737
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5710
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5738
		cu.codeComplete(cursorLocation, requestor);
5711
		cu.codeComplete(cursorLocation, requestor);
5739
5712
5740
		assertEquals(
5713
		assertEquals(
5741
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5714
			"",
5742
			requestor.getResults());
5715
			requestor.getResults());
5743
}
5716
}
5744
public void testCompletionKeywordInterface4() throws JavaModelException {
5717
public void testCompletionKeywordFalse4() throws JavaModelException {
5745
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5718
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5746
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface4.java");
5719
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFalse4.java");
5747
5720
5748
		String str = cu.getSource();
5721
		String str = cu.getSource();
5749
		String completeBehind = "interf";
5722
		String completeBehind = "fal";
5750
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5723
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5751
		cu.codeComplete(cursorLocation, requestor);
5724
		cu.codeComplete(cursorLocation, requestor);
5752
5725
5753
		assertEquals(
5726
		assertEquals(
5754
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5727
			"element:false    completion:false    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
5755
			requestor.getResults());
5728
			requestor.getResults());
5756
}
5729
}
5757
public void testCompletionKeywordInterface5() throws JavaModelException {
5730
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=95008
5731
public void testCompletionKeywordFalse5() throws JavaModelException {
5732
	this.workingCopies = new ICompilationUnit[1];
5733
	this.workingCopies[0] = getWorkingCopy(
5734
		"/Completion/src/test/Test.java",
5735
		"package test;"+
5736
		"public class Test {\n" + 
5737
		"  boolean test = ;\n" + 
5738
		"}\n");
5739
5740
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
5741
	String str = this.workingCopies[0].getSource();
5742
	String completeBehind = "boolean test = ";
5743
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5744
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
5745
5746
	assertResults(
5747
			"Test[TYPE_REF]{Test, test, Ltest.Test;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
5748
			"clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
5749
			"finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
5750
			"getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
5751
			"hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
5752
			"notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
5753
			"notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
5754
			"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
5755
			"wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
5756
			"wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
5757
			"wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
5758
			"test[FIELD_REF]{test, Ltest.Test;, Z, test, null, " + (R_DEFAULT + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" +
5759
			"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" +
5760
			"false[KEYWORD]{false, null, null, false, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_TRUE_OR_FALSE + R_NON_RESTRICTED) + "}\n" +
5761
			"true[KEYWORD]{true, null, null, true, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_TRUE_OR_FALSE + R_NON_RESTRICTED) + "}",
5762
			requestor.getResults());
5763
}
5764
public void testCompletionKeywordFinal1() throws JavaModelException {
5758
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5765
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5759
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface5.java");
5766
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal1.java");
5760
5767
5761
		String str = cu.getSource();
5768
		String str = cu.getSource();
5762
		String completeBehind = "interf";
5769
		String completeBehind = "fin";
5763
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5770
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5764
		cu.codeComplete(cursorLocation, requestor);
5771
		cu.codeComplete(cursorLocation, requestor);
5765
5772
5766
		assertEquals(
5773
		assertEquals(
5767
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5774
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5768
			requestor.getResults());
5775
			requestor.getResults());
5769
}
5776
}
5770
public void testCompletionKeywordInterface6() throws JavaModelException {
5777
public void testCompletionKeywordFinal10() throws JavaModelException {
5771
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5778
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5772
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface6.java");
5779
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal10.java");
5773
5780
5774
		String str = cu.getSource();
5781
		String str = cu.getSource();
5775
		String completeBehind = "interf";
5782
		String completeBehind = "fin";
5776
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5783
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5777
		cu.codeComplete(cursorLocation, requestor);
5784
		cu.codeComplete(cursorLocation, requestor);
5778
5785
5779
		assertEquals(
5786
		assertEquals(
5780
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5787
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5781
			requestor.getResults());
5788
			requestor.getResults());
5782
}
5789
}
5783
public void testCompletionKeywordInterface7() throws JavaModelException {
5790
public void testCompletionKeywordFinal11() throws JavaModelException {
5784
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5791
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5785
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface7.java");
5792
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal11.java");
5786
5793
5787
		String str = cu.getSource();
5794
		String str = cu.getSource();
5788
		String completeBehind = "interf";
5795
		String completeBehind = "fin";
5789
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5796
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5790
		cu.codeComplete(cursorLocation, requestor);
5797
		cu.codeComplete(cursorLocation, requestor);
5791
5798
5792
		assertEquals(
5799
		assertEquals(
5793
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5800
			"",
5794
			requestor.getResults());
5801
			requestor.getResults());
5795
}
5802
}
5796
public void testCompletionKeywordInterface8() throws JavaModelException {
5803
public void testCompletionKeywordFinal12() throws JavaModelException {
5797
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5804
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5798
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface8.java");
5805
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal12.java");
5799
5806
5800
		String str = cu.getSource();
5807
		String str = cu.getSource();
5801
		String completeBehind = "interf";
5808
		String completeBehind = "fin";
5802
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5809
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5803
		cu.codeComplete(cursorLocation, requestor);
5810
		cu.codeComplete(cursorLocation, requestor);
5804
5811
5805
		assertEquals(
5812
		assertEquals(
5806
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5813
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5807
			requestor.getResults());
5814
			requestor.getResults());
5808
}
5815
}
5809
public void testCompletionKeywordInterface9() throws JavaModelException {
5816
public void testCompletionKeywordFinal13() throws JavaModelException {
5810
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5817
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5811
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface9.java");
5818
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal13.java");
5812
5819
5813
		String str = cu.getSource();
5820
		String str = cu.getSource();
5814
		String completeBehind = "interf";
5821
		String completeBehind = "fin";
5815
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5822
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5816
		cu.codeComplete(cursorLocation, requestor);
5823
		cu.codeComplete(cursorLocation, requestor);
5817
5824
5818
		assertEquals(
5825
		assertEquals(
5819
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5826
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5820
			requestor.getResults());
5827
			requestor.getResults());
5821
}
5828
}
5822
public void testCompletionKeywordThrows1() throws JavaModelException {
5829
public void testCompletionKeywordFinal14() throws JavaModelException {
5823
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5830
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5824
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrows1.java");
5831
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal14.java");
5825
5832
5826
		String str = cu.getSource();
5833
		String str = cu.getSource();
5827
		String completeBehind = "thro";
5834
		String completeBehind = "fin";
5828
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5835
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5829
		cu.codeComplete(cursorLocation, requestor);
5836
		cu.codeComplete(cursorLocation, requestor);
5830
5837
5831
		assertEquals(
5838
		assertEquals(
5832
			"element:throws    completion:throws    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5839
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
5840
			"element:finalize    completion:protected void finalize() throws Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
5833
			requestor.getResults());
5841
			requestor.getResults());
5834
}
5842
}
5835
public void testCompletionKeywordThrows2() throws JavaModelException {
5843
public void testCompletionKeywordFinal15() throws JavaModelException {
5836
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5844
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5837
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrows2.java");
5845
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal15.java");
5838
5846
5839
		String str = cu.getSource();
5847
		String str = cu.getSource();
5840
		String completeBehind = "thro";
5848
		String completeBehind = "fin";
5841
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5849
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5842
		cu.codeComplete(cursorLocation, requestor);
5850
		cu.codeComplete(cursorLocation, requestor);
5843
5851
Lines 5845-5895 Link Here
5845
			"",
5853
			"",
5846
			requestor.getResults());
5854
			requestor.getResults());
5847
}
5855
}
5848
public void testCompletionKeywordThrows3() throws JavaModelException {
5856
public void testCompletionKeywordFinal16() throws JavaModelException {
5849
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5857
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5850
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrows3.java");
5858
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal16.java");
5851
5859
5852
		String str = cu.getSource();
5860
		String str = cu.getSource();
5853
		String completeBehind = "thro";
5861
		String completeBehind = "fin";
5854
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5862
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5855
		cu.codeComplete(cursorLocation, requestor);
5863
		cu.codeComplete(cursorLocation, requestor);
5856
5864
5857
		assertEquals(
5865
		assertEquals(
5858
			"element:throws    completion:throws    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5866
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
5867
			"element:finalize    completion:protected void finalize() throws Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
5859
			requestor.getResults());
5868
			requestor.getResults());
5860
}
5869
}
5861
public void testCompletionKeywordThrows4() throws JavaModelException {
5870
public void testCompletionKeywordFinal17() throws JavaModelException {
5862
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5871
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5863
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrows4.java");
5872
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal17.java");
5864
5873
5865
		String str = cu.getSource();
5874
		String str = cu.getSource();
5866
		String completeBehind = "thro";
5875
		String completeBehind = "fin";
5867
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5876
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5868
		cu.codeComplete(cursorLocation, requestor);
5877
		cu.codeComplete(cursorLocation, requestor);
5869
5878
5870
		assertEquals(
5879
		assertEquals(
5871
			"element:throws    completion:throws    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5880
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5872
			requestor.getResults());
5881
			requestor.getResults());
5873
}
5882
}
5874
public void testCompletionKeywordSynchronized1() throws JavaModelException {
5883
public void testCompletionKeywordFinal18() throws JavaModelException {
5875
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5884
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5876
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized1.java");
5885
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal18.java");
5877
5886
5878
		String str = cu.getSource();
5887
		String str = cu.getSource();
5879
		String completeBehind = "syn";
5888
		String completeBehind = "fin";
5880
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5889
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5881
		cu.codeComplete(cursorLocation, requestor);
5890
		cu.codeComplete(cursorLocation, requestor);
5882
5891
5883
		assertEquals(
5892
		assertEquals(
5884
			"element:synchronized    completion:synchronized    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5893
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
5894
			"element:finalize    completion:finalize()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
5885
			requestor.getResults());
5895
			requestor.getResults());
5886
}
5896
}
5887
public void testCompletionKeywordSynchronized2() throws JavaModelException {
5897
public void testCompletionKeywordFinal2() throws JavaModelException {
5888
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5898
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5889
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized2.java");
5899
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal2.java");
5890
5900
5891
		String str = cu.getSource();
5901
		String str = cu.getSource();
5892
		String completeBehind = "syn";
5902
		String completeBehind = "fin";
5893
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5903
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5894
		cu.codeComplete(cursorLocation, requestor);
5904
		cu.codeComplete(cursorLocation, requestor);
5895
5905
Lines 5897-5947 Link Here
5897
			"",
5907
			"",
5898
			requestor.getResults());
5908
			requestor.getResults());
5899
}
5909
}
5900
public void testCompletionKeywordSynchronized3() throws JavaModelException {
5910
public void testCompletionKeywordFinal3() throws JavaModelException {
5901
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5911
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5902
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized3.java");
5912
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal3.java");
5903
5913
5904
		String str = cu.getSource();
5914
		String str = cu.getSource();
5905
		String completeBehind = "syn";
5915
		String completeBehind = "fin";
5906
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5916
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5907
		cu.codeComplete(cursorLocation, requestor);
5917
		cu.codeComplete(cursorLocation, requestor);
5908
5918
5909
		assertEquals(
5919
		assertEquals(
5910
			"element:synchronized    completion:synchronized    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5920
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5911
			requestor.getResults());
5921
			requestor.getResults());
5912
}
5922
}
5913
public void testCompletionKeywordSynchronized4() throws JavaModelException {
5923
public void testCompletionKeywordFinal4() throws JavaModelException {
5914
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5924
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5915
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized4.java");
5925
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal4.java");
5916
5926
5917
		String str = cu.getSource();
5927
		String str = cu.getSource();
5918
		String completeBehind = "syn";
5928
		String completeBehind = "fin";
5919
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5929
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5920
		cu.codeComplete(cursorLocation, requestor);
5930
		cu.codeComplete(cursorLocation, requestor);
5921
5931
5922
		assertEquals(
5932
		assertEquals(
5923
			"",
5933
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5924
			requestor.getResults());
5934
			requestor.getResults());
5925
}
5935
}
5926
public void testCompletionKeywordSynchronized5() throws JavaModelException {
5936
public void testCompletionKeywordFinal5() throws JavaModelException {
5927
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5937
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5928
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized5.java");
5938
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal5.java");
5929
5939
5930
		String str = cu.getSource();
5940
		String str = cu.getSource();
5931
		String completeBehind = "syn";
5941
		String completeBehind = "fin";
5932
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5942
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5933
		cu.codeComplete(cursorLocation, requestor);
5943
		cu.codeComplete(cursorLocation, requestor);
5934
5944
5935
		assertEquals(
5945
		assertEquals(
5936
			"element:synchronized    completion:synchronized    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5946
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
5947
			"element:finalize    completion:protected void finalize() throws Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
5937
			requestor.getResults());
5948
			requestor.getResults());
5938
}
5949
}
5939
public void testCompletionKeywordSynchronized6() throws JavaModelException {
5950
public void testCompletionKeywordFinal6() throws JavaModelException {
5940
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5951
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5941
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized6.java");
5952
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal6.java");
5942
5953
5943
		String str = cu.getSource();
5954
		String str = cu.getSource();
5944
		String completeBehind = "syn";
5955
		String completeBehind = "fin";
5945
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5956
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5946
		cu.codeComplete(cursorLocation, requestor);
5957
		cu.codeComplete(cursorLocation, requestor);
5947
5958
Lines 5949-6025 Link Here
5949
			"",
5960
			"",
5950
			requestor.getResults());
5961
			requestor.getResults());
5951
}
5962
}
5952
public void testCompletionKeywordNative1() throws JavaModelException {
5963
public void testCompletionKeywordFinal7() throws JavaModelException {
5953
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5964
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5954
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNative1.java");
5965
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal7.java");
5955
5966
5956
		String str = cu.getSource();
5967
		String str = cu.getSource();
5957
		String completeBehind = "nat";
5968
		String completeBehind = "fin";
5958
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5969
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5959
		cu.codeComplete(cursorLocation, requestor);
5970
		cu.codeComplete(cursorLocation, requestor);
5960
5971
5961
		assertEquals(
5972
		assertEquals(
5962
			"element:native    completion:native    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5973
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
5974
			"element:finalize    completion:protected void finalize() throws Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
5963
			requestor.getResults());
5975
			requestor.getResults());
5964
}
5976
}
5965
public void testCompletionKeywordNative2() throws JavaModelException {
5977
public void testCompletionKeywordFinal8() throws JavaModelException {
5966
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5978
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5967
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNative2.java");
5979
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal8.java");
5968
5980
5969
		String str = cu.getSource();
5981
		String str = cu.getSource();
5970
		String completeBehind = "nat";
5982
		String completeBehind = "fin";
5971
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5983
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5972
		cu.codeComplete(cursorLocation, requestor);
5984
		cu.codeComplete(cursorLocation, requestor);
5973
5985
5974
		assertEquals(
5986
		assertEquals(
5975
			"",
5987
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
5976
			requestor.getResults());
5988
			requestor.getResults());
5977
}
5989
}
5978
public void testCompletionKeywordNative3() throws JavaModelException {
5990
public void testCompletionKeywordFinal9() throws JavaModelException {
5979
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5991
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5980
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNative3.java");
5992
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal9.java");
5981
5993
5982
		String str = cu.getSource();
5994
		String str = cu.getSource();
5983
		String completeBehind = "nat";
5995
		String completeBehind = "fin";
5984
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5996
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5985
		cu.codeComplete(cursorLocation, requestor);
5997
		cu.codeComplete(cursorLocation, requestor);
5986
5998
5987
		assertEquals(
5999
		assertEquals(
5988
			"element:native    completion:native    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6000
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
6001
			"element:finalize    completion:finalize()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE +R_UNQUALIFIED+ R_NON_RESTRICTED),
5989
			requestor.getResults());
6002
			requestor.getResults());
5990
}
6003
}
5991
public void testCompletionKeywordNative4() throws JavaModelException {
6004
public void testCompletionKeywordFinally1() throws JavaModelException {
5992
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6005
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
5993
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNative4.java");
6006
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally1.java");
5994
6007
5995
		String str = cu.getSource();
6008
		String str = cu.getSource();
5996
		String completeBehind = "nat";
6009
		String completeBehind = "finall";
5997
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6010
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5998
		cu.codeComplete(cursorLocation, requestor);
6011
		cu.codeComplete(cursorLocation, requestor);
5999
6012
6000
		assertEquals(
6013
		assertEquals(
6001
			"",
6014
			"element:finally    completion:finally    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6002
			requestor.getResults());
6015
			requestor.getResults());
6003
}
6016
}
6004
public void testCompletionKeywordStrictfp1() throws JavaModelException {
6017
public void testCompletionKeywordFinally10() throws JavaModelException {
6005
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6018
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6006
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStrictfp1.java");
6019
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally10.java");
6007
6020
6008
		String str = cu.getSource();
6021
		String str = cu.getSource();
6009
		String completeBehind = "stric";
6022
		String completeBehind = "finall";
6010
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6023
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6011
		cu.codeComplete(cursorLocation, requestor);
6024
		cu.codeComplete(cursorLocation, requestor);
6012
6025
6013
		assertEquals(
6026
		assertEquals(
6014
			"element:strictfp    completion:strictfp    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6027
			"",
6015
			requestor.getResults());
6028
			requestor.getResults());
6016
}
6029
}
6017
public void testCompletionKeywordStrictfp2() throws JavaModelException {
6030
public void testCompletionKeywordFinally11() throws JavaModelException {
6018
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6031
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6019
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStrictfp2.java");
6032
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally11.java");
6020
6033
6021
		String str = cu.getSource();
6034
		String str = cu.getSource();
6022
		String completeBehind = "stric";
6035
		String completeBehind = "finall";
6023
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6036
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6024
		cu.codeComplete(cursorLocation, requestor);
6037
		cu.codeComplete(cursorLocation, requestor);
6025
6038
Lines 6027-6077 Link Here
6027
			"",
6040
			"",
6028
			requestor.getResults());
6041
			requestor.getResults());
6029
}
6042
}
6030
public void testCompletionKeywordStrictfp3() throws JavaModelException {
6043
public void testCompletionKeywordFinally12() throws JavaModelException {
6031
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6044
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6032
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStrictfp3.java");
6045
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally12.java");
6033
6046
6034
		String str = cu.getSource();
6047
		String str = cu.getSource();
6035
		String completeBehind = "stric";
6048
		String completeBehind = "finall";
6036
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6049
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6037
		cu.codeComplete(cursorLocation, requestor);
6050
		cu.codeComplete(cursorLocation, requestor);
6038
6051
6039
		assertEquals(
6052
		assertEquals(
6040
			"element:strictfp    completion:strictfp    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6053
			"element:finally    completion:finally    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6041
			requestor.getResults());
6054
			requestor.getResults());
6042
}
6055
}
6043
public void testCompletionKeywordStrictfp4() throws JavaModelException {
6056
public void testCompletionKeywordFinally13() throws JavaModelException {
6044
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6057
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6045
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStrictfp4.java");
6058
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally13.java");
6046
6059
6047
		String str = cu.getSource();
6060
		String str = cu.getSource();
6048
		String completeBehind = "stric";
6061
		String completeBehind = "finall";
6049
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6062
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6050
		cu.codeComplete(cursorLocation, requestor);
6063
		cu.codeComplete(cursorLocation, requestor);
6051
6064
6052
		assertEquals(
6065
		assertEquals(
6053
			"",
6066
			"element:finally    completion:finally    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
6067
			"element:finallyz    completion:finallyz    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
6054
			requestor.getResults());
6068
			requestor.getResults());
6055
}
6069
}
6056
public void testCompletionKeywordVolatile1() throws JavaModelException {
6070
public void testCompletionKeywordFinally14() throws JavaModelException {
6057
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6071
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6058
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordVolatile1.java");
6072
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally14.java");
6059
6073
6060
		String str = cu.getSource();
6074
		String str = cu.getSource();
6061
		String completeBehind = "vol";
6075
		String completeBehind = "finall";
6062
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6076
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6063
		cu.codeComplete(cursorLocation, requestor);
6077
		cu.codeComplete(cursorLocation, requestor);
6064
6078
6065
		assertEquals(
6079
		assertEquals(
6066
			"element:volatile    completion:volatile    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6080
			"element:finallyz    completion:finallyz    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
6067
			requestor.getResults());
6081
			requestor.getResults());
6068
}
6082
}
6069
public void testCompletionKeywordVolatile2() throws JavaModelException {
6083
public void testCompletionKeywordFinally2() throws JavaModelException {
6070
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6084
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6071
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordVolatile2.java");
6085
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally2.java");
6072
6086
6073
		String str = cu.getSource();
6087
		String str = cu.getSource();
6074
		String completeBehind = "vol";
6088
		String completeBehind = "finall";
6075
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6089
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6076
		cu.codeComplete(cursorLocation, requestor);
6090
		cu.codeComplete(cursorLocation, requestor);
6077
6091
Lines 6079-6103 Link Here
6079
			"",
6093
			"",
6080
			requestor.getResults());
6094
			requestor.getResults());
6081
}
6095
}
6082
public void testCompletionKeywordVolatile3() throws JavaModelException {
6096
public void testCompletionKeywordFinally3() throws JavaModelException {
6083
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6097
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6084
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordVolatile3.java");
6098
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally3.java");
6085
6099
6086
		String str = cu.getSource();
6100
		String str = cu.getSource();
6087
		String completeBehind = "vol";
6101
		String completeBehind = "finall";
6088
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6102
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6089
		cu.codeComplete(cursorLocation, requestor);
6103
		cu.codeComplete(cursorLocation, requestor);
6090
6104
6091
		assertEquals(
6105
		assertEquals(
6092
			"element:volatile    completion:volatile    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6106
			"",
6093
			requestor.getResults());
6107
			requestor.getResults());
6094
}
6108
}
6095
public void testCompletionKeywordVolatile4() throws JavaModelException {
6109
public void testCompletionKeywordFinally4() throws JavaModelException {
6096
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6110
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6097
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordVolatile4.java");
6111
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally4.java");
6098
6112
6099
		String str = cu.getSource();
6113
		String str = cu.getSource();
6100
		String completeBehind = "vol";
6114
		String completeBehind = "finall";
6101
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6115
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6102
		cu.codeComplete(cursorLocation, requestor);
6116
		cu.codeComplete(cursorLocation, requestor);
6103
6117
Lines 6105-6311 Link Here
6105
			"",
6119
			"",
6106
			requestor.getResults());
6120
			requestor.getResults());
6107
}
6121
}
6108
public void testCompletionKeywordTransient1() throws JavaModelException {
6122
public void testCompletionKeywordFinally5() throws JavaModelException {
6109
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6123
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6110
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTransient1.java");
6124
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally5.java");
6111
6125
6112
		String str = cu.getSource();
6126
		String str = cu.getSource();
6113
		String completeBehind = "tran";
6127
		String completeBehind = "finall";
6114
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6128
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6115
		cu.codeComplete(cursorLocation, requestor);
6129
		cu.codeComplete(cursorLocation, requestor);
6116
6130
6117
		assertEquals(
6131
		assertEquals(
6118
			"element:transient    completion:transient    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6132
			"element:finally    completion:finally    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6119
			requestor.getResults());
6133
			requestor.getResults());
6120
}
6134
}
6121
public void testCompletionKeywordTransient2() throws JavaModelException {
6135
public void testCompletionKeywordFinally6() throws JavaModelException {
6122
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6136
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6123
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTransient2.java");
6137
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally6.java");
6124
6138
6125
		String str = cu.getSource();
6139
		String str = cu.getSource();
6126
		String completeBehind = "tran";
6140
		String completeBehind = "finall";
6127
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6141
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6128
		cu.codeComplete(cursorLocation, requestor);
6142
		cu.codeComplete(cursorLocation, requestor);
6129
6143
6130
		assertEquals(
6144
		assertEquals(
6131
			"",
6145
			"element:finally    completion:finally    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
6146
			"element:finallyz    completion:finallyz    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
6132
			requestor.getResults());
6147
			requestor.getResults());
6133
}
6148
}
6134
public void testCompletionKeywordTransient3() throws JavaModelException {
6149
public void testCompletionKeywordFinally7() throws JavaModelException {
6135
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6150
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6136
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTransient3.java");
6151
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally7.java");
6137
6152
6138
		String str = cu.getSource();
6153
		String str = cu.getSource();
6139
		String completeBehind = "tran";
6154
		String completeBehind = "finall";
6140
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6155
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6141
		cu.codeComplete(cursorLocation, requestor);
6156
		cu.codeComplete(cursorLocation, requestor);
6142
6157
6143
		assertEquals(
6158
		assertEquals(
6144
			"element:transient    completion:transient    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6159
			"element:finallyz    completion:finallyz    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
6145
			requestor.getResults());
6160
			requestor.getResults());
6146
}
6161
}
6147
public void testCompletionKeywordTransient4() throws JavaModelException {
6162
public void testCompletionKeywordFinally8() throws JavaModelException {
6148
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6163
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6149
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTransient4.java");
6164
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally8.java");
6150
6165
6151
		String str = cu.getSource();
6166
		String str = cu.getSource();
6152
		String completeBehind = "tran";
6167
		String completeBehind = "finall";
6153
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6168
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6154
		cu.codeComplete(cursorLocation, requestor);
6169
		cu.codeComplete(cursorLocation, requestor);
6155
6170
6156
		assertEquals(
6171
		assertEquals(
6157
			"",
6172
			"element:finally    completion:finally    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6158
			requestor.getResults());
6173
			requestor.getResults());
6159
}
6174
}
6160
public void testCompletionKeywordNew1() throws JavaModelException {
6175
public void testCompletionKeywordFinally9() throws JavaModelException {
6161
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6176
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6162
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew1.java");
6177
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally9.java");
6163
6178
6164
		String str = cu.getSource();
6179
		String str = cu.getSource();
6165
		String completeBehind = "ne";
6180
		String completeBehind = "finall";
6166
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6181
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6167
		cu.codeComplete(cursorLocation, requestor);
6182
		cu.codeComplete(cursorLocation, requestor);
6168
6183
6169
		assertEquals(
6184
		assertEquals(
6170
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6185
			"",
6171
			requestor.getResults());
6186
			requestor.getResults());
6172
}
6187
}
6173
public void testCompletionKeywordNew2() throws JavaModelException {
6188
public void testCompletionKeywordFor1() throws JavaModelException {
6174
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6189
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6175
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew2.java");
6190
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFor1.java");
6176
6191
6177
		String str = cu.getSource();
6192
		String str = cu.getSource();
6178
		String completeBehind = "ne";
6193
		String completeBehind = "fo";
6179
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6194
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6180
		cu.codeComplete(cursorLocation, requestor);
6195
		cu.codeComplete(cursorLocation, requestor);
6181
6196
6182
		assertEquals(
6197
		assertEquals(
6183
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6198
			"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
6199
			"element:for    completion:for    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6184
			requestor.getResults());
6200
			requestor.getResults());
6185
}
6201
}
6186
public void testCompletionKeywordNew3() throws JavaModelException {
6202
public void testCompletionKeywordFor2() throws JavaModelException {
6187
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6203
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6188
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew3.java");
6204
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFor2.java");
6189
6205
6190
		String str = cu.getSource();
6206
		String str = cu.getSource();
6191
		String completeBehind = "ne";
6207
		String completeBehind = "fo";
6192
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6208
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6193
		cu.codeComplete(cursorLocation, requestor);
6209
		cu.codeComplete(cursorLocation, requestor);
6194
6210
6195
		assertEquals(
6211
		assertEquals(
6196
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6212
			"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
6197
			requestor.getResults());
6213
			requestor.getResults());
6198
}
6214
}
6199
public void testCompletionKeywordNew4() throws JavaModelException {
6215
public void testCompletionKeywordFor3() throws JavaModelException {
6200
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6216
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6201
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew4.java");
6217
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFor3.java");
6202
6218
6203
		String str = cu.getSource();
6219
		String str = cu.getSource();
6204
		String completeBehind = "ne";
6220
		String completeBehind = "fo";
6205
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6221
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6206
		cu.codeComplete(cursorLocation, requestor);
6222
		cu.codeComplete(cursorLocation, requestor);
6207
6223
6208
		assertEquals(
6224
		assertEquals(
6209
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6225
			"",
6210
			requestor.getResults());
6226
			requestor.getResults());
6211
}
6227
}
6212
public void testCompletionKeywordNew5() throws JavaModelException {
6228
public void testCompletionKeywordFor4() throws JavaModelException {
6213
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6229
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6214
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew5.java");
6230
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFor4.java");
6215
6231
6216
		String str = cu.getSource();
6232
		String str = cu.getSource();
6217
		String completeBehind = "ne";
6233
		String completeBehind = "fo";
6218
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6234
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6219
		cu.codeComplete(cursorLocation, requestor);
6235
		cu.codeComplete(cursorLocation, requestor);
6220
6236
6221
		assertEquals(
6237
		assertEquals(
6222
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6238
			"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
6239
			"element:for    completion:for    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6223
			requestor.getResults());
6240
			requestor.getResults());
6224
}
6241
}
6225
public void testCompletionKeywordNew6() throws JavaModelException {
6242
public void testCompletionKeywordFor5() throws JavaModelException {
6226
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6243
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6227
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew6.java");
6244
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFor5.java");
6228
6245
6229
		String str = cu.getSource();
6246
		String str = cu.getSource();
6230
		String completeBehind = "ne";
6247
		String completeBehind = "fo";
6231
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6248
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6232
		cu.codeComplete(cursorLocation, requestor);
6249
		cu.codeComplete(cursorLocation, requestor);
6233
6250
6234
		assertEquals(
6251
		assertEquals(
6235
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6252
			"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
6236
			requestor.getResults());
6253
			requestor.getResults());
6237
}
6254
}
6238
public void testCompletionKeywordNew7() throws JavaModelException {
6255
public void testCompletionKeywordFor6() throws JavaModelException {
6239
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6256
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6240
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew7.java");
6257
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFor6.java");
6241
6258
6242
		String str = cu.getSource();
6259
		String str = cu.getSource();
6243
		String completeBehind = "ne";
6260
		String completeBehind = "fo";
6244
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6261
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6245
		cu.codeComplete(cursorLocation, requestor);
6262
		cu.codeComplete(cursorLocation, requestor);
6246
6263
6247
		assertEquals(
6264
		assertEquals(
6248
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6265
			"",
6249
			requestor.getResults());
6266
			requestor.getResults());
6250
}
6267
}
6251
public void testCompletionKeywordNew8() throws JavaModelException {
6268
public void testCompletionKeywordIf1() throws JavaModelException {
6252
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6269
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6253
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew8.java");
6270
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordIf1.java");
6254
6271
6255
		String str = cu.getSource();
6272
		String str = cu.getSource();
6256
		String completeBehind = "ne";
6273
		String completeBehind = "if";
6257
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6274
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6258
		cu.codeComplete(cursorLocation, requestor);
6275
		cu.codeComplete(cursorLocation, requestor);
6259
6276
6260
		assertEquals(
6277
		assertEquals(
6261
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6278
			"element:if    completion:if    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME+ R_NON_RESTRICTED),
6262
			requestor.getResults());
6279
			requestor.getResults());
6263
}
6280
}
6264
public void testCompletionKeywordStatic1() throws JavaModelException {
6281
public void testCompletionKeywordIf2() throws JavaModelException {
6265
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6282
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6266
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic1.java");
6283
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordIf2.java");
6267
6284
6268
		String str = cu.getSource();
6285
		String str = cu.getSource();
6269
		String completeBehind = "sta";
6286
		String completeBehind = "if";
6270
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6287
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6271
		cu.codeComplete(cursorLocation, requestor);
6288
		cu.codeComplete(cursorLocation, requestor);
6272
6289
6273
		assertEquals(
6290
		assertEquals(
6274
			"element:static    completion:static    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6291
			"",
6275
			requestor.getResults());
6292
			requestor.getResults());
6276
}
6293
}
6277
public void testCompletionKeywordStatic2() throws JavaModelException {
6294
public void testCompletionKeywordIf3() throws JavaModelException {
6278
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6295
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6279
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic2.java");
6296
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordIf3.java");
6280
6297
6281
		String str = cu.getSource();
6298
		String str = cu.getSource();
6282
		String completeBehind = "sta";
6299
		String completeBehind = "if";
6283
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6300
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6284
		cu.codeComplete(cursorLocation, requestor);
6301
		cu.codeComplete(cursorLocation, requestor);
6285
6302
6286
		assertEquals(
6303
		assertEquals(
6287
			"element:static    completion:static    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6304
			"",
6288
			requestor.getResults());
6305
			requestor.getResults());
6289
}
6306
}
6290
public void testCompletionKeywordStatic3() throws JavaModelException {
6307
public void testCompletionKeywordIf4() throws JavaModelException {
6291
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6308
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6292
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic3.java");
6309
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordIf4.java");
6293
6310
6294
		String str = cu.getSource();
6311
		String str = cu.getSource();
6295
		String completeBehind = "sta";
6312
		String completeBehind = "if";
6296
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6313
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6297
		cu.codeComplete(cursorLocation, requestor);
6314
		cu.codeComplete(cursorLocation, requestor);
6298
6315
6299
		assertEquals(
6316
		assertEquals(
6300
			"element:static    completion:static    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6317
			"element:if    completion:if    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME+ R_NON_RESTRICTED),
6301
			requestor.getResults());
6318
			requestor.getResults());
6302
}
6319
}
6303
public void testCompletionKeywordStatic4() throws JavaModelException {
6320
public void testCompletionKeywordIf5() throws JavaModelException {
6304
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6321
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6305
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic4.java");
6322
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordIf5.java");
6306
6323
6307
		String str = cu.getSource();
6324
		String str = cu.getSource();
6308
		String completeBehind = "sta";
6325
		String completeBehind = "if";
6309
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6326
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6310
		cu.codeComplete(cursorLocation, requestor);
6327
		cu.codeComplete(cursorLocation, requestor);
6311
6328
Lines 6313-6454 Link Here
6313
			"",
6330
			"",
6314
			requestor.getResults());
6331
			requestor.getResults());
6315
}
6332
}
6316
public void testCompletionKeywordStatic5() throws JavaModelException {
6333
public void testCompletionKeywordIf6() throws JavaModelException {
6317
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6334
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6318
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic5.java");
6335
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordIf6.java");
6319
6336
6320
		String str = cu.getSource();
6337
		String str = cu.getSource();
6321
		String completeBehind = "sta";
6338
		String completeBehind = "if";
6322
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6339
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6323
		cu.codeComplete(cursorLocation, requestor);
6340
		cu.codeComplete(cursorLocation, requestor);
6324
6341
6325
		assertEquals(
6342
		assertEquals(
6326
			"element:static    completion:static    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6343
			"",
6327
			requestor.getResults());
6344
			requestor.getResults());
6328
}
6345
}
6329
public void testCompletionKeywordPublic1() throws JavaModelException {
6346
public void testCompletionKeywordImplements1() throws JavaModelException {
6330
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6347
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6331
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic1.java");
6348
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImplements1.java");
6332
6349
6333
		String str = cu.getSource();
6350
		String str = cu.getSource();
6334
		String completeBehind = "pub";
6351
		String completeBehind = "imp";
6335
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6352
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6336
		cu.codeComplete(cursorLocation, requestor);
6353
		cu.codeComplete(cursorLocation, requestor);
6337
6354
6338
		assertEquals(
6355
		assertEquals(
6339
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6356
			"element:implements    completion:implements    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6340
			requestor.getResults());
6357
			requestor.getResults());
6341
}
6358
}
6342
public void testCompletionKeywordPublic2() throws JavaModelException {
6359
public void testCompletionKeywordImplements2() throws JavaModelException {
6343
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6360
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6344
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic2.java");
6361
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImplements2.java");
6345
6362
6346
		String str = cu.getSource();
6363
		String str = cu.getSource();
6347
		String completeBehind = "pub";
6364
		String completeBehind = "imp";
6348
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6365
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6349
		cu.codeComplete(cursorLocation, requestor);
6366
		cu.codeComplete(cursorLocation, requestor);
6350
6367
6351
		assertEquals(
6368
		assertEquals(
6352
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6369
			"element:implements    completion:implements    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6353
			requestor.getResults());
6370
			requestor.getResults());
6354
}
6371
}
6355
public void testCompletionKeywordPublic3() throws JavaModelException {
6372
public void testCompletionKeywordImplements3() throws JavaModelException {
6356
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6373
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6357
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic3.java");
6374
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImplements3.java");
6358
6375
6359
		String str = cu.getSource();
6376
		String str = cu.getSource();
6360
		String completeBehind = "pub";
6377
		String completeBehind = "imp";
6361
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6378
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6362
		cu.codeComplete(cursorLocation, requestor);
6379
		cu.codeComplete(cursorLocation, requestor);
6363
6380
6364
		assertEquals(
6381
		assertEquals(
6365
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6382
			"",
6366
			requestor.getResults());
6383
			requestor.getResults());
6367
}
6384
}
6368
public void testCompletionKeywordPublic4() throws JavaModelException {
6385
public void testCompletionKeywordImplements4() throws JavaModelException {
6369
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6386
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6370
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic4.java");
6387
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImplements4.java");
6371
6388
6372
		String str = cu.getSource();
6389
		String str = cu.getSource();
6373
		String completeBehind = "pub";
6390
		String completeBehind = "imp";
6374
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6391
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6375
		cu.codeComplete(cursorLocation, requestor);
6392
		cu.codeComplete(cursorLocation, requestor);
6376
6393
6377
		assertEquals(
6394
		assertEquals(
6378
			"",
6395
			"element:implements    completion:implements    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6379
			requestor.getResults());
6396
			requestor.getResults());
6380
}
6397
}
6381
public void testCompletionKeywordPublic5() throws JavaModelException {
6398
public void testCompletionKeywordImplements5() throws JavaModelException {
6382
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6399
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6383
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic5.java");
6400
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImplements5.java");
6384
6401
6385
		String str = cu.getSource();
6402
		String str = cu.getSource();
6386
		String completeBehind = "pub";
6403
		String completeBehind = "imp";
6387
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6404
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6388
		cu.codeComplete(cursorLocation, requestor);
6405
		cu.codeComplete(cursorLocation, requestor);
6389
6406
6390
		assertEquals(
6407
		assertEquals(
6391
			"",
6408
			"element:implements    completion:implements    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6392
			requestor.getResults());
6409
			requestor.getResults());
6393
}
6410
}
6394
public void testCompletionKeywordPublic6() throws JavaModelException {
6411
public void testCompletionKeywordImplements6() throws JavaModelException {
6395
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6412
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6396
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic6.java");
6413
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImplements6.java");
6397
6414
6398
		String str = cu.getSource();
6415
		String str = cu.getSource();
6399
		String completeBehind = "pub";
6416
		String completeBehind = "imp";
6400
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6417
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6401
		cu.codeComplete(cursorLocation, requestor);
6418
		cu.codeComplete(cursorLocation, requestor);
6402
6419
6403
		assertEquals(
6420
		assertEquals(
6404
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6421
			"",
6405
			requestor.getResults());
6422
			requestor.getResults());
6406
}
6423
}
6407
public void testCompletionKeywordPublic7() throws JavaModelException {
6424
public void testCompletionKeywordImport1() throws JavaModelException {
6408
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6425
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6409
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic7.java");
6426
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImport1.java");
6410
6427
6411
		String str = cu.getSource();
6428
		String str = cu.getSource();
6412
		String completeBehind = "pub";
6429
		String completeBehind = "imp";
6413
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6430
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6414
		cu.codeComplete(cursorLocation, requestor);
6431
		cu.codeComplete(cursorLocation, requestor);
6415
6432
6416
		assertEquals(
6433
		assertEquals(
6417
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6434
			"element:import    completion:import    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6418
			requestor.getResults());
6435
			requestor.getResults());
6419
}
6436
}
6420
public void testCompletionKeywordPublic8() throws JavaModelException {
6437
public void testCompletionKeywordImport2() throws JavaModelException {
6421
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6438
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6422
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic8.java");
6439
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "p", "CompletionKeywordImport2.java");
6423
6440
6424
		String str = cu.getSource();
6441
		String str = cu.getSource();
6425
		String completeBehind = "pub";
6442
		String completeBehind = "imp";
6426
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6443
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6427
		cu.codeComplete(cursorLocation, requestor);
6444
		cu.codeComplete(cursorLocation, requestor);
6428
6445
6429
		assertEquals(
6446
		assertEquals(
6430
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6447
			"element:import    completion:import    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6431
			requestor.getResults());
6448
			requestor.getResults());
6432
}
6449
}
6433
public void testCompletionKeywordPublic9() throws JavaModelException {
6450
public void testCompletionKeywordImport3() throws JavaModelException {
6434
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6451
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6435
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic9.java");
6452
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImport3.java");
6436
6453
6437
		String str = cu.getSource();
6454
		String str = cu.getSource();
6438
		String completeBehind = "pub";
6455
		String completeBehind = "imp";
6439
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6456
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6440
		cu.codeComplete(cursorLocation, requestor);
6457
		cu.codeComplete(cursorLocation, requestor);
6441
6458
6442
		assertEquals(
6459
		assertEquals(
6443
			"",
6460
			"element:import    completion:import    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6444
			requestor.getResults());
6461
			requestor.getResults());
6445
}
6462
}
6446
public void testCompletionKeywordPublic10() throws JavaModelException {
6463
public void testCompletionKeywordImport4() throws JavaModelException {
6447
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6464
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6448
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic10.java");
6465
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImport4.java");
6449
6466
6450
		String str = cu.getSource();
6467
		String str = cu.getSource();
6451
		String completeBehind = "pub";
6468
		String completeBehind = "imp";
6452
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6469
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6453
		cu.codeComplete(cursorLocation, requestor);
6470
		cu.codeComplete(cursorLocation, requestor);
6454
6471
Lines 6456-6571 Link Here
6456
			"",
6473
			"",
6457
			requestor.getResults());
6474
			requestor.getResults());
6458
}
6475
}
6459
public void testCompletionKeywordPrivate1() throws JavaModelException {
6476
public void testCompletionKeywordImport5() throws JavaModelException {
6460
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6477
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6461
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate1.java");
6478
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImport5.java");
6462
6479
6463
		String str = cu.getSource();
6480
		String str = cu.getSource();
6464
		String completeBehind = "pri";
6481
		String completeBehind = "imp";
6465
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6482
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6466
		cu.codeComplete(cursorLocation, requestor);
6483
		cu.codeComplete(cursorLocation, requestor);
6467
6484
6468
		assertEquals(
6485
		assertEquals(
6469
			"element:private    completion:private    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6486
			"element:import    completion:import    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6470
			requestor.getResults());
6487
			requestor.getResults());
6471
}
6488
}
6472
public void testCompletionKeywordPrivate2() throws JavaModelException {
6489
public void testCompletionKeywordImport6() throws JavaModelException {
6473
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6490
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6474
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate2.java");
6491
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImport6.java");
6475
6492
6476
		String str = cu.getSource();
6493
		String str = cu.getSource();
6477
		String completeBehind = "pri";
6494
		String completeBehind = "imp";
6478
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6495
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6479
		cu.codeComplete(cursorLocation, requestor);
6496
		cu.codeComplete(cursorLocation, requestor);
6480
6497
6481
		assertEquals(
6498
		assertEquals(
6482
			"element:private    completion:private    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6499
			"",
6483
			requestor.getResults());
6500
			requestor.getResults());
6484
}
6501
}
6485
public void testCompletionKeywordPrivate3() throws JavaModelException {
6502
public void testCompletionKeywordImport7() throws JavaModelException {
6486
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6503
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6487
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate3.java");
6504
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImport7.java");
6488
6505
6489
		String str = cu.getSource();
6506
		String str = cu.getSource();
6490
		String completeBehind = "pri";
6507
		String completeBehind = "imp";
6491
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6508
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6492
		cu.codeComplete(cursorLocation, requestor);
6509
		cu.codeComplete(cursorLocation, requestor);
6493
6510
6494
		assertEquals(
6511
		assertEquals(
6495
			"element:private    completion:private    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6512
			"element:import    completion:import    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6496
			requestor.getResults());
6513
			requestor.getResults());
6497
}
6514
}
6498
public void testCompletionKeywordPrivate4() throws JavaModelException {
6515
public void testCompletionKeywordImport8() throws JavaModelException {
6499
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6516
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6500
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate4.java");
6517
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "p", "CompletionKeywordImport8.java");
6501
6518
6502
		String str = cu.getSource();
6519
		String str = cu.getSource();
6503
		String completeBehind = "pri";
6520
		String completeBehind = "imp";
6504
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6521
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6505
		cu.codeComplete(cursorLocation, requestor);
6522
		cu.codeComplete(cursorLocation, requestor);
6506
6523
6507
		assertEquals(
6524
		assertEquals(
6508
			"",
6525
			"element:import    completion:import    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6509
			requestor.getResults());
6526
			requestor.getResults());
6510
}
6527
}
6511
public void testCompletionKeywordPrivate5() throws JavaModelException {
6528
public void testCompletionKeywordInstanceof1() throws JavaModelException {
6512
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6529
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6513
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate5.java");
6530
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInstanceof1.java");
6514
6531
6515
		String str = cu.getSource();
6532
		String str = cu.getSource();
6516
		String completeBehind = "pri";
6533
		String completeBehind = "ins";
6517
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6534
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6518
		cu.codeComplete(cursorLocation, requestor);
6535
		cu.codeComplete(cursorLocation, requestor);
6519
6536
6520
		assertEquals(
6537
		assertEquals(
6521
			"",
6538
			"element:instanceof    completion:instanceof    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6522
			requestor.getResults());
6539
			requestor.getResults());
6523
}
6540
}
6524
public void testCompletionKeywordProtected1() throws JavaModelException {
6541
public void testCompletionKeywordInstanceof2() throws JavaModelException {
6525
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6542
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6526
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected1.java");
6543
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInstanceof2.java");
6527
6544
6528
		String str = cu.getSource();
6545
		String str = cu.getSource();
6529
		String completeBehind = "pro";
6546
		String completeBehind = "ins";
6530
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6547
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6531
		cu.codeComplete(cursorLocation, requestor);
6548
		cu.codeComplete(cursorLocation, requestor);
6532
6549
6533
		assertEquals(
6550
		assertEquals(
6534
			"element:protected    completion:protected    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6551
			"",
6535
			requestor.getResults());
6552
			requestor.getResults());
6536
}
6553
}
6537
public void testCompletionKeywordProtected2() throws JavaModelException {
6554
public void testCompletionKeywordInstanceof3() throws JavaModelException {
6538
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6555
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6539
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected2.java");
6556
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInstanceof3.java");
6540
6557
6541
		String str = cu.getSource();
6558
		String str = cu.getSource();
6542
		String completeBehind = "pro";
6559
		String completeBehind = "ins";
6543
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6560
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6544
		cu.codeComplete(cursorLocation, requestor);
6561
		cu.codeComplete(cursorLocation, requestor);
6545
6562
6546
		assertEquals(
6563
		assertEquals(
6547
			"element:protected    completion:protected    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6564
			"",
6548
			requestor.getResults());
6565
			requestor.getResults());
6549
}
6566
}
6550
public void testCompletionKeywordProtected3() throws JavaModelException {
6567
public void testCompletionKeywordInstanceof4() throws JavaModelException {
6551
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6568
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6552
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected3.java");
6569
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInstanceof4.java");
6553
6570
6554
		String str = cu.getSource();
6571
		String str = cu.getSource();
6555
		String completeBehind = "pro";
6572
		String completeBehind = "ins";
6556
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6573
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6557
		cu.codeComplete(cursorLocation, requestor);
6574
		cu.codeComplete(cursorLocation, requestor);
6558
6575
6559
		assertEquals(
6576
		assertEquals(
6560
			"element:protected    completion:protected    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6577
			"element:instanceof    completion:instanceof    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6561
			requestor.getResults());
6578
			requestor.getResults());
6562
}
6579
}
6563
public void testCompletionKeywordProtected4() throws JavaModelException {
6580
public void testCompletionKeywordInstanceof5() throws JavaModelException {
6564
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6581
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6565
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected4.java");
6582
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInstanceof5.java");
6566
6583
6567
		String str = cu.getSource();
6584
		String str = cu.getSource();
6568
		String completeBehind = "pro";
6585
		String completeBehind = "ins";
6569
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6586
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6570
		cu.codeComplete(cursorLocation, requestor);
6587
		cu.codeComplete(cursorLocation, requestor);
6571
6588
Lines 6573-6584 Link Here
6573
			"",
6590
			"",
6574
			requestor.getResults());
6591
			requestor.getResults());
6575
}
6592
}
6576
public void testCompletionKeywordProtected5() throws JavaModelException {
6593
public void testCompletionKeywordInstanceof6() throws JavaModelException {
6577
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6594
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6578
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected5.java");
6595
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInstanceof6.java");
6579
6596
6580
		String str = cu.getSource();
6597
		String str = cu.getSource();
6581
		String completeBehind = "pro";
6598
		String completeBehind = "ins";
6582
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6599
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6583
		cu.codeComplete(cursorLocation, requestor);
6600
		cu.codeComplete(cursorLocation, requestor);
6584
6601
Lines 6586-6847 Link Here
6586
			"",
6603
			"",
6587
			requestor.getResults());
6604
			requestor.getResults());
6588
}
6605
}
6589
public void testCompletionKeywordFinal1() throws JavaModelException {
6606
public void testCompletionKeywordInterface1() throws JavaModelException {
6590
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6607
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6591
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal1.java");
6608
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface1.java");
6592
6609
6593
		String str = cu.getSource();
6610
		String str = cu.getSource();
6594
		String completeBehind = "fin";
6611
		String completeBehind = "interf";
6595
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6612
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6596
		cu.codeComplete(cursorLocation, requestor);
6613
		cu.codeComplete(cursorLocation, requestor);
6597
6614
6598
		assertEquals(
6615
		assertEquals(
6599
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6616
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6600
			requestor.getResults());
6617
			requestor.getResults());
6601
}
6618
}
6602
public void testCompletionKeywordFinal2() throws JavaModelException {
6619
public void testCompletionKeywordInterface10() throws JavaModelException {
6603
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6620
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6604
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal2.java");
6621
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface1.java");
6605
6622
6606
		String str = cu.getSource();
6623
		String str = cu.getSource();
6607
		String completeBehind = "fin";
6624
		String completeBehind = "interf";
6608
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6625
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6609
		cu.codeComplete(cursorLocation, requestor);
6626
		cu.codeComplete(cursorLocation, requestor);
6610
6627
6611
		assertEquals(
6628
		assertEquals(
6612
			"",
6629
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6613
			requestor.getResults());
6630
			requestor.getResults());
6614
}
6631
}
6615
public void testCompletionKeywordFinal3() throws JavaModelException {
6632
public void testCompletionKeywordInterface11() throws JavaModelException {
6616
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6633
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6617
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal3.java");
6634
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface11.java");
6618
6635
6619
		String str = cu.getSource();
6636
		String str = cu.getSource();
6620
		String completeBehind = "fin";
6637
		String completeBehind = "interf";
6621
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6638
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6622
		cu.codeComplete(cursorLocation, requestor);
6639
		cu.codeComplete(cursorLocation, requestor);
6623
6640
6624
		assertEquals(
6641
		assertEquals(
6625
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6642
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6626
			requestor.getResults());
6643
			requestor.getResults());
6627
}
6644
}
6628
public void testCompletionKeywordFinal4() throws JavaModelException {
6645
public void testCompletionKeywordInterface12() throws JavaModelException {
6629
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6646
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6630
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal4.java");
6647
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface12.java");
6631
6648
6632
		String str = cu.getSource();
6649
		String str = cu.getSource();
6633
		String completeBehind = "fin";
6650
		String completeBehind = "interf";
6634
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6651
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6635
		cu.codeComplete(cursorLocation, requestor);
6652
		cu.codeComplete(cursorLocation, requestor);
6636
6653
6637
		assertEquals(
6654
		assertEquals(
6638
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6655
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6639
			requestor.getResults());
6656
			requestor.getResults());
6640
}
6657
}
6641
public void testCompletionKeywordFinal5() throws JavaModelException {
6658
public void testCompletionKeywordInterface13() throws JavaModelException {
6642
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6659
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6643
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal5.java");
6660
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface13.java");
6644
6661
6645
		String str = cu.getSource();
6662
		String str = cu.getSource();
6646
		String completeBehind = "fin";
6663
		String completeBehind = "interf";
6647
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6664
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6648
		cu.codeComplete(cursorLocation, requestor);
6665
		cu.codeComplete(cursorLocation, requestor);
6649
6666
6650
		assertEquals(
6667
		assertEquals(
6651
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
6668
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6652
			"element:finalize    completion:protected void finalize() throws Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
6653
			requestor.getResults());
6669
			requestor.getResults());
6654
}
6670
}
6655
public void testCompletionKeywordFinal6() throws JavaModelException {
6671
public void testCompletionKeywordInterface14() throws JavaModelException {
6656
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6672
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6657
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal6.java");
6673
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface14.java");
6658
6674
6659
		String str = cu.getSource();
6675
		String str = cu.getSource();
6660
		String completeBehind = "fin";
6676
		String completeBehind = "interf";
6661
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6677
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6662
		cu.codeComplete(cursorLocation, requestor);
6678
		cu.codeComplete(cursorLocation, requestor);
6663
6679
6664
		assertEquals(
6680
		assertEquals(
6665
			"",
6681
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6666
			requestor.getResults());
6682
			requestor.getResults());
6667
}
6683
}
6668
public void testCompletionKeywordFinal7() throws JavaModelException {
6684
public void testCompletionKeywordInterface15() throws JavaModelException {
6669
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6685
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6670
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal7.java");
6686
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface15.java");
6671
6687
6672
		String str = cu.getSource();
6688
		String str = cu.getSource();
6673
		String completeBehind = "fin";
6689
		String completeBehind = "interf";
6674
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6690
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6675
		cu.codeComplete(cursorLocation, requestor);
6691
		cu.codeComplete(cursorLocation, requestor);
6676
6692
6677
		assertEquals(
6693
		assertEquals(
6678
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
6694
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6679
			"element:finalize    completion:protected void finalize() throws Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
6680
			requestor.getResults());
6695
			requestor.getResults());
6681
}
6696
}
6682
public void testCompletionKeywordFinal8() throws JavaModelException {
6697
public void testCompletionKeywordInterface16() throws JavaModelException {
6683
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6698
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6684
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal8.java");
6699
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface16.java");
6685
6700
6686
		String str = cu.getSource();
6701
		String str = cu.getSource();
6687
		String completeBehind = "fin";
6702
		String completeBehind = "interf";
6688
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6703
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6689
		cu.codeComplete(cursorLocation, requestor);
6704
		cu.codeComplete(cursorLocation, requestor);
6690
6705
6691
		assertEquals(
6706
		assertEquals(
6692
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6707
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6693
			requestor.getResults());
6708
			requestor.getResults());
6694
}
6709
}
6695
public void testCompletionKeywordFinal9() throws JavaModelException {
6710
public void testCompletionKeywordInterface17() throws JavaModelException {
6696
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6711
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6697
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal9.java");
6712
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface17.java");
6698
6713
6699
		String str = cu.getSource();
6714
		String str = cu.getSource();
6700
		String completeBehind = "fin";
6715
		String completeBehind = "interf";
6701
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6716
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6702
		cu.codeComplete(cursorLocation, requestor);
6717
		cu.codeComplete(cursorLocation, requestor);
6703
6718
6704
		assertEquals(
6719
		assertEquals(
6705
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
6720
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6706
			"element:finalize    completion:finalize()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE +R_UNQUALIFIED+ R_NON_RESTRICTED),
6707
			requestor.getResults());
6721
			requestor.getResults());
6708
}
6722
}
6709
public void testCompletionKeywordAbstract1() throws JavaModelException {
6723
public void testCompletionKeywordInterface18() throws JavaModelException {
6710
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6724
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6711
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract1.java");
6725
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface18.java");
6712
6726
6713
		String str = cu.getSource();
6727
		String str = cu.getSource();
6714
		String completeBehind = "abs";
6728
		String completeBehind = "interf";
6715
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6729
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6716
		cu.codeComplete(cursorLocation, requestor);
6730
		cu.codeComplete(cursorLocation, requestor);
6717
6731
6718
		assertEquals(
6732
		assertEquals(
6719
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6733
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6720
			requestor.getResults());
6734
			requestor.getResults());
6721
}
6735
}
6722
public void testCompletionKeywordAbstract2() throws JavaModelException {
6736
public void testCompletionKeywordInterface2() throws JavaModelException {
6723
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6737
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6724
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract2.java");
6738
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface2.java");
6725
6739
6726
		String str = cu.getSource();
6740
		String str = cu.getSource();
6727
		String completeBehind = "abs";
6741
		String completeBehind = "interf";
6728
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6742
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6729
		cu.codeComplete(cursorLocation, requestor);
6743
		cu.codeComplete(cursorLocation, requestor);
6730
6744
6731
		assertEquals(
6745
		assertEquals(
6732
			"",
6746
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6733
			requestor.getResults());
6747
			requestor.getResults());
6734
}
6748
}
6735
public void testCompletionKeywordAbstract3() throws JavaModelException {
6749
public void testCompletionKeywordInterface3() throws JavaModelException {
6736
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6750
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6737
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract3.java");
6751
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface3.java");
6738
6752
6739
		String str = cu.getSource();
6753
		String str = cu.getSource();
6740
		String completeBehind = "abs";
6754
		String completeBehind = "interf";
6741
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6755
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6742
		cu.codeComplete(cursorLocation, requestor);
6756
		cu.codeComplete(cursorLocation, requestor);
6743
6757
6744
		assertEquals(
6758
		assertEquals(
6745
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6759
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6746
			requestor.getResults());
6760
			requestor.getResults());
6747
}
6761
}
6748
public void testCompletionKeywordAbstract4() throws JavaModelException {
6762
public void testCompletionKeywordInterface4() throws JavaModelException {
6749
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6763
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6750
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract4.java");
6764
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface4.java");
6751
6765
6752
		String str = cu.getSource();
6766
		String str = cu.getSource();
6753
		String completeBehind = "abs";
6767
		String completeBehind = "interf";
6754
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6768
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6755
		cu.codeComplete(cursorLocation, requestor);
6769
		cu.codeComplete(cursorLocation, requestor);
6756
6770
6757
		assertEquals(
6771
		assertEquals(
6758
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6772
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6759
			requestor.getResults());
6773
			requestor.getResults());
6760
}
6774
}
6761
public void testCompletionKeywordAbstract5() throws JavaModelException {
6775
public void testCompletionKeywordInterface5() throws JavaModelException {
6762
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6776
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6763
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract5.java");
6777
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface5.java");
6764
6778
6765
		String str = cu.getSource();
6779
		String str = cu.getSource();
6766
		String completeBehind = "abs";
6780
		String completeBehind = "interf";
6767
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6781
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6768
		cu.codeComplete(cursorLocation, requestor);
6782
		cu.codeComplete(cursorLocation, requestor);
6769
6783
6770
		assertEquals(
6784
		assertEquals(
6771
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6785
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6772
			requestor.getResults());
6786
			requestor.getResults());
6773
}
6787
}
6774
public void testCompletionKeywordAbstract6() throws JavaModelException {
6788
public void testCompletionKeywordInterface6() throws JavaModelException {
6775
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6789
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6776
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract6.java");
6790
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface6.java");
6777
6791
6778
		String str = cu.getSource();
6792
		String str = cu.getSource();
6779
		String completeBehind = "abs";
6793
		String completeBehind = "interf";
6780
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6794
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6781
		cu.codeComplete(cursorLocation, requestor);
6795
		cu.codeComplete(cursorLocation, requestor);
6782
6796
6783
		assertEquals(
6797
		assertEquals(
6784
			"",
6798
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6785
			requestor.getResults());
6799
			requestor.getResults());
6786
}
6800
}
6787
public void testCompletionKeywordAbstract7() throws JavaModelException {
6801
public void testCompletionKeywordInterface7() throws JavaModelException {
6788
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6802
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6789
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract7.java");
6803
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface7.java");
6790
6804
6791
		String str = cu.getSource();
6805
		String str = cu.getSource();
6792
		String completeBehind = "abs";
6806
		String completeBehind = "interf";
6793
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6807
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6794
		cu.codeComplete(cursorLocation, requestor);
6808
		cu.codeComplete(cursorLocation, requestor);
6795
6809
6796
		assertEquals(
6810
		assertEquals(
6797
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6811
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6798
			requestor.getResults());
6812
			requestor.getResults());
6799
}
6813
}
6800
public void testCompletionKeywordAbstract8() throws JavaModelException {
6814
public void testCompletionKeywordInterface8() throws JavaModelException {
6801
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6815
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6802
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract8.java");
6816
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface8.java");
6803
6817
6804
		String str = cu.getSource();
6818
		String str = cu.getSource();
6805
		String completeBehind = "abs";
6819
		String completeBehind = "interf";
6806
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6820
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6807
		cu.codeComplete(cursorLocation, requestor);
6821
		cu.codeComplete(cursorLocation, requestor);
6808
6822
6809
		assertEquals(
6823
		assertEquals(
6810
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6824
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6811
			requestor.getResults());
6825
			requestor.getResults());
6812
}
6826
}
6813
public void testCompletionKeywordTrue1() throws JavaModelException {
6827
public void testCompletionKeywordInterface9() throws JavaModelException {
6814
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6828
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6815
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTrue1.java");
6829
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface9.java");
6816
6830
6817
		String str = cu.getSource();
6831
		String str = cu.getSource();
6818
		String completeBehind = "tru";
6832
		String completeBehind = "interf";
6819
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6833
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6820
		cu.codeComplete(cursorLocation, requestor);
6834
		cu.codeComplete(cursorLocation, requestor);
6821
6835
6822
		assertEquals(
6836
		assertEquals(
6823
			"",
6837
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6824
			requestor.getResults());
6838
			requestor.getResults());
6825
}
6839
}
6826
public void testCompletionKeywordTrue2() throws JavaModelException {
6840
public void testCompletionKeywordNative1() throws JavaModelException {
6827
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6841
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6828
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTrue2.java");
6842
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNative1.java");
6829
6843
6830
		String str = cu.getSource();
6844
		String str = cu.getSource();
6831
		String completeBehind = "tru";
6845
		String completeBehind = "nat";
6832
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6846
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6833
		cu.codeComplete(cursorLocation, requestor);
6847
		cu.codeComplete(cursorLocation, requestor);
6834
6848
6835
		assertEquals(
6849
		assertEquals(
6836
			"element:true    completion:true    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
6850
			"element:native    completion:native    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6837
			requestor.getResults());
6851
			requestor.getResults());
6838
}
6852
}
6839
public void testCompletionKeywordFalse1() throws JavaModelException {
6853
public void testCompletionKeywordNative2() throws JavaModelException {
6840
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6854
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6841
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFalse1.java");
6855
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNative2.java");
6842
6856
6843
		String str = cu.getSource();
6857
		String str = cu.getSource();
6844
		String completeBehind = "fal";
6858
		String completeBehind = "nat";
6845
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6859
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6846
		cu.codeComplete(cursorLocation, requestor);
6860
		cu.codeComplete(cursorLocation, requestor);
6847
6861
Lines 6849-6873 Link Here
6849
			"",
6863
			"",
6850
			requestor.getResults());
6864
			requestor.getResults());
6851
}
6865
}
6852
public void testCompletionKeywordFalse2() throws JavaModelException {
6866
public void testCompletionKeywordNative3() throws JavaModelException {
6853
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6867
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6854
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFalse2.java");
6868
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNative3.java");
6855
6869
6856
		String str = cu.getSource();
6870
		String str = cu.getSource();
6857
		String completeBehind = "fal";
6871
		String completeBehind = "nat";
6858
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6872
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6859
		cu.codeComplete(cursorLocation, requestor);
6873
		cu.codeComplete(cursorLocation, requestor);
6860
6874
6861
		assertEquals(
6875
		assertEquals(
6862
			"element:false    completion:false    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
6876
			"element:native    completion:native    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6863
			requestor.getResults());
6877
			requestor.getResults());
6864
}
6878
}
6865
public void testCompletionKeywordNull1() throws JavaModelException {
6879
public void testCompletionKeywordNative4() throws JavaModelException {
6866
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6880
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6867
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNull1.java");
6881
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNative4.java");
6868
6882
6869
		String str = cu.getSource();
6883
		String str = cu.getSource();
6870
		String completeBehind = "nul";
6884
		String completeBehind = "nat";
6871
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6885
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6872
		cu.codeComplete(cursorLocation, requestor);
6886
		cu.codeComplete(cursorLocation, requestor);
6873
6887
Lines 6875-6925 Link Here
6875
			"",
6889
			"",
6876
			requestor.getResults());
6890
			requestor.getResults());
6877
}
6891
}
6878
public void testCompletionKeywordNull2() throws JavaModelException {
6892
public void testCompletionKeywordNative5() throws JavaModelException {
6879
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6893
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6880
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNull2.java");
6894
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNative5.java");
6881
6895
6882
		String str = cu.getSource();
6896
		String str = cu.getSource();
6883
		String completeBehind = "nul";
6897
		String completeBehind = "nat";
6884
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6898
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6885
		cu.codeComplete(cursorLocation, requestor);
6899
		cu.codeComplete(cursorLocation, requestor);
6886
6900
6887
		assertEquals(
6901
		assertEquals(
6888
			"element:null    completion:null    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6902
			"element:native    completion:native    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6889
			requestor.getResults());
6903
			requestor.getResults());
6890
}
6904
}
6891
public void testCompletionKeywordInstanceof1() throws JavaModelException {
6905
public void testCompletionKeywordNative6() throws JavaModelException {
6892
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6906
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6893
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInstanceof1.java");
6907
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNative6.java");
6894
6908
6895
		String str = cu.getSource();
6909
		String str = cu.getSource();
6896
		String completeBehind = "ins";
6910
		String completeBehind = "nat";
6897
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6911
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6898
		cu.codeComplete(cursorLocation, requestor);
6912
		cu.codeComplete(cursorLocation, requestor);
6899
6913
6900
		assertEquals(
6914
		assertEquals(
6901
			"element:instanceof    completion:instanceof    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6915
			"",
6902
			requestor.getResults());
6916
			requestor.getResults());
6903
}
6917
}
6904
public void testCompletionKeywordInstanceof2() throws JavaModelException {
6918
public void testCompletionKeywordNative7() throws JavaModelException {
6905
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6919
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6906
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInstanceof2.java");
6920
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNative7.java");
6907
6921
6908
		String str = cu.getSource();
6922
		String str = cu.getSource();
6909
		String completeBehind = "ins";
6923
		String completeBehind = "nat";
6910
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6924
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6911
		cu.codeComplete(cursorLocation, requestor);
6925
		cu.codeComplete(cursorLocation, requestor);
6912
6926
6913
		assertEquals(
6927
		assertEquals(
6914
			"",
6928
			"element:native    completion:native    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6915
			requestor.getResults());
6929
			requestor.getResults());
6916
}
6930
}
6917
public void testCompletionKeywordInstanceof3() throws JavaModelException {
6931
public void testCompletionKeywordNative8() throws JavaModelException {
6918
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6932
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6919
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInstanceof3.java");
6933
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNative8.java");
6920
6934
6921
		String str = cu.getSource();
6935
		String str = cu.getSource();
6922
		String completeBehind = "ins";
6936
		String completeBehind = "nat";
6923
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6937
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6924
		cu.codeComplete(cursorLocation, requestor);
6938
		cu.codeComplete(cursorLocation, requestor);
6925
6939
Lines 6927-7266 Link Here
6927
			"",
6941
			"",
6928
			requestor.getResults());
6942
			requestor.getResults());
6929
}
6943
}
6930
6944
public void testCompletionKeywordNew1() throws JavaModelException {
6931
public void testCompletionKeywordThis8() throws JavaModelException {
6932
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6945
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6933
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis8.java");
6946
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew1.java");
6934
6947
6935
		String str = cu.getSource();
6948
		String str = cu.getSource();
6936
		String completeBehind = "thi";
6949
		String completeBehind = "ne";
6937
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6950
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6938
		cu.codeComplete(cursorLocation, requestor);
6951
		cu.codeComplete(cursorLocation, requestor);
6939
6952
6940
		assertEquals(
6953
		assertEquals(
6941
			"element:this    completion:this    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6954
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6942
			requestor.getResults());
6955
			requestor.getResults());
6943
}
6956
}
6944
public void testCompletionKeywordThis9() throws JavaModelException {
6957
public void testCompletionKeywordNew10() throws JavaModelException {
6945
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6958
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6946
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis9.java");
6959
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew10.java");
6947
6960
6948
		String str = cu.getSource();
6961
		String str = cu.getSource();
6949
		String completeBehind = "thi";
6962
		String completeBehind = "ne";
6950
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6963
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6951
		cu.codeComplete(cursorLocation, requestor);
6964
		cu.codeComplete(cursorLocation, requestor);
6952
6965
6953
		assertEquals(
6966
		assertEquals(
6954
			"element:this    completion:this    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6967
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6955
			requestor.getResults());
6968
			requestor.getResults());
6956
}
6969
}
6957
public void testCompletionKeywordThis10() throws JavaModelException {
6970
public void testCompletionKeywordNew11() throws JavaModelException {
6958
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6971
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6959
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis10.java");
6972
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew11.java");
6960
6973
6961
		String str = cu.getSource();
6974
		String str = cu.getSource();
6962
		String completeBehind = "thi";
6975
		String completeBehind = "ne";
6963
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6976
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6964
		cu.codeComplete(cursorLocation, requestor);
6977
		cu.codeComplete(cursorLocation, requestor);
6965
6978
6966
		assertEquals(
6979
		assertEquals(
6967
			"",
6980
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6968
			requestor.getResults());
6981
			requestor.getResults());
6969
}
6982
}
6970
public void testCompletionKeywordThis11() throws JavaModelException {
6983
public void testCompletionKeywordNew12() throws JavaModelException {
6971
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6984
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6972
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis11.java");
6985
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew12.java");
6973
6986
6974
		String str = cu.getSource();
6987
		String str = cu.getSource();
6975
		String completeBehind = "thi";
6988
		String completeBehind = "ne";
6976
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6989
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6977
		cu.codeComplete(cursorLocation, requestor);
6990
		cu.codeComplete(cursorLocation, requestor);
6978
6991
6979
		assertEquals(
6992
		assertEquals(
6980
			"element:this    completion:this    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6993
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6981
			requestor.getResults());
6994
			requestor.getResults());
6982
}
6995
}
6983
public void testCompletionKeywordThis12() throws JavaModelException {
6996
public void testCompletionKeywordNew13() throws JavaModelException {
6984
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6997
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6985
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis12.java");
6998
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew13.java");
6986
6999
6987
		String str = cu.getSource();
7000
		String str = cu.getSource();
6988
		String completeBehind = "thi";
7001
		String completeBehind = "ne";
6989
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7002
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
6990
		cu.codeComplete(cursorLocation, requestor);
7003
		cu.codeComplete(cursorLocation, requestor);
6991
7004
6992
		assertEquals(
7005
		assertEquals(
6993
			"",
7006
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
6994
			requestor.getResults());
7007
			requestor.getResults());
6995
}
7008
}
6996
public void testCompletionKeywordThis13() throws JavaModelException {
7009
public void testCompletionKeywordNew14() throws JavaModelException {
6997
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7010
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
6998
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis13.java");
7011
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew14.java");
6999
7012
7000
		String str = cu.getSource();
7013
		String str = cu.getSource();
7001
		String completeBehind = "thi";
7014
		String completeBehind = "ne";
7002
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7015
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7003
		cu.codeComplete(cursorLocation, requestor);
7016
		cu.codeComplete(cursorLocation, requestor);
7004
7017
7005
		assertEquals(
7018
		assertEquals(
7006
			"element:this    completion:this    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED),
7019
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7007
			requestor.getResults());
7020
			requestor.getResults());
7008
}
7021
}
7009
public void testCompletionKeywordThis14() throws JavaModelException {
7022
public void testCompletionKeywordNew15() throws JavaModelException {
7010
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7023
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7011
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis14.java");
7024
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew15.java");
7012
7025
7013
		String str = cu.getSource();
7026
		String str = cu.getSource();
7014
		String completeBehind = "thi";
7027
		String completeBehind = "ne";
7015
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7028
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7016
		cu.codeComplete(cursorLocation, requestor);
7029
		cu.codeComplete(cursorLocation, requestor);
7017
7030
7018
		assertEquals(
7031
		assertEquals(
7019
			"",
7032
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7020
			requestor.getResults());
7033
			requestor.getResults());
7021
}
7034
}
7022
/*
7035
public void testCompletionKeywordNew16() throws JavaModelException {
7023
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=42402
7024
 */
7025
public void testCompletionKeywordThis15() throws JavaModelException {
7026
	this.wc = getWorkingCopy(
7027
            "/Completion/src2/CompletionKeywordThis15.java",
7028
            "public class CompletionKeywordThis15 {\n" +
7029
            "	public class InnerClass {\n" +
7030
            "		public InnerClass() {\n" +
7031
            "			CompletionKeywordThis15 a = CompletionKeywordThis15.this;\n" +
7032
            "		}\n" +
7033
            "	}\n" +
7034
            "}");
7035
    
7036
    
7037
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
7038
    String str = this.wc.getSource();
7039
    String completeBehind = "CompletionKeywordThis15.";
7040
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7041
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
7042
7043
	assertResults(
7044
			"CompletionKeywordThis15.InnerClass[TYPE_REF]{InnerClass, , LCompletionKeywordThis15$InnerClass;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n" +
7045
			"class[FIELD_REF]{class, null, Ljava.lang.Class;, class, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n"+
7046
			"this[KEYWORD]{this, null, null, this, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}",
7047
		requestor.getResults());
7048
}
7049
public void testCompletionKeywordSuper7() throws JavaModelException {
7050
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7036
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7051
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper7.java");
7037
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew16.java");
7052
7038
7053
		String str = cu.getSource();
7039
		String str = cu.getSource();
7054
		String completeBehind = "sup";
7040
		String completeBehind = "ne";
7055
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7041
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7056
		cu.codeComplete(cursorLocation, requestor);
7042
		cu.codeComplete(cursorLocation, requestor);
7057
7043
7058
		assertEquals(
7044
		assertEquals(
7059
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
7045
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7060
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
7061
			"element:super    completion:super    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7062
			requestor.getResults());
7046
			requestor.getResults());
7063
}
7047
}
7064
public void testCompletionKeywordSuper8() throws JavaModelException {
7048
public void testCompletionKeywordNew2() throws JavaModelException {
7065
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7049
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7066
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper8.java");
7050
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew2.java");
7067
7051
7068
		String str = cu.getSource();
7052
		String str = cu.getSource();
7069
		String completeBehind = "sup";
7053
		String completeBehind = "ne";
7070
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7054
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7071
		cu.codeComplete(cursorLocation, requestor);
7055
		cu.codeComplete(cursorLocation, requestor);
7072
7056
7073
		assertEquals(
7057
		assertEquals(
7074
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
7058
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7075
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
7076
			"element:super    completion:super    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7077
			requestor.getResults());
7059
			requestor.getResults());
7078
}
7060
}
7079
public void testCompletionKeywordSuper9() throws JavaModelException {
7061
public void testCompletionKeywordNew3() throws JavaModelException {
7080
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7062
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7081
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper9.java");
7063
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew3.java");
7082
7064
7083
		String str = cu.getSource();
7065
		String str = cu.getSource();
7084
		String completeBehind = "sup";
7066
		String completeBehind = "ne";
7085
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7067
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7086
		cu.codeComplete(cursorLocation, requestor);
7068
		cu.codeComplete(cursorLocation, requestor);
7087
7069
7088
		assertEquals(
7070
		assertEquals(
7089
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
7071
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7090
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
7091
			requestor.getResults());
7072
			requestor.getResults());
7092
}
7073
}
7093
public void testCompletionKeywordSuper10() throws JavaModelException {
7074
public void testCompletionKeywordNew4() throws JavaModelException {
7094
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7075
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7095
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper10.java");
7076
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew4.java");
7096
7077
7097
		String str = cu.getSource();
7078
		String str = cu.getSource();
7098
		String completeBehind = "sup";
7079
		String completeBehind = "ne";
7099
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7080
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7100
		cu.codeComplete(cursorLocation, requestor);
7081
		cu.codeComplete(cursorLocation, requestor);
7101
7082
7102
		assertEquals(
7083
		assertEquals(
7103
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
7084
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7104
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
7105
			"element:super    completion:super    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7106
			requestor.getResults());
7085
			requestor.getResults());
7107
}
7086
}
7108
public void testCompletionKeywordSuper11() throws JavaModelException {
7087
public void testCompletionKeywordNew5() throws JavaModelException {
7109
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7088
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7110
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper11.java");
7089
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew5.java");
7111
7090
7112
		String str = cu.getSource();
7091
		String str = cu.getSource();
7113
		String completeBehind = "sup";
7092
		String completeBehind = "ne";
7114
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7093
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7115
		cu.codeComplete(cursorLocation, requestor);
7094
		cu.codeComplete(cursorLocation, requestor);
7116
7095
7117
		assertEquals(
7096
		assertEquals(
7118
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
7097
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7119
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
7120
			requestor.getResults());
7098
			requestor.getResults());
7121
}
7099
}
7122
public void testCompletionKeywordSuper12() throws JavaModelException {
7100
public void testCompletionKeywordNew6() throws JavaModelException {
7123
	this.wc = getWorkingCopy(
7101
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7124
            "/Completion/src2/CompletionKeywordSuper12.java",
7102
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew6.java");
7125
            "public class CompletionKeywordSuper12 {\n"+
7126
            "	public CompletionKeywordSuper12() {\n"+
7127
            "		#\n"+
7128
            "		sup\n"+
7129
            "	}\n"+
7130
            "}");
7131
    
7132
    
7133
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
7134
    
7135
    String str = this.wc.getSource();
7136
    String completeBehind = "sup";
7137
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7138
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
7139
7103
7140
    assertResults(
7104
		String str = cu.getSource();
7141
            "expectedTypesSignatures=null\n"+
7105
		String completeBehind = "ne";
7142
            "expectedTypesKeys=null",
7106
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7143
            requestor.getContext());
7107
		cu.codeComplete(cursorLocation, requestor);
7144
    
7108
7145
    assertResults(
7109
		assertEquals(
7146
            "SuperClass[TYPE_REF]{SuperClass, , LSuperClass;, null, null, " + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
7110
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7147
			"SuperInterface[TYPE_REF]{SuperInterface, , LSuperInterface;, null, null, " + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
7148
			"super[KEYWORD]{super, null, null, super, null, "+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED)+"}\n" +
7149
			"super[METHOD_REF<CONSTRUCTOR>]{super(), Ljava.lang.Object;, ()V, super, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
7150
			requestor.getResults());
7111
			requestor.getResults());
7151
}
7112
}
7152
public void testCompletionKeywordTry4() throws JavaModelException {
7113
public void testCompletionKeywordNew7() throws JavaModelException {
7153
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7114
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7154
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTry4.java");
7115
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew7.java");
7155
7116
7156
		String str = cu.getSource();
7117
		String str = cu.getSource();
7157
		String completeBehind = "tr";
7118
		String completeBehind = "ne";
7158
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7119
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7159
		cu.codeComplete(cursorLocation, requestor);
7120
		cu.codeComplete(cursorLocation, requestor);
7160
7121
7161
		assertEquals(
7122
		assertEquals(
7162
			"element:try    completion:try    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7123
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7163
			requestor.getResults());
7124
			requestor.getResults());
7164
}
7125
}
7165
public void testCompletionKeywordTry5() throws JavaModelException {
7126
public void testCompletionKeywordNew8() throws JavaModelException {
7166
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7127
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7167
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTry5.java");
7128
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew8.java");
7168
7129
7169
		String str = cu.getSource();
7130
		String str = cu.getSource();
7170
		String completeBehind = "tr";
7131
		String completeBehind = "ne";
7171
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7132
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7172
		cu.codeComplete(cursorLocation, requestor);
7133
		cu.codeComplete(cursorLocation, requestor);
7173
7134
7174
		assertEquals(
7135
		assertEquals(
7175
			"element:true    completion:true    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
7136
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7176
			requestor.getResults());
7137
			requestor.getResults());
7177
}
7138
}
7178
public void testCompletionKeywordTry6() throws JavaModelException {
7139
public void testCompletionKeywordNew9() throws JavaModelException {
7179
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7140
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7180
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTry6.java");
7141
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew9.java");
7181
7142
7182
		String str = cu.getSource();
7143
		String str = cu.getSource();
7183
		String completeBehind = "try";
7144
		String completeBehind = "ne";
7184
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7145
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7185
		cu.codeComplete(cursorLocation, requestor);
7146
		cu.codeComplete(cursorLocation, requestor);
7186
7147
7187
		assertEquals(
7148
		assertEquals(
7188
			"",
7149
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7189
			requestor.getResults());
7150
			requestor.getResults());
7190
}
7151
}
7191
public void testCompletionKeywordDo4() throws JavaModelException {
7152
public void testCompletionKeywordNull1() throws JavaModelException {
7192
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7153
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7193
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDo4.java");
7154
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNull1.java");
7194
7155
7195
		String str = cu.getSource();
7156
		String str = cu.getSource();
7196
		String completeBehind = "do";
7157
		String completeBehind = "nul";
7197
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7158
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7198
		cu.codeComplete(cursorLocation, requestor);
7159
		cu.codeComplete(cursorLocation, requestor);
7199
7160
7200
		assertEquals(
7161
		assertEquals(
7201
			"element:do    completion:do    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"\n"+
7162
			"",
7202
			"element:double    completion:double    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7203
			requestor.getResults());
7163
			requestor.getResults());
7204
}
7164
}
7205
public void testCompletionKeywordDo5() throws JavaModelException {
7165
public void testCompletionKeywordNull2() throws JavaModelException {
7206
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7166
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7207
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDo5.java");
7167
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNull2.java");
7208
7168
7209
		String str = cu.getSource();
7169
		String str = cu.getSource();
7210
		String completeBehind = "do";
7170
		String completeBehind = "nul";
7211
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7171
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7212
		cu.codeComplete(cursorLocation, requestor);
7172
		cu.codeComplete(cursorLocation, requestor);
7213
7173
7214
		assertEquals(
7174
		assertEquals(
7215
			"element:double    completion:double    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7175
			"element:null    completion:null    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7216
			requestor.getResults());
7176
			requestor.getResults());
7217
}
7177
}
7218
public void testCompletionKeywordDo6() throws JavaModelException {
7178
public void testCompletionKeywordNull3() throws JavaModelException {
7219
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7179
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7220
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDo6.java");
7180
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNull3.java");
7221
7181
7222
		String str = cu.getSource();
7182
		String str = cu.getSource();
7223
		String completeBehind = "do";
7183
		String completeBehind = "nul";
7224
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7184
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7225
		cu.codeComplete(cursorLocation, requestor);
7185
		cu.codeComplete(cursorLocation, requestor);
7226
7186
7227
		assertEquals(
7187
		assertEquals(
7228
			"element:double    completion:double    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7188
			"",
7229
			requestor.getResults());
7189
			requestor.getResults());
7230
}
7190
}
7231
public void testCompletionKeywordFor4() throws JavaModelException {
7191
public void testCompletionKeywordNull4() throws JavaModelException {
7232
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7192
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7233
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFor4.java");
7193
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNull4.java");
7234
7194
7235
		String str = cu.getSource();
7195
		String str = cu.getSource();
7236
		String completeBehind = "fo";
7196
		String completeBehind = "nul";
7237
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7197
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7238
		cu.codeComplete(cursorLocation, requestor);
7198
		cu.codeComplete(cursorLocation, requestor);
7239
7199
7240
		assertEquals(
7200
		assertEquals(
7241
			"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
7201
			"element:null    completion:null    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7242
			"element:for    completion:for    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7243
			requestor.getResults());
7202
			requestor.getResults());
7244
}
7203
}
7245
public void testCompletionKeywordFor5() throws JavaModelException {
7204
public void testCompletionKeywordPackage1() throws JavaModelException {
7246
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7205
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7247
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFor5.java");
7206
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPackage1.java");
7248
7207
7249
		String str = cu.getSource();
7208
		String str = cu.getSource();
7250
		String completeBehind = "fo";
7209
		String completeBehind = "pac";
7251
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7210
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7252
		cu.codeComplete(cursorLocation, requestor);
7211
		cu.codeComplete(cursorLocation, requestor);
7253
7212
7254
		assertEquals(
7213
		assertEquals(
7255
			"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
7214
			"element:package    completion:package    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7256
			requestor.getResults());
7215
			requestor.getResults());
7257
}
7216
}
7258
public void testCompletionKeywordFor6() throws JavaModelException {
7217
public void testCompletionKeywordPackage2() throws JavaModelException {
7259
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7218
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7260
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFor6.java");
7219
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "p", "CompletionKeywordPackage2.java");
7261
7220
7262
		String str = cu.getSource();
7221
		String str = cu.getSource();
7263
		String completeBehind = "fo";
7222
		String completeBehind = "pac";
7264
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7223
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7265
		cu.codeComplete(cursorLocation, requestor);
7224
		cu.codeComplete(cursorLocation, requestor);
7266
7225
Lines 7268-7292 Link Here
7268
			"",
7227
			"",
7269
			requestor.getResults());
7228
			requestor.getResults());
7270
}
7229
}
7271
public void testCompletionKeywordIf4() throws JavaModelException {
7230
7231
public void testCompletionKeywordPackage3() throws JavaModelException {
7272
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7232
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7273
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordIf4.java");
7233
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPackage3.java");
7274
7234
7275
		String str = cu.getSource();
7235
		String str = cu.getSource();
7276
		String completeBehind = "if";
7236
		String completeBehind = "pac";
7277
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7237
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7278
		cu.codeComplete(cursorLocation, requestor);
7238
		cu.codeComplete(cursorLocation, requestor);
7279
7239
7280
		assertEquals(
7240
		assertEquals(
7281
			"element:if    completion:if    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME+ R_NON_RESTRICTED),
7241
			"",
7282
			requestor.getResults());
7242
			requestor.getResults());
7283
}
7243
}
7284
public void testCompletionKeywordIf5() throws JavaModelException {
7244
public void testCompletionKeywordPackage4() throws JavaModelException {
7285
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7245
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7286
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordIf5.java");
7246
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPackage4.java");
7287
7247
7288
		String str = cu.getSource();
7248
		String str = cu.getSource();
7289
		String completeBehind = "if";
7249
		String completeBehind = "pac";
7290
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7250
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7291
		cu.codeComplete(cursorLocation, requestor);
7251
		cu.codeComplete(cursorLocation, requestor);
7292
7252
Lines 7294-7305 Link Here
7294
			"",
7254
			"",
7295
			requestor.getResults());
7255
			requestor.getResults());
7296
}
7256
}
7297
public void testCompletionKeywordIf6() throws JavaModelException {
7257
public void testCompletionKeywordPackage5() throws JavaModelException {
7298
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7258
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7299
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordIf6.java");
7259
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPackage5.java");
7300
7260
7301
		String str = cu.getSource();
7261
		String str = cu.getSource();
7302
		String completeBehind = "if";
7262
		String completeBehind = "pac";
7303
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7263
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7304
		cu.codeComplete(cursorLocation, requestor);
7264
		cu.codeComplete(cursorLocation, requestor);
7305
7265
Lines 7307-7331 Link Here
7307
			"",
7267
			"",
7308
			requestor.getResults());
7268
			requestor.getResults());
7309
}
7269
}
7310
public void testCompletionKeywordReturn4() throws JavaModelException {
7270
public void testCompletionKeywordPackage6() throws JavaModelException {
7311
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7271
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7312
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn4.java");
7272
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPackage6.java");
7313
7273
7314
		String str = cu.getSource();
7274
		String str = cu.getSource();
7315
		String completeBehind = "re";
7275
		String completeBehind = "pac";
7316
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7276
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7317
		cu.codeComplete(cursorLocation, requestor);
7277
		cu.codeComplete(cursorLocation, requestor);
7318
7278
7319
		assertEquals(
7279
		assertEquals(
7320
			"element:return    completion:return    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7280
			"",
7321
			requestor.getResults());
7281
			requestor.getResults());
7322
}
7282
}
7323
public void testCompletionKeywordReturn5() throws JavaModelException {
7283
public void testCompletionKeywordPackage7() throws JavaModelException {
7324
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7284
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7325
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn5.java");
7285
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPackage7.java");
7326
7286
7327
		String str = cu.getSource();
7287
		String str = cu.getSource();
7328
		String completeBehind = "re";
7288
		String completeBehind = "pac";
7329
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7289
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7330
		cu.codeComplete(cursorLocation, requestor);
7290
		cu.codeComplete(cursorLocation, requestor);
7331
7291
Lines 7333-7344 Link Here
7333
			"",
7293
			"",
7334
			requestor.getResults());
7294
			requestor.getResults());
7335
}
7295
}
7336
public void testCompletionKeywordReturn6() throws JavaModelException {
7296
public void testCompletionKeywordPackage8() throws JavaModelException {
7337
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7297
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7338
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn6.java");
7298
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "p", "CompletionKeywordPackage8.java");
7339
7299
7340
		String str = cu.getSource();
7300
		String str = cu.getSource();
7341
		String completeBehind = "re";
7301
		String completeBehind = "pac";
7342
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7302
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7343
		cu.codeComplete(cursorLocation, requestor);
7303
		cu.codeComplete(cursorLocation, requestor);
7344
7304
Lines 7346-7370 Link Here
7346
			"",
7306
			"",
7347
			requestor.getResults());
7307
			requestor.getResults());
7348
}
7308
}
7349
public void testCompletionKeywordSwitch4() throws JavaModelException {
7309
public void testCompletionKeywordPrivate1() throws JavaModelException {
7350
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7310
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7351
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSwitch4.java");
7311
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate1.java");
7352
7312
7353
		String str = cu.getSource();
7313
		String str = cu.getSource();
7354
		String completeBehind = "sw";
7314
		String completeBehind = "pri";
7355
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7315
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7356
		cu.codeComplete(cursorLocation, requestor);
7316
		cu.codeComplete(cursorLocation, requestor);
7357
7317
7358
		assertEquals(
7318
		assertEquals(
7359
			"element:switch    completion:switch    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7319
			"element:private    completion:private    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7360
			requestor.getResults());
7320
			requestor.getResults());
7361
}
7321
}
7362
public void testCompletionKeywordSwitch5() throws JavaModelException {
7322
public void testCompletionKeywordPrivate10() throws JavaModelException {
7363
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7323
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7364
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSwitch5.java");
7324
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate10.java");
7365
7325
7366
		String str = cu.getSource();
7326
		String str = cu.getSource();
7367
		String completeBehind = "sw";
7327
		String completeBehind = "pri";
7368
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7328
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7369
		cu.codeComplete(cursorLocation, requestor);
7329
		cu.codeComplete(cursorLocation, requestor);
7370
7330
Lines 7372-7501 Link Here
7372
			"",
7332
			"",
7373
			requestor.getResults());
7333
			requestor.getResults());
7374
}
7334
}
7375
public void testCompletionKeywordSwitch6() throws JavaModelException {
7335
public void testCompletionKeywordPrivate2() throws JavaModelException {
7376
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7336
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7377
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSwitch6.java");
7337
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate2.java");
7378
7338
7379
		String str = cu.getSource();
7339
		String str = cu.getSource();
7380
		String completeBehind = "sw";
7340
		String completeBehind = "pri";
7381
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7341
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7382
		cu.codeComplete(cursorLocation, requestor);
7342
		cu.codeComplete(cursorLocation, requestor);
7383
7343
7384
		assertEquals(
7344
		assertEquals(
7385
			"",
7345
			"element:private    completion:private    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7386
			requestor.getResults());
7346
			requestor.getResults());
7387
}
7347
}
7388
public void testCompletionKeywordThrow4() throws JavaModelException {
7348
public void testCompletionKeywordPrivate3() throws JavaModelException {
7389
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7349
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7390
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrow4.java");
7350
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate3.java");
7391
7351
7392
		String str = cu.getSource();
7352
		String str = cu.getSource();
7393
		String completeBehind = "thr";
7353
		String completeBehind = "pri";
7394
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7354
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7395
		cu.codeComplete(cursorLocation, requestor);
7355
		cu.codeComplete(cursorLocation, requestor);
7396
7356
7397
		assertEquals(
7357
		assertEquals(
7398
			"element:Throwable    completion:Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
7358
			"element:private    completion:private    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7399
			"element:throw    completion:throw    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7400
			requestor.getResults());
7359
			requestor.getResults());
7401
}
7360
}
7402
public void testCompletionKeywordThrow5() throws JavaModelException {
7361
public void testCompletionKeywordPrivate4() throws JavaModelException {
7403
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7362
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7404
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrow5.java");
7363
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate4.java");
7405
7364
7406
		String str = cu.getSource();
7365
		String str = cu.getSource();
7407
		String completeBehind = "thr";
7366
		String completeBehind = "pri";
7408
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7367
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7409
		cu.codeComplete(cursorLocation, requestor);
7368
		cu.codeComplete(cursorLocation, requestor);
7410
7369
7411
		assertEquals(
7370
		assertEquals(
7412
			"element:Throwable    completion:Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
7371
			"",
7413
			requestor.getResults());
7372
			requestor.getResults());
7414
}
7373
}
7415
public void testCompletionKeywordThrow6() throws JavaModelException {
7374
public void testCompletionKeywordPrivate5() throws JavaModelException {
7416
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7375
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7417
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrow6.java");
7376
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate5.java");
7418
7377
7419
		String str = cu.getSource();
7378
		String str = cu.getSource();
7420
		String completeBehind = "thr";
7379
		String completeBehind = "pri";
7421
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7380
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7422
		cu.codeComplete(cursorLocation, requestor);
7381
		cu.codeComplete(cursorLocation, requestor);
7423
7382
7424
		assertEquals(
7383
		assertEquals(
7425
			"element:Throwable    completion:Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
7384
			"",
7426
			requestor.getResults());
7385
			requestor.getResults());
7427
}
7386
}
7428
public void testCompletionKeywordAssert4() throws JavaModelException {
7387
public void testCompletionKeywordPrivate6() throws JavaModelException {
7429
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7388
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7430
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAssert4.java");
7389
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate6.java");
7431
7390
7432
		String str = cu.getSource();
7391
		String str = cu.getSource();
7433
		String completeBehind = "as";
7392
		String completeBehind = "pri";
7434
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7393
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7435
		cu.codeComplete(cursorLocation, requestor);
7394
		cu.codeComplete(cursorLocation, requestor);
7436
7395
7437
		assertEquals(
7396
		assertEquals(
7438
			"element:assert    completion:assert    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7397
			"element:private    completion:private    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7439
			requestor.getResults());
7398
			requestor.getResults());
7440
}
7399
}
7441
public void testCompletionKeywordAssert5() throws JavaModelException {
7400
public void testCompletionKeywordPrivate7() throws JavaModelException {
7442
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7401
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7443
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAssert5.java");
7402
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate7.java");
7444
7403
7445
		String str = cu.getSource();
7404
		String str = cu.getSource();
7446
		String completeBehind = "as";
7405
		String completeBehind = "pri";
7447
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7406
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7448
		cu.codeComplete(cursorLocation, requestor);
7407
		cu.codeComplete(cursorLocation, requestor);
7449
7408
7450
		assertEquals(
7409
		assertEquals(
7451
			"",
7410
			"element:private    completion:private    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7452
			requestor.getResults());
7411
			requestor.getResults());
7453
}
7412
}
7454
public void testCompletionKeywordAssert6() throws JavaModelException {
7413
public void testCompletionKeywordPrivate8() throws JavaModelException {
7455
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7414
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7456
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAssert6.java");
7415
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate8.java");
7457
7416
7458
		String str = cu.getSource();
7417
		String str = cu.getSource();
7459
		String completeBehind = "as";
7418
		String completeBehind = "pri";
7460
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7419
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7461
		cu.codeComplete(cursorLocation, requestor);
7420
		cu.codeComplete(cursorLocation, requestor);
7462
7421
7463
		assertEquals(
7422
		assertEquals(
7464
			"",
7423
			"element:private    completion:private    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7465
			requestor.getResults());
7424
			requestor.getResults());
7466
}
7425
}
7467
public void testCompletionKeywordElse5() throws JavaModelException {
7426
public void testCompletionKeywordPrivate9() throws JavaModelException {
7468
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7427
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7469
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordElse5.java");
7428
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate9.java");
7470
7429
7471
		String str = cu.getSource();
7430
		String str = cu.getSource();
7472
		String completeBehind = "els";
7431
		String completeBehind = "pri";
7473
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7432
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7474
		cu.codeComplete(cursorLocation, requestor);
7433
		cu.codeComplete(cursorLocation, requestor);
7475
7434
7476
		assertEquals(
7435
		assertEquals(
7477
			"element:else    completion:else    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7436
			"",
7478
			requestor.getResults());
7437
			requestor.getResults());
7479
}
7438
}
7480
public void testCompletionKeywordElse6() throws JavaModelException {
7439
public void testCompletionKeywordProtected1() throws JavaModelException {
7481
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7440
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7482
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordElse6.java");
7441
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected1.java");
7483
7442
7484
		String str = cu.getSource();
7443
		String str = cu.getSource();
7485
		String completeBehind = "els";
7444
		String completeBehind = "pro";
7486
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7445
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7487
		cu.codeComplete(cursorLocation, requestor);
7446
		cu.codeComplete(cursorLocation, requestor);
7488
7447
7489
		assertEquals(
7448
		assertEquals(
7490
			"",
7449
			"element:protected    completion:protected    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7491
			requestor.getResults());
7450
			requestor.getResults());
7492
}
7451
}
7493
public void testCompletionKeywordElse7() throws JavaModelException {
7452
public void testCompletionKeywordProtected10() throws JavaModelException {
7494
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7453
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7495
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordElse7.java");
7454
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected10.java");
7496
7455
7497
		String str = cu.getSource();
7456
		String str = cu.getSource();
7498
		String completeBehind = "els";
7457
		String completeBehind = "pro";
7499
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7458
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7500
		cu.codeComplete(cursorLocation, requestor);
7459
		cu.codeComplete(cursorLocation, requestor);
7501
7460
Lines 7503-7540 Link Here
7503
			"",
7462
			"",
7504
			requestor.getResults());
7463
			requestor.getResults());
7505
}
7464
}
7506
public void testCompletionKeywordElse8() throws JavaModelException {
7465
public void testCompletionKeywordProtected2() throws JavaModelException {
7507
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7466
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7508
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordElse8.java");
7467
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected2.java");
7509
7468
7510
		String str = cu.getSource();
7469
		String str = cu.getSource();
7511
		String completeBehind = "els";
7470
		String completeBehind = "pro";
7512
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7471
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7513
		cu.codeComplete(cursorLocation, requestor);
7472
		cu.codeComplete(cursorLocation, requestor);
7514
7473
7515
		assertEquals(
7474
		assertEquals(
7516
			"",
7475
			"element:protected    completion:protected    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7517
			requestor.getResults());
7476
			requestor.getResults());
7518
}
7477
}
7519
public void testCompletionKeywordCatch6() throws JavaModelException {
7478
public void testCompletionKeywordProtected3() throws JavaModelException {
7520
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7479
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7521
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch6.java");
7480
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected3.java");
7522
7481
7523
		String str = cu.getSource();
7482
		String str = cu.getSource();
7524
		String completeBehind = "cat";
7483
		String completeBehind = "pro";
7525
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7484
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7526
		cu.codeComplete(cursorLocation, requestor);
7485
		cu.codeComplete(cursorLocation, requestor);
7527
7486
7528
		assertEquals(
7487
		assertEquals(
7529
			"element:catch    completion:catch    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7488
			"element:protected    completion:protected    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7530
			requestor.getResults());
7489
			requestor.getResults());
7531
}
7490
}
7532
public void testCompletionKeywordCatch7() throws JavaModelException {
7491
public void testCompletionKeywordProtected4() throws JavaModelException {
7533
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7492
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7534
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch7.java");
7493
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected4.java");
7535
7494
7536
		String str = cu.getSource();
7495
		String str = cu.getSource();
7537
		String completeBehind = "cat";
7496
		String completeBehind = "pro";
7538
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7497
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7539
		cu.codeComplete(cursorLocation, requestor);
7498
		cu.codeComplete(cursorLocation, requestor);
7540
7499
Lines 7542-7553 Link Here
7542
			"",
7501
			"",
7543
			requestor.getResults());
7502
			requestor.getResults());
7544
}
7503
}
7545
public void testCompletionKeywordCatch8() throws JavaModelException {
7504
public void testCompletionKeywordProtected5() throws JavaModelException {
7546
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7505
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7547
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch8.java");
7506
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected5.java");
7548
7507
7549
		String str = cu.getSource();
7508
		String str = cu.getSource();
7550
		String completeBehind = "cat";
7509
		String completeBehind = "pro";
7551
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7510
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7552
		cu.codeComplete(cursorLocation, requestor);
7511
		cu.codeComplete(cursorLocation, requestor);
7553
7512
Lines 7555-7606 Link Here
7555
			"",
7514
			"",
7556
			requestor.getResults());
7515
			requestor.getResults());
7557
}
7516
}
7558
public void testCompletionKeywordCatch9() throws JavaModelException {
7517
public void testCompletionKeywordProtected6() throws JavaModelException {
7559
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7518
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7560
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch9.java");
7519
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected6.java");
7561
7520
7562
		String str = cu.getSource();
7521
		String str = cu.getSource();
7563
		String completeBehind = "cat";
7522
		String completeBehind = "pro";
7564
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7523
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7565
		cu.codeComplete(cursorLocation, requestor);
7524
		cu.codeComplete(cursorLocation, requestor);
7566
7525
7567
		assertEquals(
7526
		assertEquals(
7568
			"",
7527
			"element:protected    completion:protected    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7569
			requestor.getResults());
7528
			requestor.getResults());
7570
}
7529
}
7571
public void testCompletionKeywordCatch10() throws JavaModelException {
7530
public void testCompletionKeywordProtected7() throws JavaModelException {
7572
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7531
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7573
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCatch10.java");
7532
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected7.java");
7574
7533
7575
		String str = cu.getSource();
7534
		String str = cu.getSource();
7576
		String completeBehind = "cat";
7535
		String completeBehind = "pro";
7577
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7536
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7578
		cu.codeComplete(cursorLocation, requestor);
7537
		cu.codeComplete(cursorLocation, requestor);
7579
7538
7580
		assertEquals(
7539
		assertEquals(
7581
			"element:catch    completion:catch    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
7540
			"element:protected    completion:protected    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7582
			"element:catchz    completion:catchz    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
7583
			requestor.getResults());
7541
			requestor.getResults());
7584
}
7542
}
7585
public void testCompletionKeywordFinally8() throws JavaModelException {
7543
public void testCompletionKeywordProtected8() throws JavaModelException {
7586
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7544
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7587
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally8.java");
7545
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected8.java");
7588
7546
7589
		String str = cu.getSource();
7547
		String str = cu.getSource();
7590
		String completeBehind = "finall";
7548
		String completeBehind = "pro";
7591
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7549
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7592
		cu.codeComplete(cursorLocation, requestor);
7550
		cu.codeComplete(cursorLocation, requestor);
7593
7551
7594
		assertEquals(
7552
		assertEquals(
7595
			"element:finally    completion:finally    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7553
			"element:protected    completion:protected    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7596
			requestor.getResults());
7554
			requestor.getResults());
7597
}
7555
}
7598
public void testCompletionKeywordFinally9() throws JavaModelException {
7556
public void testCompletionKeywordProtected9() throws JavaModelException {
7599
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7557
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7600
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally9.java");
7558
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected9.java");
7601
7559
7602
		String str = cu.getSource();
7560
		String str = cu.getSource();
7603
		String completeBehind = "finall";
7561
		String completeBehind = "pro";
7604
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7562
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7605
		cu.codeComplete(cursorLocation, requestor);
7563
		cu.codeComplete(cursorLocation, requestor);
7606
7564
Lines 7608-7632 Link Here
7608
			"",
7566
			"",
7609
			requestor.getResults());
7567
			requestor.getResults());
7610
}
7568
}
7611
public void testCompletionKeywordFinally10() throws JavaModelException {
7569
public void testCompletionKeywordPublic1() throws JavaModelException {
7612
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7570
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7613
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally10.java");
7571
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic1.java");
7614
7572
7615
		String str = cu.getSource();
7573
		String str = cu.getSource();
7616
		String completeBehind = "finall";
7574
		String completeBehind = "pub";
7617
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7575
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7618
		cu.codeComplete(cursorLocation, requestor);
7576
		cu.codeComplete(cursorLocation, requestor);
7619
7577
7620
		assertEquals(
7578
		assertEquals(
7621
			"",
7579
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7622
			requestor.getResults());
7580
			requestor.getResults());
7623
}
7581
}
7624
public void testCompletionKeywordFinally11() throws JavaModelException {
7582
public void testCompletionKeywordPublic10() throws JavaModelException {
7625
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7583
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7626
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally11.java");
7584
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic10.java");
7627
7585
7628
		String str = cu.getSource();
7586
		String str = cu.getSource();
7629
		String completeBehind = "finall";
7587
		String completeBehind = "pub";
7630
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7588
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7631
		cu.codeComplete(cursorLocation, requestor);
7589
		cu.codeComplete(cursorLocation, requestor);
7632
7590
Lines 7634-7698 Link Here
7634
			"",
7592
			"",
7635
			requestor.getResults());
7593
			requestor.getResults());
7636
}
7594
}
7637
public void testCompletionKeywordFinally12() throws JavaModelException {
7595
public void testCompletionKeywordPublic11() throws JavaModelException {
7638
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7596
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7639
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally12.java");
7597
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic11.java");
7640
7598
7641
		String str = cu.getSource();
7599
		String str = cu.getSource();
7642
		String completeBehind = "finall";
7600
		String completeBehind = "pub";
7643
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7601
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7644
		cu.codeComplete(cursorLocation, requestor);
7602
		cu.codeComplete(cursorLocation, requestor);
7645
7603
7646
		assertEquals(
7604
		assertEquals(
7647
			"element:finally    completion:finally    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7605
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7648
			requestor.getResults());
7606
			requestor.getResults());
7649
}
7607
}
7650
public void testCompletionKeywordFinally13() throws JavaModelException {
7608
public void testCompletionKeywordPublic12() throws JavaModelException {
7651
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7609
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7652
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally13.java");
7610
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic12.java");
7653
7611
7654
		String str = cu.getSource();
7612
		String str = cu.getSource();
7655
		String completeBehind = "finall";
7613
		String completeBehind = "pub";
7656
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7614
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7657
		cu.codeComplete(cursorLocation, requestor);
7615
		cu.codeComplete(cursorLocation, requestor);
7658
7616
7659
		assertEquals(
7617
		assertEquals(
7660
			"element:finally    completion:finally    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
7618
			"",
7661
			"element:finallyz    completion:finallyz    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
7662
			requestor.getResults());
7619
			requestor.getResults());
7663
}
7620
}
7664
public void testCompletionKeywordFinally14() throws JavaModelException {
7621
public void testCompletionKeywordPublic13() throws JavaModelException {
7665
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7622
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7666
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinally14.java");
7623
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic13.java");
7667
7624
7668
		String str = cu.getSource();
7625
		String str = cu.getSource();
7669
		String completeBehind = "finall";
7626
		String completeBehind = "pub";
7670
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7627
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7671
		cu.codeComplete(cursorLocation, requestor);
7628
		cu.codeComplete(cursorLocation, requestor);
7672
7629
7673
		assertEquals(
7630
		assertEquals(
7674
			"element:finallyz    completion:finallyz    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
7631
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7675
			requestor.getResults());
7632
			requestor.getResults());
7676
}
7633
}
7677
public void testCompletionKeywordContinue3() throws JavaModelException {
7634
public void testCompletionKeywordPublic14() throws JavaModelException {
7678
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7635
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7679
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordContinue3.java");
7636
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic14.java");
7680
7637
7681
		String str = cu.getSource();
7638
		String str = cu.getSource();
7682
		String completeBehind = "cont";
7639
		String completeBehind = "pub";
7683
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7640
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7684
		cu.codeComplete(cursorLocation, requestor);
7641
		cu.codeComplete(cursorLocation, requestor);
7685
7642
7686
		assertEquals(
7643
		assertEquals(
7687
			"element:continue    completion:continue    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7644
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7688
			requestor.getResults());
7645
			requestor.getResults());
7689
}
7646
}
7690
public void testCompletionKeywordContinue4() throws JavaModelException {
7647
public void testCompletionKeywordPublic15() throws JavaModelException {
7691
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7648
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7692
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordContinue4.java");
7649
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic15.java");
7693
7650
7694
		String str = cu.getSource();
7651
		String str = cu.getSource();
7695
		String completeBehind = "cont";
7652
		String completeBehind = "pub";
7696
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7653
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7697
		cu.codeComplete(cursorLocation, requestor);
7654
		cu.codeComplete(cursorLocation, requestor);
7698
7655
Lines 7700-7776 Link Here
7700
			"",
7657
			"",
7701
			requestor.getResults());
7658
			requestor.getResults());
7702
}
7659
}
7703
public void testCompletionKeywordBreak4() throws JavaModelException {
7660
public void testCompletionKeywordPublic16() throws JavaModelException {
7704
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7661
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7705
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordBreak4.java");
7662
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic16.java");
7706
7663
7707
		String str = cu.getSource();
7664
		String str = cu.getSource();
7708
		String completeBehind = "bre";
7665
		String completeBehind = "pub";
7709
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7666
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7710
		cu.codeComplete(cursorLocation, requestor);
7667
		cu.codeComplete(cursorLocation, requestor);
7711
7668
7712
		assertEquals(
7669
		assertEquals(
7713
			"element:break    completion:break    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7670
			"",
7714
			requestor.getResults());
7671
			requestor.getResults());
7715
}
7672
}
7716
public void testCompletionKeywordBreak5() throws JavaModelException {
7673
public void testCompletionKeywordPublic17() throws JavaModelException {
7717
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7674
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7718
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordBreak5.java");
7675
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic17.java");
7719
7676
7720
		String str = cu.getSource();
7677
		String str = cu.getSource();
7721
		String completeBehind = "bre";
7678
		String completeBehind = "pub";
7722
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7679
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7723
		cu.codeComplete(cursorLocation, requestor);
7680
		cu.codeComplete(cursorLocation, requestor);
7724
7681
7725
		assertEquals(
7682
		assertEquals(
7726
			"",
7683
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7727
			requestor.getResults());
7684
			requestor.getResults());
7728
}
7685
}
7729
public void testCompletionKeywordBreak6() throws JavaModelException {
7686
public void testCompletionKeywordPublic18() throws JavaModelException {
7730
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7687
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7731
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordBreak6.java");
7688
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic18.java");
7732
7689
7733
		String str = cu.getSource();
7690
		String str = cu.getSource();
7734
		String completeBehind = "bre";
7691
		String completeBehind = "pub";
7735
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7692
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7736
		cu.codeComplete(cursorLocation, requestor);
7693
		cu.codeComplete(cursorLocation, requestor);
7737
7694
7738
		assertEquals(
7695
		assertEquals(
7739
			"element:break    completion:break    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7696
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7740
			requestor.getResults());
7697
			requestor.getResults());
7741
}
7698
}
7742
public void testCompletionKeywordWhile6() throws JavaModelException {
7699
public void testCompletionKeywordPublic19() throws JavaModelException {
7743
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7700
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7744
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile6.java");
7701
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic19.java");
7745
7702
7746
		String str = cu.getSource();
7703
		String str = cu.getSource();
7747
		String completeBehind = "wh";
7704
		String completeBehind = "pub";
7748
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7705
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7749
		cu.codeComplete(cursorLocation, requestor);
7706
		cu.codeComplete(cursorLocation, requestor);
7750
7707
7751
		assertEquals(
7708
		assertEquals(
7752
			"element:while    completion:while    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7709
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7753
			requestor.getResults());
7710
			requestor.getResults());
7754
}
7711
}
7755
public void testCompletionKeywordWhile7() throws JavaModelException {
7712
public void testCompletionKeywordPublic2() throws JavaModelException {
7756
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7713
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7757
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile7.java");
7714
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic2.java");
7758
7715
7759
		String str = cu.getSource();
7716
		String str = cu.getSource();
7760
		String completeBehind = "wh";
7717
		String completeBehind = "pub";
7761
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7718
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7762
		cu.codeComplete(cursorLocation, requestor);
7719
		cu.codeComplete(cursorLocation, requestor);
7763
7720
7764
		assertEquals(
7721
		assertEquals(
7765
			"",
7722
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7766
			requestor.getResults());
7723
			requestor.getResults());
7767
}
7724
}
7768
public void testCompletionKeywordWhile8() throws JavaModelException {
7725
public void testCompletionKeywordPublic20() throws JavaModelException {
7769
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7726
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7770
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile8.java");
7727
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic10.java");
7771
7728
7772
		String str = cu.getSource();
7729
		String str = cu.getSource();
7773
		String completeBehind = "wh";
7730
		String completeBehind = "pub";
7774
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7731
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7775
		cu.codeComplete(cursorLocation, requestor);
7732
		cu.codeComplete(cursorLocation, requestor);
7776
7733
Lines 7778-7867 Link Here
7778
			"",
7735
			"",
7779
			requestor.getResults());
7736
			requestor.getResults());
7780
}
7737
}
7781
public void testCompletionKeywordWhile9() throws JavaModelException {
7738
public void testCompletionKeywordPublic3() throws JavaModelException {
7782
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7739
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7783
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile9.java");
7740
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic3.java");
7784
7741
7785
		String str = cu.getSource();
7742
		String str = cu.getSource();
7786
		String completeBehind = "wh";
7743
		String completeBehind = "pub";
7787
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7744
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7788
		cu.codeComplete(cursorLocation, requestor);
7745
		cu.codeComplete(cursorLocation, requestor);
7789
7746
7790
		assertEquals(
7747
		assertEquals(
7791
			"element:while    completion:while    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7748
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7792
			requestor.getResults());
7749
			requestor.getResults());
7793
}
7750
}
7794
public void testCompletionKeywordWhile10() throws JavaModelException {
7751
public void testCompletionKeywordPublic4() throws JavaModelException {
7795
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7752
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7796
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile10.java");
7753
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic4.java");
7797
7754
7798
		String str = cu.getSource();
7755
		String str = cu.getSource();
7799
		String completeBehind = "wh";
7756
		String completeBehind = "pub";
7800
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7757
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7801
		cu.codeComplete(cursorLocation, requestor);
7758
		cu.codeComplete(cursorLocation, requestor);
7802
7759
7803
		assertEquals(
7760
		assertEquals(
7804
			"element:while    completion:while    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7761
			"",
7805
			requestor.getResults());
7762
			requestor.getResults());
7806
}
7763
}
7807
public void testCompletionKeywordExtends6() throws JavaModelException {
7764
public void testCompletionKeywordPublic5() throws JavaModelException {
7808
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7765
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7809
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends6.java");
7766
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic5.java");
7810
7767
7811
		String str = cu.getSource();
7768
		String str = cu.getSource();
7812
		String completeBehind = "ext";
7769
		String completeBehind = "pub";
7813
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7770
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7814
		cu.codeComplete(cursorLocation, requestor);
7771
		cu.codeComplete(cursorLocation, requestor);
7815
7772
7816
		assertEquals(
7773
		assertEquals(
7817
			"element:extends    completion:extends    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7774
			"",
7818
			requestor.getResults());
7775
			requestor.getResults());
7819
}
7776
}
7820
public void testCompletionKeywordExtends7() throws JavaModelException {
7777
public void testCompletionKeywordPublic6() throws JavaModelException {
7821
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7778
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7822
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends7.java");
7779
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic6.java");
7823
7780
7824
		String str = cu.getSource();
7781
		String str = cu.getSource();
7825
		String completeBehind = "ext";
7782
		String completeBehind = "pub";
7826
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7783
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7827
		cu.codeComplete(cursorLocation, requestor);
7784
		cu.codeComplete(cursorLocation, requestor);
7828
7785
7829
		assertEquals(
7786
		assertEquals(
7830
			"",
7787
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7831
			requestor.getResults());
7788
			requestor.getResults());
7832
}
7789
}
7833
public void testCompletionKeywordExtends8() throws JavaModelException {
7790
public void testCompletionKeywordPublic7() throws JavaModelException {
7834
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7791
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7835
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends8.java");
7792
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic7.java");
7836
7793
7837
		String str = cu.getSource();
7794
		String str = cu.getSource();
7838
		String completeBehind = "ext";
7795
		String completeBehind = "pub";
7839
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7796
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7840
		cu.codeComplete(cursorLocation, requestor);
7797
		cu.codeComplete(cursorLocation, requestor);
7841
7798
7842
		assertEquals(
7799
		assertEquals(
7843
			"",
7800
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7844
			requestor.getResults());
7801
			requestor.getResults());
7845
}
7802
}
7846
public void testCompletionKeywordExtends9() throws JavaModelException {
7803
public void testCompletionKeywordPublic8() throws JavaModelException {
7847
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7804
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7848
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends9.java");
7805
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic8.java");
7849
7806
7850
		String str = cu.getSource();
7807
		String str = cu.getSource();
7851
		String completeBehind = "ext";
7808
		String completeBehind = "pub";
7852
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7809
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7853
		cu.codeComplete(cursorLocation, requestor);
7810
		cu.codeComplete(cursorLocation, requestor);
7854
7811
7855
		assertEquals(
7812
		assertEquals(
7856
			"element:extends    completion:extends    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7813
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7857
			requestor.getResults());
7814
			requestor.getResults());
7858
}
7815
}
7859
public void testCompletionKeywordExtends10() throws JavaModelException {
7816
public void testCompletionKeywordPublic9() throws JavaModelException {
7860
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7817
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7861
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordExtends10.java");
7818
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic9.java");
7862
7819
7863
		String str = cu.getSource();
7820
		String str = cu.getSource();
7864
		String completeBehind = "ext";
7821
		String completeBehind = "pub";
7865
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7822
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7866
		cu.codeComplete(cursorLocation, requestor);
7823
		cu.codeComplete(cursorLocation, requestor);
7867
7824
Lines 7869-7906 Link Here
7869
			"",
7826
			"",
7870
			requestor.getResults());
7827
			requestor.getResults());
7871
}
7828
}
7872
public void testCompletionKeywordImplements4() throws JavaModelException {
7829
public void testCompletionKeywordReturn1() throws JavaModelException {
7873
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7830
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7874
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImplements4.java");
7831
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn1.java");
7875
7832
7876
		String str = cu.getSource();
7833
		String str = cu.getSource();
7877
		String completeBehind = "imp";
7834
		String completeBehind = "re";
7878
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7835
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7879
		cu.codeComplete(cursorLocation, requestor);
7836
		cu.codeComplete(cursorLocation, requestor);
7880
7837
7881
		assertEquals(
7838
		assertEquals(
7882
			"element:implements    completion:implements    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7839
			"element:return    completion:return    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7883
			requestor.getResults());
7840
			requestor.getResults());
7884
}
7841
}
7885
public void testCompletionKeywordImplements5() throws JavaModelException {
7842
public void testCompletionKeywordReturn2() throws JavaModelException {
7886
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7843
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7887
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImplements5.java");
7844
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn2.java");
7888
7845
7889
		String str = cu.getSource();
7846
		String str = cu.getSource();
7890
		String completeBehind = "imp";
7847
		String completeBehind = "re";
7891
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7848
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7892
		cu.codeComplete(cursorLocation, requestor);
7849
		cu.codeComplete(cursorLocation, requestor);
7893
7850
7894
		assertEquals(
7851
		assertEquals(
7895
			"element:implements    completion:implements    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7852
			"",
7896
			requestor.getResults());
7853
			requestor.getResults());
7897
}
7854
}
7898
public void testCompletionKeywordImplements6() throws JavaModelException {
7855
public void testCompletionKeywordReturn3() throws JavaModelException {
7899
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7856
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7900
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImplements6.java");
7857
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn3.java");
7901
7858
7902
		String str = cu.getSource();
7859
		String str = cu.getSource();
7903
		String completeBehind = "imp";
7860
		String completeBehind = "re";
7904
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7861
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7905
		cu.codeComplete(cursorLocation, requestor);
7862
		cu.codeComplete(cursorLocation, requestor);
7906
7863
Lines 7908-7932 Link Here
7908
			"",
7865
			"",
7909
			requestor.getResults());
7866
			requestor.getResults());
7910
}
7867
}
7911
public void testCompletionKeywordPackage5() throws JavaModelException {
7868
public void testCompletionKeywordReturn4() throws JavaModelException {
7912
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7869
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7913
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPackage5.java");
7870
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn4.java");
7914
7871
7915
		String str = cu.getSource();
7872
		String str = cu.getSource();
7916
		String completeBehind = "pac";
7873
		String completeBehind = "re";
7917
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7874
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7918
		cu.codeComplete(cursorLocation, requestor);
7875
		cu.codeComplete(cursorLocation, requestor);
7919
7876
7920
		assertEquals(
7877
		assertEquals(
7921
			"",
7878
			"element:return    completion:return    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7922
			requestor.getResults());
7879
			requestor.getResults());
7923
}
7880
}
7924
public void testCompletionKeywordPackage6() throws JavaModelException {
7881
public void testCompletionKeywordReturn5() throws JavaModelException {
7925
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7882
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7926
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPackage6.java");
7883
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn5.java");
7927
7884
7928
		String str = cu.getSource();
7885
		String str = cu.getSource();
7929
		String completeBehind = "pac";
7886
		String completeBehind = "re";
7930
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7887
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7931
		cu.codeComplete(cursorLocation, requestor);
7888
		cu.codeComplete(cursorLocation, requestor);
7932
7889
Lines 7934-7945 Link Here
7934
			"",
7891
			"",
7935
			requestor.getResults());
7892
			requestor.getResults());
7936
}
7893
}
7937
public void testCompletionKeywordPackage7() throws JavaModelException {
7894
public void testCompletionKeywordReturn6() throws JavaModelException {
7938
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7895
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7939
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPackage7.java");
7896
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordReturn6.java");
7940
7897
7941
		String str = cu.getSource();
7898
		String str = cu.getSource();
7942
		String completeBehind = "pac";
7899
		String completeBehind = "re";
7943
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7900
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7944
		cu.codeComplete(cursorLocation, requestor);
7901
		cu.codeComplete(cursorLocation, requestor);
7945
7902
Lines 7947-8075 Link Here
7947
			"",
7904
			"",
7948
			requestor.getResults());
7905
			requestor.getResults());
7949
}
7906
}
7950
public void testCompletionKeywordPackage8() throws JavaModelException {
7907
public void testCompletionKeywordStatic1() throws JavaModelException {
7951
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7908
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7952
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "p", "CompletionKeywordPackage8.java");
7909
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic1.java");
7953
7910
7954
		String str = cu.getSource();
7911
		String str = cu.getSource();
7955
		String completeBehind = "pac";
7912
		String completeBehind = "sta";
7956
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7913
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7957
		cu.codeComplete(cursorLocation, requestor);
7914
		cu.codeComplete(cursorLocation, requestor);
7958
7915
7959
		assertEquals(
7916
		assertEquals(
7960
			"",
7917
			"element:static    completion:static    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7961
			requestor.getResults());
7918
			requestor.getResults());
7962
}
7919
}
7963
public void testCompletionKeywordImport5() throws JavaModelException {
7920
public void testCompletionKeywordStatic10() throws JavaModelException {
7964
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7921
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7965
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImport5.java");
7922
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic10.java");
7966
7923
7967
		String str = cu.getSource();
7924
		String str = cu.getSource();
7968
		String completeBehind = "imp";
7925
		String completeBehind = "sta";
7969
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7926
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7970
		cu.codeComplete(cursorLocation, requestor);
7927
		cu.codeComplete(cursorLocation, requestor);
7971
7928
7972
		assertEquals(
7929
		assertEquals(
7973
			"element:import    completion:import    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7930
			"element:static    completion:static    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7974
			requestor.getResults());
7931
			requestor.getResults());
7975
}
7932
}
7976
public void testCompletionKeywordImport6() throws JavaModelException {
7933
public void testCompletionKeywordStatic2() throws JavaModelException {
7977
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7934
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7978
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImport6.java");
7935
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic2.java");
7979
7936
7980
		String str = cu.getSource();
7937
		String str = cu.getSource();
7981
		String completeBehind = "imp";
7938
		String completeBehind = "sta";
7982
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7939
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7983
		cu.codeComplete(cursorLocation, requestor);
7940
		cu.codeComplete(cursorLocation, requestor);
7984
7941
7985
		assertEquals(
7942
		assertEquals(
7986
			"",
7943
			"element:static    completion:static    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7987
			requestor.getResults());
7944
			requestor.getResults());
7988
}
7945
}
7989
public void testCompletionKeywordImport7() throws JavaModelException {
7946
public void testCompletionKeywordStatic3() throws JavaModelException {
7990
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7947
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7991
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordImport7.java");
7948
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic3.java");
7992
7949
7993
		String str = cu.getSource();
7950
		String str = cu.getSource();
7994
		String completeBehind = "imp";
7951
		String completeBehind = "sta";
7995
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7952
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7996
		cu.codeComplete(cursorLocation, requestor);
7953
		cu.codeComplete(cursorLocation, requestor);
7997
7954
7998
		assertEquals(
7955
		assertEquals(
7999
			"element:import    completion:import    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7956
			"element:static    completion:static    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8000
			requestor.getResults());
7957
			requestor.getResults());
8001
}
7958
}
8002
public void testCompletionKeywordImport8() throws JavaModelException {
7959
public void testCompletionKeywordStatic4() throws JavaModelException {
8003
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7960
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8004
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "p", "CompletionKeywordImport8.java");
7961
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic4.java");
8005
7962
8006
		String str = cu.getSource();
7963
		String str = cu.getSource();
8007
		String completeBehind = "imp";
7964
		String completeBehind = "sta";
8008
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7965
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8009
		cu.codeComplete(cursorLocation, requestor);
7966
		cu.codeComplete(cursorLocation, requestor);
8010
7967
8011
		assertEquals(
7968
		assertEquals(
8012
			"element:import    completion:import    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7969
			"",
8013
			requestor.getResults());
7970
			requestor.getResults());
8014
}
7971
}
8015
public void testCompletionKeywordCase6() throws JavaModelException {
7972
public void testCompletionKeywordStatic5() throws JavaModelException {
8016
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7973
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8017
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase6.java");
7974
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic5.java");
8018
7975
8019
		String str = cu.getSource();
7976
		String str = cu.getSource();
8020
		String completeBehind = "cas";
7977
		String completeBehind = "sta";
8021
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7978
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8022
		cu.codeComplete(cursorLocation, requestor);
7979
		cu.codeComplete(cursorLocation, requestor);
8023
7980
8024
		assertEquals(
7981
		assertEquals(
8025
			"element:case    completion:case    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7982
			"element:static    completion:static    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8026
			requestor.getResults());
7983
			requestor.getResults());
8027
}
7984
}
8028
public void testCompletionKeywordCase7() throws JavaModelException {
7985
public void testCompletionKeywordStatic6() throws JavaModelException {
8029
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7986
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8030
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase7.java");
7987
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic6.java");
8031
7988
8032
		String str = cu.getSource();
7989
		String str = cu.getSource();
8033
		String completeBehind = "cas";
7990
		String completeBehind = "sta";
8034
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
7991
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8035
		cu.codeComplete(cursorLocation, requestor);
7992
		cu.codeComplete(cursorLocation, requestor);
8036
7993
8037
		assertEquals(
7994
		assertEquals(
8038
			"element:case    completion:case    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
7995
			"element:static    completion:static    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8039
			requestor.getResults());
7996
			requestor.getResults());
8040
}
7997
}
8041
public void testCompletionKeywordCase8() throws JavaModelException {
7998
public void testCompletionKeywordStatic7() throws JavaModelException {
8042
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
7999
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8043
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase8.java");
8000
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic7.java");
8044
8001
8045
		String str = cu.getSource();
8002
		String str = cu.getSource();
8046
		String completeBehind = "cas";
8003
		String completeBehind = "sta";
8047
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8004
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8048
		cu.codeComplete(cursorLocation, requestor);
8005
		cu.codeComplete(cursorLocation, requestor);
8049
8006
8050
		assertEquals(
8007
		assertEquals(
8051
			"element:case    completion:case    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8008
			"element:static    completion:static    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8052
			requestor.getResults());
8009
			requestor.getResults());
8053
}
8010
}
8054
public void testCompletionKeywordCase9() throws JavaModelException {
8011
public void testCompletionKeywordStatic8() throws JavaModelException {
8055
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8012
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8056
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase9.java");
8013
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic8.java");
8057
8014
8058
		String str = cu.getSource();
8015
		String str = cu.getSource();
8059
		String completeBehind = "cas";
8016
		String completeBehind = "sta";
8060
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8017
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8061
		cu.codeComplete(cursorLocation, requestor);
8018
		cu.codeComplete(cursorLocation, requestor);
8062
8019
8063
		assertEquals(
8020
		assertEquals(
8064
			"element:case    completion:case    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8021
			"element:static    completion:static    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8065
			requestor.getResults());
8022
			requestor.getResults());
8066
}
8023
}
8067
public void testCompletionKeywordCase10() throws JavaModelException {
8024
public void testCompletionKeywordStatic9() throws JavaModelException {
8068
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8025
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8069
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordCase10.java");
8026
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic9.java");
8070
8027
8071
		String str = cu.getSource();
8028
		String str = cu.getSource();
8072
		String completeBehind = "cas";
8029
		String completeBehind = "sta";
8073
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8030
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8074
		cu.codeComplete(cursorLocation, requestor);
8031
		cu.codeComplete(cursorLocation, requestor);
8075
8032
Lines 8077-8491 Link Here
8077
			"",
8034
			"",
8078
			requestor.getResults());
8035
			requestor.getResults());
8079
}
8036
}
8080
public void testCompletionKeywordDefault6() throws JavaModelException {
8037
public void testCompletionKeywordStrictfp1() throws JavaModelException {
8081
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8038
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8082
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault6.java");
8039
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStrictfp1.java");
8083
8040
8084
		String str = cu.getSource();
8041
		String str = cu.getSource();
8085
		String completeBehind = "def";
8042
		String completeBehind = "stric";
8086
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8043
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8087
		cu.codeComplete(cursorLocation, requestor);
8044
		cu.codeComplete(cursorLocation, requestor);
8088
8045
8089
		assertEquals(
8046
		assertEquals(
8090
			"element:default    completion:default    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8047
			"element:strictfp    completion:strictfp    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8091
			requestor.getResults());
8048
			requestor.getResults());
8092
}
8049
}
8093
public void testCompletionKeywordDefault7() throws JavaModelException {
8050
public void testCompletionKeywordStrictfp2() throws JavaModelException {
8094
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8051
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8095
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault7.java");
8052
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStrictfp2.java");
8096
8053
8097
		String str = cu.getSource();
8054
		String str = cu.getSource();
8098
		String completeBehind = "def";
8055
		String completeBehind = "stric";
8099
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8056
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8100
		cu.codeComplete(cursorLocation, requestor);
8057
		cu.codeComplete(cursorLocation, requestor);
8101
8058
8102
		assertEquals(
8059
		assertEquals(
8103
			"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8060
			"",
8104
			"element:default    completion:default    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8105
			requestor.getResults());
8061
			requestor.getResults());
8106
}
8062
}
8107
public void testCompletionKeywordDefault8() throws JavaModelException {
8063
public void testCompletionKeywordStrictfp3() throws JavaModelException {
8108
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8064
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8109
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault8.java");
8065
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStrictfp3.java");
8110
8066
8111
		String str = cu.getSource();
8067
		String str = cu.getSource();
8112
		String completeBehind = "def";
8068
		String completeBehind = "stric";
8113
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8069
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8114
		cu.codeComplete(cursorLocation, requestor);
8070
		cu.codeComplete(cursorLocation, requestor);
8115
8071
8116
		assertEquals(
8072
		assertEquals(
8117
			"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8073
			"element:strictfp    completion:strictfp    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8118
			"element:default    completion:default    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8119
			requestor.getResults());
8074
			requestor.getResults());
8120
}
8075
}
8121
public void testCompletionKeywordDefault9() throws JavaModelException {
8076
public void testCompletionKeywordStrictfp4() throws JavaModelException {
8122
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8077
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8123
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault9.java");
8078
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStrictfp4.java");
8124
8079
8125
		String str = cu.getSource();
8080
		String str = cu.getSource();
8126
		String completeBehind = "def";
8081
		String completeBehind = "stric";
8127
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8082
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8128
		cu.codeComplete(cursorLocation, requestor);
8083
		cu.codeComplete(cursorLocation, requestor);
8129
8084
8130
		assertEquals(
8085
		assertEquals(
8131
			"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
8086
			"",
8132
			requestor.getResults());
8087
			requestor.getResults());
8133
}
8088
}
8134
public void testCompletionKeywordDefault10() throws JavaModelException {
8089
public void testCompletionKeywordStrictfp5() throws JavaModelException {
8135
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8090
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8136
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordDefault10.java");
8091
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStrictfp5.java");
8137
8092
8138
		String str = cu.getSource();
8093
		String str = cu.getSource();
8139
		String completeBehind = "def";
8094
		String completeBehind = "stric";
8140
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8095
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8141
		cu.codeComplete(cursorLocation, requestor);
8096
		cu.codeComplete(cursorLocation, requestor);
8142
8097
8143
		assertEquals(
8098
		assertEquals(
8144
			"element:Default    completion:Default    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
8099
			"element:strictfp    completion:strictfp    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8145
			requestor.getResults());
8100
			requestor.getResults());
8146
}
8101
}
8147
public void testCompletionKeywordClass13() throws JavaModelException {
8102
public void testCompletionKeywordStrictfp6() throws JavaModelException {
8148
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8103
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8149
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass13.java");
8104
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStrictfp6.java");
8150
8105
8151
		String str = cu.getSource();
8106
		String str = cu.getSource();
8152
		String completeBehind = "cla";
8107
		String completeBehind = "stric";
8153
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8108
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8154
		cu.codeComplete(cursorLocation, requestor);
8109
		cu.codeComplete(cursorLocation, requestor);
8155
8110
8156
		assertEquals(
8111
		assertEquals(
8157
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8112
			"",
8158
			requestor.getResults());
8113
			requestor.getResults());
8159
}
8114
}
8160
public void testCompletionKeywordClass14() throws JavaModelException {
8115
public void testCompletionKeywordStrictfp7() throws JavaModelException {
8161
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8116
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8162
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass14.java");
8117
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStrictfp7.java");
8163
8118
8164
		String str = cu.getSource();
8119
		String str = cu.getSource();
8165
		String completeBehind = "cla";
8120
		String completeBehind = "stric";
8166
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8121
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8167
		cu.codeComplete(cursorLocation, requestor);
8122
		cu.codeComplete(cursorLocation, requestor);
8168
8123
8169
		assertEquals(
8124
		assertEquals(
8170
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8125
			"element:strictfp    completion:strictfp    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8171
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8172
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8173
			requestor.getResults());
8126
			requestor.getResults());
8174
}
8127
}
8175
public void testCompletionKeywordClass15() throws JavaModelException {
8128
public void testCompletionKeywordStrictfp8() throws JavaModelException {
8176
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8129
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8177
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass15.java");
8130
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStrictfp8.java");
8178
8131
8179
		String str = cu.getSource();
8132
		String str = cu.getSource();
8180
		String completeBehind = "cla";
8133
		String completeBehind = "stric";
8181
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8134
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8182
		cu.codeComplete(cursorLocation, requestor);
8135
		cu.codeComplete(cursorLocation, requestor);
8183
8136
8184
		assertEquals(
8137
		assertEquals(
8185
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8138
			"",
8186
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8187
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8188
			requestor.getResults());
8139
			requestor.getResults());
8189
}
8140
}
8190
public void testCompletionKeywordClass16() throws JavaModelException {
8141
public void testCompletionKeywordSuper1() throws JavaModelException {
8191
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8142
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8192
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass16.java");
8143
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper1.java");
8193
8144
8194
		String str = cu.getSource();
8145
		String str = cu.getSource();
8195
		String completeBehind = "cla";
8146
		String completeBehind = "sup";
8196
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8147
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8197
		cu.codeComplete(cursorLocation, requestor);
8148
		cu.codeComplete(cursorLocation, requestor);
8198
8149
8199
		assertEquals(
8150
		assertEquals(
8200
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8151
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
8201
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8152
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
8202
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8153
			"element:super    completion:super    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8203
			requestor.getResults());
8154
			requestor.getResults());
8204
}
8155
}
8205
public void testCompletionKeywordClass17() throws JavaModelException {
8156
public void testCompletionKeywordSuper10() throws JavaModelException {
8206
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8157
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8207
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass17.java");
8158
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper10.java");
8208
8159
8209
		String str = cu.getSource();
8160
		String str = cu.getSource();
8210
		String completeBehind = "cla";
8161
		String completeBehind = "sup";
8211
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8162
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8212
		cu.codeComplete(cursorLocation, requestor);
8163
		cu.codeComplete(cursorLocation, requestor);
8213
8164
8214
		assertEquals(
8165
		assertEquals(
8215
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8166
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
8167
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
8168
			"element:super    completion:super    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8216
			requestor.getResults());
8169
			requestor.getResults());
8217
}
8170
}
8218
public void testCompletionKeywordClass18() throws JavaModelException {
8171
public void testCompletionKeywordSuper11() throws JavaModelException {
8219
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8172
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8220
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass18.java");
8173
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper11.java");
8221
8174
8222
		String str = cu.getSource();
8175
		String str = cu.getSource();
8223
		String completeBehind = "cla";
8176
		String completeBehind = "sup";
8224
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8177
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8225
		cu.codeComplete(cursorLocation, requestor);
8178
		cu.codeComplete(cursorLocation, requestor);
8226
8179
8227
		assertEquals(
8180
		assertEquals(
8228
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8181
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
8182
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
8229
			requestor.getResults());
8183
			requestor.getResults());
8230
}
8184
}
8231
public void testCompletionKeywordClass19() throws JavaModelException {
8185
public void testCompletionKeywordSuper12() throws JavaModelException {
8186
	this.wc = getWorkingCopy(
8187
            "/Completion/src2/CompletionKeywordSuper12.java",
8188
            "public class CompletionKeywordSuper12 {\n"+
8189
            "	public CompletionKeywordSuper12() {\n"+
8190
            "		#\n"+
8191
            "		sup\n"+
8192
            "	}\n"+
8193
            "}");
8194
    
8195
    
8196
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
8197
    
8198
    String str = this.wc.getSource();
8199
    String completeBehind = "sup";
8200
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8201
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
8202
8203
    assertResults(
8204
            "expectedTypesSignatures=null\n"+
8205
            "expectedTypesKeys=null",
8206
            requestor.getContext());
8207
    
8208
    assertResults(
8209
            "SuperClass[TYPE_REF]{SuperClass, , LSuperClass;, null, null, " + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
8210
			"SuperInterface[TYPE_REF]{SuperInterface, , LSuperInterface;, null, null, " + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
8211
			"super[KEYWORD]{super, null, null, super, null, "+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED)+"}\n" +
8212
			"super[METHOD_REF<CONSTRUCTOR>]{super(), Ljava.lang.Object;, ()V, super, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
8213
			requestor.getResults());
8214
}
8215
public void testCompletionKeywordSuper2() throws JavaModelException {
8232
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8216
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8233
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass19.java");
8217
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper2.java");
8234
8218
8235
		String str = cu.getSource();
8219
		String str = cu.getSource();
8236
		String completeBehind = "cla";
8220
		String completeBehind = "sup";
8237
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8221
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8238
		cu.codeComplete(cursorLocation, requestor);
8222
		cu.codeComplete(cursorLocation, requestor);
8239
8223
8240
		assertEquals(
8224
		assertEquals(
8241
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8225
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
8226
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
8227
			"element:super    completion:super    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8242
			requestor.getResults());
8228
			requestor.getResults());
8243
}
8229
}
8244
public void testCompletionKeywordClass20() throws JavaModelException {
8230
public void testCompletionKeywordSuper3() throws JavaModelException {
8245
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8231
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8246
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass20.java");
8232
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper3.java");
8247
8233
8248
		String str = cu.getSource();
8234
		String str = cu.getSource();
8249
		String completeBehind = "cla";
8235
		String completeBehind = "sup";
8250
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8236
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8251
		cu.codeComplete(cursorLocation, requestor);
8237
		cu.codeComplete(cursorLocation, requestor);
8252
8238
8253
		assertEquals(
8239
		assertEquals(
8254
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8240
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
8241
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
8255
			requestor.getResults());
8242
			requestor.getResults());
8256
}
8243
}
8257
public void testCompletionKeywordClass21() throws JavaModelException {
8244
public void testCompletionKeywordSuper4() throws JavaModelException {
8258
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8245
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8259
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass21.java");
8246
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper4.java");
8260
8247
8261
		String str = cu.getSource();
8248
		String str = cu.getSource();
8262
		String completeBehind = "cla";
8249
		String completeBehind = "sup";
8263
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8250
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8264
		cu.codeComplete(cursorLocation, requestor);
8251
		cu.codeComplete(cursorLocation, requestor);
8265
8252
8266
		assertEquals(
8253
		assertEquals(
8267
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8254
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
8268
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8255
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
8269
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8256
			"element:super    completion:super    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8270
			requestor.getResults());
8257
			requestor.getResults());
8271
}
8258
}
8272
public void testCompletionKeywordClass22() throws JavaModelException {
8259
public void testCompletionKeywordSuper5() throws JavaModelException {
8273
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8260
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8274
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass22.java");
8261
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper5.java");
8275
8262
8276
		String str = cu.getSource();
8263
		String str = cu.getSource();
8277
		String completeBehind = "cla";
8264
		String completeBehind = "sup";
8278
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8265
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8279
		cu.codeComplete(cursorLocation, requestor);
8266
		cu.codeComplete(cursorLocation, requestor);
8280
8267
8281
		assertEquals(
8268
		assertEquals(
8282
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8269
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
8283
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8270
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
8284
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8285
			requestor.getResults());
8271
			requestor.getResults());
8286
}
8272
}
8287
public void testCompletionKeywordClass23() throws JavaModelException {
8273
public void testCompletionKeywordSuper6() throws JavaModelException {
8288
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8274
	this.wc = getWorkingCopy(
8289
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass23.java");
8275
            "/Completion/src2/CompletionKeywordSuper6.java",
8290
8276
            "public class CompletionKeywordSuper6 {\n"+
8291
		String str = cu.getSource();
8277
            "	public CompletionKeywordSuper6() {\n"+
8292
		String completeBehind = "cla";
8278
            "		sup\n"+
8293
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8279
            "	}\n"+
8294
		cu.codeComplete(cursorLocation, requestor);
8280
            "}");
8281
    
8282
    
8283
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
8284
    
8285
    String str = this.wc.getSource();
8286
    String completeBehind = "sup";
8287
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8288
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
8295
8289
8296
		assertEquals(
8290
    assertResults(
8297
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8291
            "expectedTypesSignatures=null\n"+
8298
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8292
            "expectedTypesKeys=null",
8299
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8293
            requestor.getContext());
8294
    
8295
    assertResults(
8296
            "SuperClass[TYPE_REF]{SuperClass, , LSuperClass;, null, null, " + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
8297
			"SuperInterface[TYPE_REF]{SuperInterface, , LSuperInterface;, null, null, " + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
8298
			"super[KEYWORD]{super, null, null, super, null, "+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED)+"}\n" +
8299
			"super[METHOD_REF<CONSTRUCTOR>]{super(), Ljava.lang.Object;, ()V, super, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
8300
			requestor.getResults());
8300
			requestor.getResults());
8301
}
8301
}
8302
public void testCompletionKeywordClass24() throws JavaModelException {
8302
public void testCompletionKeywordSuper7() throws JavaModelException {
8303
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8303
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8304
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordClass24.java");
8304
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper7.java");
8305
8305
8306
		String str = cu.getSource();
8306
		String str = cu.getSource();
8307
		String completeBehind = "cla";
8307
		String completeBehind = "sup";
8308
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8308
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8309
		cu.codeComplete(cursorLocation, requestor);
8309
		cu.codeComplete(cursorLocation, requestor);
8310
8310
8311
		assertEquals(
8311
		assertEquals(
8312
			"element:Class    completion:Class    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8312
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
8313
			"element:ClassWithComplexName    completion:ClassWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8313
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
8314
			"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8314
			"element:super    completion:super    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8315
			requestor.getResults());
8315
			requestor.getResults());
8316
}
8316
}
8317
public void testCompletionKeywordInterface10() throws JavaModelException {
8317
public void testCompletionKeywordSuper8() throws JavaModelException {
8318
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8318
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8319
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface1.java");
8319
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper8.java");
8320
8320
8321
		String str = cu.getSource();
8321
		String str = cu.getSource();
8322
		String completeBehind = "interf";
8322
		String completeBehind = "sup";
8323
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8323
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8324
		cu.codeComplete(cursorLocation, requestor);
8324
		cu.codeComplete(cursorLocation, requestor);
8325
8325
8326
		assertEquals(
8326
		assertEquals(
8327
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8327
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
8328
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
8329
			"element:super    completion:super    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8328
			requestor.getResults());
8330
			requestor.getResults());
8329
}
8331
}
8330
public void testCompletionKeywordInterface11() throws JavaModelException {
8332
public void testCompletionKeywordSuper9() throws JavaModelException {
8331
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8333
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8332
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface11.java");
8334
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSuper9.java");
8333
8335
8334
		String str = cu.getSource();
8336
		String str = cu.getSource();
8335
		String completeBehind = "interf";
8337
		String completeBehind = "sup";
8336
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8338
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8337
		cu.codeComplete(cursorLocation, requestor);
8339
		cu.codeComplete(cursorLocation, requestor);
8338
8340
8339
		assertEquals(
8341
		assertEquals(
8340
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8342
			"element:SuperClass    completion:SuperClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED) + "\n" +
8343
			"element:SuperInterface    completion:SuperInterface    relevance:" + (R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
8341
			requestor.getResults());
8344
			requestor.getResults());
8342
}
8345
}
8343
public void testCompletionKeywordInterface12() throws JavaModelException {
8346
public void testCompletionKeywordSwitch1() throws JavaModelException {
8344
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8347
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8345
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface12.java");
8348
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSwitch1.java");
8346
8349
8347
		String str = cu.getSource();
8350
		String str = cu.getSource();
8348
		String completeBehind = "interf";
8351
		String completeBehind = "sw";
8349
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8352
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8350
		cu.codeComplete(cursorLocation, requestor);
8353
		cu.codeComplete(cursorLocation, requestor);
8351
8354
8352
		assertEquals(
8355
		assertEquals(
8353
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8356
			"element:switch    completion:switch    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8354
			requestor.getResults());
8357
			requestor.getResults());
8355
}
8358
}
8356
public void testCompletionKeywordInterface13() throws JavaModelException {
8359
public void testCompletionKeywordSwitch2() throws JavaModelException {
8357
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8360
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8358
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface13.java");
8361
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSwitch2.java");
8359
8362
8360
		String str = cu.getSource();
8363
		String str = cu.getSource();
8361
		String completeBehind = "interf";
8364
		String completeBehind = "sw";
8362
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8365
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8363
		cu.codeComplete(cursorLocation, requestor);
8366
		cu.codeComplete(cursorLocation, requestor);
8364
8367
8365
		assertEquals(
8368
		assertEquals(
8366
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8369
			"",
8367
			requestor.getResults());
8370
			requestor.getResults());
8368
}
8371
}
8369
public void testCompletionKeywordInterface14() throws JavaModelException {
8372
public void testCompletionKeywordSwitch3() throws JavaModelException {
8370
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8373
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8371
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface14.java");
8374
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSwitch3.java");
8372
8375
8373
		String str = cu.getSource();
8376
		String str = cu.getSource();
8374
		String completeBehind = "interf";
8377
		String completeBehind = "sw";
8375
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8378
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8376
		cu.codeComplete(cursorLocation, requestor);
8379
		cu.codeComplete(cursorLocation, requestor);
8377
8380
8378
		assertEquals(
8381
		assertEquals(
8379
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8382
			"",
8380
			requestor.getResults());
8383
			requestor.getResults());
8381
}
8384
}
8382
public void testCompletionKeywordInterface15() throws JavaModelException {
8385
public void testCompletionKeywordSwitch4() throws JavaModelException {
8383
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8386
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8384
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface15.java");
8387
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSwitch4.java");
8385
8388
8386
		String str = cu.getSource();
8389
		String str = cu.getSource();
8387
		String completeBehind = "interf";
8390
		String completeBehind = "sw";
8388
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8391
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8389
		cu.codeComplete(cursorLocation, requestor);
8392
		cu.codeComplete(cursorLocation, requestor);
8390
8393
8391
		assertEquals(
8394
		assertEquals(
8392
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8395
			"element:switch    completion:switch    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8393
			requestor.getResults());
8396
			requestor.getResults());
8394
}
8397
}
8395
public void testCompletionKeywordInterface16() throws JavaModelException {
8398
public void testCompletionKeywordSwitch5() throws JavaModelException {
8396
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8399
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8397
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface16.java");
8400
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSwitch5.java");
8398
8401
8399
		String str = cu.getSource();
8402
		String str = cu.getSource();
8400
		String completeBehind = "interf";
8403
		String completeBehind = "sw";
8401
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8404
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8402
		cu.codeComplete(cursorLocation, requestor);
8405
		cu.codeComplete(cursorLocation, requestor);
8403
8406
8404
		assertEquals(
8407
		assertEquals(
8405
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8408
			"",
8406
			requestor.getResults());
8409
			requestor.getResults());
8407
}
8410
}
8408
public void testCompletionKeywordInterface17() throws JavaModelException {
8411
public void testCompletionKeywordSwitch6() throws JavaModelException {
8409
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8412
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8410
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface17.java");
8413
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSwitch6.java");
8411
8414
8412
		String str = cu.getSource();
8415
		String str = cu.getSource();
8413
		String completeBehind = "interf";
8416
		String completeBehind = "sw";
8414
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8417
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8415
		cu.codeComplete(cursorLocation, requestor);
8418
		cu.codeComplete(cursorLocation, requestor);
8416
8419
8417
		assertEquals(
8420
		assertEquals(
8418
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8421
			"",
8419
			requestor.getResults());
8422
			requestor.getResults());
8420
}
8423
}
8421
public void testCompletionKeywordInterface18() throws JavaModelException {
8424
public void testCompletionKeywordSynchronized1() throws JavaModelException {
8422
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8425
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8423
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInterface18.java");
8426
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized1.java");
8424
8427
8425
		String str = cu.getSource();
8428
		String str = cu.getSource();
8426
		String completeBehind = "interf";
8429
		String completeBehind = "syn";
8427
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8430
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8428
		cu.codeComplete(cursorLocation, requestor);
8431
		cu.codeComplete(cursorLocation, requestor);
8429
8432
8430
		assertEquals(
8433
		assertEquals(
8431
			"element:interface    completion:interface    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8434
			"element:synchronized    completion:synchronized    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8432
			requestor.getResults());
8435
			requestor.getResults());
8433
}
8436
}
8434
public void testCompletionKeywordThrows5() throws JavaModelException {
8437
public void testCompletionKeywordSynchronized10() throws JavaModelException {
8435
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8438
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8436
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrows5.java");
8439
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized10.java");
8437
8440
8438
		String str = cu.getSource();
8441
		String str = cu.getSource();
8439
		String completeBehind = "thro";
8442
		String completeBehind = "syn";
8440
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8443
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8441
		cu.codeComplete(cursorLocation, requestor);
8444
		cu.codeComplete(cursorLocation, requestor);
8442
8445
8443
		assertEquals(
8446
		assertEquals(
8444
			"element:throws    completion:throws    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8447
			"",
8445
			requestor.getResults());
8448
			requestor.getResults());
8446
}
8449
}
8447
public void testCompletionKeywordThrows6() throws JavaModelException {
8450
public void testCompletionKeywordSynchronized11() throws JavaModelException {
8448
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8451
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8449
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrows6.java");
8452
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized11.java");
8450
8453
8451
		String str = cu.getSource();
8454
		String str = cu.getSource();
8452
		String completeBehind = "thro";
8455
		String completeBehind = "syn";
8453
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8456
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8454
		cu.codeComplete(cursorLocation, requestor);
8457
		cu.codeComplete(cursorLocation, requestor);
8455
8458
8456
		assertEquals(
8459
		assertEquals(
8457
			"",
8460
			"element:synchronized    completion:synchronized    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8458
			requestor.getResults());
8461
			requestor.getResults());
8459
}
8462
}
8460
public void testCompletionKeywordThrows7() throws JavaModelException {
8463
public void testCompletionKeywordSynchronized12() throws JavaModelException {
8461
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8464
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8462
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrows7.java");
8465
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized12.java");
8463
8466
8464
		String str = cu.getSource();
8467
		String str = cu.getSource();
8465
		String completeBehind = "thro";
8468
		String completeBehind = "syn";
8466
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8469
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8467
		cu.codeComplete(cursorLocation, requestor);
8470
		cu.codeComplete(cursorLocation, requestor);
8468
8471
8469
		assertEquals(
8472
		assertEquals(
8470
			"element:throws    completion:throws    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8473
			"",
8471
			requestor.getResults());
8474
			requestor.getResults());
8472
}
8475
}
8473
public void testCompletionKeywordThrows8() throws JavaModelException {
8476
public void testCompletionKeywordSynchronized2() throws JavaModelException {
8474
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8477
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8475
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrows8.java");
8478
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized2.java");
8476
8479
8477
		String str = cu.getSource();
8480
		String str = cu.getSource();
8478
		String completeBehind = "thro";
8481
		String completeBehind = "syn";
8479
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8482
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8480
		cu.codeComplete(cursorLocation, requestor);
8483
		cu.codeComplete(cursorLocation, requestor);
8481
8484
8482
		assertEquals(
8485
		assertEquals(
8483
			"element:throws    completion:throws    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8486
			"",
8484
			requestor.getResults());
8487
			requestor.getResults());
8485
}
8488
}
8486
public void testCompletionKeywordSynchronized7() throws JavaModelException {
8489
public void testCompletionKeywordSynchronized3() throws JavaModelException {
8487
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8490
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8488
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized7.java");
8491
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized3.java");
8489
8492
8490
		String str = cu.getSource();
8493
		String str = cu.getSource();
8491
		String completeBehind = "syn";
8494
		String completeBehind = "syn";
Lines 8496-8504 Link Here
8496
			"element:synchronized    completion:synchronized    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8499
			"element:synchronized    completion:synchronized    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8497
			requestor.getResults());
8500
			requestor.getResults());
8498
}
8501
}
8499
public void testCompletionKeywordSynchronized8() throws JavaModelException {
8502
public void testCompletionKeywordSynchronized4() throws JavaModelException {
8500
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8503
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8501
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized8.java");
8504
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized4.java");
8502
8505
8503
		String str = cu.getSource();
8506
		String str = cu.getSource();
8504
		String completeBehind = "syn";
8507
		String completeBehind = "syn";
Lines 8509-8517 Link Here
8509
			"",
8512
			"",
8510
			requestor.getResults());
8513
			requestor.getResults());
8511
}
8514
}
8512
public void testCompletionKeywordSynchronized9() throws JavaModelException {
8515
public void testCompletionKeywordSynchronized5() throws JavaModelException {
8513
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8516
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8514
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized9.java");
8517
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized5.java");
8515
8518
8516
		String str = cu.getSource();
8519
		String str = cu.getSource();
8517
		String completeBehind = "syn";
8520
		String completeBehind = "syn";
Lines 8522-8530 Link Here
8522
			"element:synchronized    completion:synchronized    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8525
			"element:synchronized    completion:synchronized    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8523
			requestor.getResults());
8526
			requestor.getResults());
8524
}
8527
}
8525
public void testCompletionKeywordSynchronized10() throws JavaModelException {
8528
public void testCompletionKeywordSynchronized6() throws JavaModelException {
8526
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8529
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8527
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized10.java");
8530
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized6.java");
8528
8531
8529
		String str = cu.getSource();
8532
		String str = cu.getSource();
8530
		String completeBehind = "syn";
8533
		String completeBehind = "syn";
Lines 8535-8543 Link Here
8535
			"",
8538
			"",
8536
			requestor.getResults());
8539
			requestor.getResults());
8537
}
8540
}
8538
public void testCompletionKeywordSynchronized11() throws JavaModelException {
8541
public void testCompletionKeywordSynchronized7() throws JavaModelException {
8539
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8542
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8540
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized11.java");
8543
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized7.java");
8541
8544
8542
		String str = cu.getSource();
8545
		String str = cu.getSource();
8543
		String completeBehind = "syn";
8546
		String completeBehind = "syn";
Lines 8548-8556 Link Here
8548
			"element:synchronized    completion:synchronized    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8551
			"element:synchronized    completion:synchronized    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8549
			requestor.getResults());
8552
			requestor.getResults());
8550
}
8553
}
8551
public void testCompletionKeywordSynchronized12() throws JavaModelException {
8554
public void testCompletionKeywordSynchronized8() throws JavaModelException {
8552
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8555
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8553
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized12.java");
8556
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized8.java");
8554
8557
8555
		String str = cu.getSource();
8558
		String str = cu.getSource();
8556
		String completeBehind = "syn";
8559
		String completeBehind = "syn";
Lines 8561-8689 Link Here
8561
			"",
8564
			"",
8562
			requestor.getResults());
8565
			requestor.getResults());
8563
}
8566
}
8564
public void testCompletionKeywordNative5() throws JavaModelException {
8567
public void testCompletionKeywordSynchronized9() throws JavaModelException {
8565
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8568
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8566
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNative5.java");
8569
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordSynchronized9.java");
8567
8570
8568
		String str = cu.getSource();
8571
		String str = cu.getSource();
8569
		String completeBehind = "nat";
8572
		String completeBehind = "syn";
8570
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8573
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8571
		cu.codeComplete(cursorLocation, requestor);
8574
		cu.codeComplete(cursorLocation, requestor);
8572
8575
8573
		assertEquals(
8576
		assertEquals(
8574
			"element:native    completion:native    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8577
			"element:synchronized    completion:synchronized    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8575
			requestor.getResults());
8578
			requestor.getResults());
8576
}
8579
}
8577
public void testCompletionKeywordNative6() throws JavaModelException {
8580
public void testCompletionKeywordThis1() throws JavaModelException {
8578
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8581
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8579
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNative6.java");
8582
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis1.java");
8580
8583
8581
		String str = cu.getSource();
8584
		String str = cu.getSource();
8582
		String completeBehind = "nat";
8585
		String completeBehind = "thi";
8583
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8586
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8584
		cu.codeComplete(cursorLocation, requestor);
8587
		cu.codeComplete(cursorLocation, requestor);
8585
8588
8586
		assertEquals(
8589
		assertEquals(
8587
			"",
8590
			"element:this    completion:this    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8588
			requestor.getResults());
8591
			requestor.getResults());
8589
}
8592
}
8590
public void testCompletionKeywordNative7() throws JavaModelException {
8593
public void testCompletionKeywordThis10() throws JavaModelException {
8591
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8594
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8592
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNative7.java");
8595
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis10.java");
8593
8596
8594
		String str = cu.getSource();
8597
		String str = cu.getSource();
8595
		String completeBehind = "nat";
8598
		String completeBehind = "thi";
8596
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8599
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8597
		cu.codeComplete(cursorLocation, requestor);
8600
		cu.codeComplete(cursorLocation, requestor);
8598
8601
8599
		assertEquals(
8602
		assertEquals(
8600
			"element:native    completion:native    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8603
			"",
8601
			requestor.getResults());
8604
			requestor.getResults());
8602
}
8605
}
8603
public void testCompletionKeywordNative8() throws JavaModelException {
8606
public void testCompletionKeywordThis11() throws JavaModelException {
8604
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8607
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8605
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNative8.java");
8608
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis11.java");
8606
8609
8607
		String str = cu.getSource();
8610
		String str = cu.getSource();
8608
		String completeBehind = "nat";
8611
		String completeBehind = "thi";
8609
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8612
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8610
		cu.codeComplete(cursorLocation, requestor);
8613
		cu.codeComplete(cursorLocation, requestor);
8611
8614
8612
		assertEquals(
8615
		assertEquals(
8613
			"",
8616
			"element:this    completion:this    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8614
			requestor.getResults());
8617
			requestor.getResults());
8615
}
8618
}
8616
public void testCompletionKeywordStrictfp5() throws JavaModelException {
8619
public void testCompletionKeywordThis12() throws JavaModelException {
8617
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8620
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8618
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStrictfp5.java");
8621
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis12.java");
8619
8622
8620
		String str = cu.getSource();
8623
		String str = cu.getSource();
8621
		String completeBehind = "stric";
8624
		String completeBehind = "thi";
8622
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8625
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8623
		cu.codeComplete(cursorLocation, requestor);
8626
		cu.codeComplete(cursorLocation, requestor);
8624
8627
8625
		assertEquals(
8628
		assertEquals(
8626
			"element:strictfp    completion:strictfp    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8629
			"",
8627
			requestor.getResults());
8630
			requestor.getResults());
8628
}
8631
}
8629
public void testCompletionKeywordStrictfp6() throws JavaModelException {
8632
public void testCompletionKeywordThis13() throws JavaModelException {
8630
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8633
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8631
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStrictfp6.java");
8634
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis13.java");
8632
8635
8633
		String str = cu.getSource();
8636
		String str = cu.getSource();
8634
		String completeBehind = "stric";
8637
		String completeBehind = "thi";
8635
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8638
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8636
		cu.codeComplete(cursorLocation, requestor);
8639
		cu.codeComplete(cursorLocation, requestor);
8637
8640
8638
		assertEquals(
8641
		assertEquals(
8639
			"",
8642
			"element:this    completion:this    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED),
8640
			requestor.getResults());
8643
			requestor.getResults());
8641
}
8644
}
8642
public void testCompletionKeywordStrictfp7() throws JavaModelException {
8645
public void testCompletionKeywordThis14() throws JavaModelException {
8643
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8646
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8644
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStrictfp7.java");
8647
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis14.java");
8645
8648
8646
		String str = cu.getSource();
8649
		String str = cu.getSource();
8647
		String completeBehind = "stric";
8650
		String completeBehind = "thi";
8648
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8651
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8649
		cu.codeComplete(cursorLocation, requestor);
8652
		cu.codeComplete(cursorLocation, requestor);
8650
8653
8651
		assertEquals(
8654
		assertEquals(
8652
			"element:strictfp    completion:strictfp    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8655
			"",
8653
			requestor.getResults());
8656
			requestor.getResults());
8654
}
8657
}
8655
public void testCompletionKeywordStrictfp8() throws JavaModelException {
8658
/*
8656
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8659
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=42402
8657
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStrictfp8.java");
8660
 */
8658
8661
public void testCompletionKeywordThis15() throws JavaModelException {
8659
		String str = cu.getSource();
8662
	this.wc = getWorkingCopy(
8660
		String completeBehind = "stric";
8663
            "/Completion/src2/CompletionKeywordThis15.java",
8661
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8664
            "public class CompletionKeywordThis15 {\n" +
8662
		cu.codeComplete(cursorLocation, requestor);
8665
            "	public class InnerClass {\n" +
8666
            "		public InnerClass() {\n" +
8667
            "			CompletionKeywordThis15 a = CompletionKeywordThis15.this;\n" +
8668
            "		}\n" +
8669
            "	}\n" +
8670
            "}");
8671
    
8672
    
8673
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
8674
    String str = this.wc.getSource();
8675
    String completeBehind = "CompletionKeywordThis15.";
8676
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8677
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
8663
8678
8664
		assertEquals(
8679
	assertResults(
8665
			"",
8680
			"CompletionKeywordThis15.InnerClass[TYPE_REF]{InnerClass, , LCompletionKeywordThis15$InnerClass;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n" +
8666
			requestor.getResults());
8681
			"class[FIELD_REF]{class, null, Ljava.lang.Class;, class, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n"+
8682
			"this[KEYWORD]{this, null, null, this, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}",
8683
		requestor.getResults());
8667
}
8684
}
8668
public void testCompletionKeywordVolatile5() throws JavaModelException {
8685
public void testCompletionKeywordThis2() throws JavaModelException {
8669
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8686
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8670
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordVolatile5.java");
8687
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis2.java");
8671
8688
8672
		String str = cu.getSource();
8689
		String str = cu.getSource();
8673
		String completeBehind = "vol";
8690
		String completeBehind = "thi";
8674
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8691
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8675
		cu.codeComplete(cursorLocation, requestor);
8692
		cu.codeComplete(cursorLocation, requestor);
8676
8693
8677
		assertEquals(
8694
		assertEquals(
8678
			"element:volatile    completion:volatile    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8695
			"element:this    completion:this    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8679
			requestor.getResults());
8696
			requestor.getResults());
8680
}
8697
}
8681
public void testCompletionKeywordVolatile6() throws JavaModelException {
8698
public void testCompletionKeywordThis3() throws JavaModelException {
8682
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8699
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8683
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordVolatile6.java");
8700
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis3.java");
8684
8701
8685
		String str = cu.getSource();
8702
		String str = cu.getSource();
8686
		String completeBehind = "vol";
8703
		String completeBehind = "thi";
8687
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8704
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8688
		cu.codeComplete(cursorLocation, requestor);
8705
		cu.codeComplete(cursorLocation, requestor);
8689
8706
Lines 8691-8715 Link Here
8691
			"",
8708
			"",
8692
			requestor.getResults());
8709
			requestor.getResults());
8693
}
8710
}
8694
public void testCompletionKeywordVolatile7() throws JavaModelException {
8711
public void testCompletionKeywordThis4() throws JavaModelException {
8695
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8712
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8696
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordVolatile7.java");
8713
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis4.java");
8697
8714
8698
		String str = cu.getSource();
8715
		String str = cu.getSource();
8699
		String completeBehind = "vol";
8716
		String completeBehind = "thi";
8700
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8717
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8701
		cu.codeComplete(cursorLocation, requestor);
8718
		cu.codeComplete(cursorLocation, requestor);
8702
8719
8703
		assertEquals(
8720
		assertEquals(
8704
			"element:volatile    completion:volatile    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8721
			"element:this    completion:this    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8705
			requestor.getResults());
8722
			requestor.getResults());
8706
}
8723
}
8707
public void testCompletionKeywordVolatile8() throws JavaModelException {
8724
public void testCompletionKeywordThis5() throws JavaModelException {
8708
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8725
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8709
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordVolatile8.java");
8726
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis5.java");
8710
8727
8711
		String str = cu.getSource();
8728
		String str = cu.getSource();
8712
		String completeBehind = "vol";
8729
		String completeBehind = "thi";
8713
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8730
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8714
		cu.codeComplete(cursorLocation, requestor);
8731
		cu.codeComplete(cursorLocation, requestor);
8715
8732
Lines 8717-8741 Link Here
8717
			"",
8734
			"",
8718
			requestor.getResults());
8735
			requestor.getResults());
8719
}
8736
}
8720
public void testCompletionKeywordTransient5() throws JavaModelException {
8737
public void testCompletionKeywordThis6() throws JavaModelException {
8721
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8738
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8722
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTransient5.java");
8739
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis6.java");
8723
8740
8724
		String str = cu.getSource();
8741
		String str = cu.getSource();
8725
		String completeBehind = "tran";
8742
		String completeBehind = "thi";
8726
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8743
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8727
		cu.codeComplete(cursorLocation, requestor);
8744
		cu.codeComplete(cursorLocation, requestor);
8728
8745
8729
		assertEquals(
8746
		assertEquals(
8730
			"element:transient    completion:transient    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8747
			"element:this    completion:this    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED),
8731
			requestor.getResults());
8748
			requestor.getResults());
8732
}
8749
}
8733
public void testCompletionKeywordTransient6() throws JavaModelException {
8750
public void testCompletionKeywordThis7() throws JavaModelException {
8734
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8751
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8735
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTransient6.java");
8752
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis7.java");
8736
8753
8737
		String str = cu.getSource();
8754
		String str = cu.getSource();
8738
		String completeBehind = "tran";
8755
		String completeBehind = "thi";
8739
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8756
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8740
		cu.codeComplete(cursorLocation, requestor);
8757
		cu.codeComplete(cursorLocation, requestor);
8741
8758
Lines 8743-8923 Link Here
8743
			"",
8760
			"",
8744
			requestor.getResults());
8761
			requestor.getResults());
8745
}
8762
}
8746
public void testCompletionKeywordTransient7() throws JavaModelException {
8763
public void testCompletionKeywordThis8() throws JavaModelException {
8747
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8764
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8748
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTransient7.java");
8765
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis8.java");
8749
8766
8750
		String str = cu.getSource();
8767
		String str = cu.getSource();
8751
		String completeBehind = "tran";
8768
		String completeBehind = "thi";
8752
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8769
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8753
		cu.codeComplete(cursorLocation, requestor);
8770
		cu.codeComplete(cursorLocation, requestor);
8754
8771
8755
		assertEquals(
8772
		assertEquals(
8756
			"element:transient    completion:transient    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8773
			"element:this    completion:this    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8757
			requestor.getResults());
8774
			requestor.getResults());
8758
}
8775
}
8759
public void testCompletionKeywordTransient8() throws JavaModelException {
8776
public void testCompletionKeywordThis9() throws JavaModelException {
8760
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8777
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8761
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTransient8.java");
8778
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThis9.java");
8762
8779
8763
		String str = cu.getSource();
8780
		String str = cu.getSource();
8764
		String completeBehind = "tran";
8781
		String completeBehind = "thi";
8765
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8782
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8766
		cu.codeComplete(cursorLocation, requestor);
8783
		cu.codeComplete(cursorLocation, requestor);
8767
8784
8768
		assertEquals(
8785
		assertEquals(
8769
			"",
8786
			"element:this    completion:this    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8770
			requestor.getResults());
8787
			requestor.getResults());
8771
}
8788
}
8772
public void testCompletionKeywordNew9() throws JavaModelException {
8789
public void testCompletionKeywordThrow1() throws JavaModelException {
8773
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8790
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8774
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew9.java");
8791
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrow1.java");
8775
8792
8776
		String str = cu.getSource();
8793
		String str = cu.getSource();
8777
		String completeBehind = "ne";
8794
		String completeBehind = "thr";
8778
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8795
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8779
		cu.codeComplete(cursorLocation, requestor);
8796
		cu.codeComplete(cursorLocation, requestor);
8780
8797
8781
		assertEquals(
8798
		assertEquals(
8782
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8799
			"element:Throwable    completion:Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8800
			"element:throw    completion:throw    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8783
			requestor.getResults());
8801
			requestor.getResults());
8784
}
8802
}
8785
public void testCompletionKeywordNew10() throws JavaModelException {
8803
public void testCompletionKeywordThrow2() throws JavaModelException {
8786
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8804
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8787
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew10.java");
8805
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrow2.java");
8788
8806
8789
		String str = cu.getSource();
8807
		String str = cu.getSource();
8790
		String completeBehind = "ne";
8808
		String completeBehind = "thr";
8791
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8809
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8792
		cu.codeComplete(cursorLocation, requestor);
8810
		cu.codeComplete(cursorLocation, requestor);
8793
8811
8794
		assertEquals(
8812
		assertEquals(
8795
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8813
			"element:Throwable    completion:Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
8796
			requestor.getResults());
8814
			requestor.getResults());
8797
}
8815
}
8798
public void testCompletionKeywordNew11() throws JavaModelException {
8816
public void testCompletionKeywordThrow3() throws JavaModelException {
8799
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8817
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8800
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew11.java");
8818
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrow3.java");
8801
8819
8802
		String str = cu.getSource();
8820
		String str = cu.getSource();
8803
		String completeBehind = "ne";
8821
		String completeBehind = "thr";
8804
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8822
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8805
		cu.codeComplete(cursorLocation, requestor);
8823
		cu.codeComplete(cursorLocation, requestor);
8806
8824
8807
		assertEquals(
8825
		assertEquals(
8808
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8826
			"element:Throwable    completion:Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
8809
			requestor.getResults());
8827
			requestor.getResults());
8810
}
8828
}
8811
public void testCompletionKeywordNew12() throws JavaModelException {
8829
public void testCompletionKeywordThrow4() throws JavaModelException {
8812
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8830
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8813
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew12.java");
8831
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrow4.java");
8814
8832
8815
		String str = cu.getSource();
8833
		String str = cu.getSource();
8816
		String completeBehind = "ne";
8834
		String completeBehind = "thr";
8817
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8835
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8818
		cu.codeComplete(cursorLocation, requestor);
8836
		cu.codeComplete(cursorLocation, requestor);
8819
8837
8820
		assertEquals(
8838
		assertEquals(
8821
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8839
			"element:Throwable    completion:Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
8840
			"element:throw    completion:throw    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8822
			requestor.getResults());
8841
			requestor.getResults());
8823
}
8842
}
8824
public void testCompletionKeywordNew13() throws JavaModelException {
8843
public void testCompletionKeywordThrow5() throws JavaModelException {
8825
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8844
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8826
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew13.java");
8845
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrow5.java");
8827
8846
8828
		String str = cu.getSource();
8847
		String str = cu.getSource();
8829
		String completeBehind = "ne";
8848
		String completeBehind = "thr";
8830
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8849
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8831
		cu.codeComplete(cursorLocation, requestor);
8850
		cu.codeComplete(cursorLocation, requestor);
8832
8851
8833
		assertEquals(
8852
		assertEquals(
8834
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8853
			"element:Throwable    completion:Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
8835
			requestor.getResults());
8854
			requestor.getResults());
8836
}
8855
}
8837
public void testCompletionKeywordNew14() throws JavaModelException {
8856
public void testCompletionKeywordThrow6() throws JavaModelException {
8838
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8857
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8839
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew14.java");
8858
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrow6.java");
8840
8859
8841
		String str = cu.getSource();
8860
		String str = cu.getSource();
8842
		String completeBehind = "ne";
8861
		String completeBehind = "thr";
8843
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8862
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8844
		cu.codeComplete(cursorLocation, requestor);
8863
		cu.codeComplete(cursorLocation, requestor);
8845
8864
8846
		assertEquals(
8865
		assertEquals(
8847
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8866
			"element:Throwable    completion:Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
8848
			requestor.getResults());
8867
			requestor.getResults());
8849
}
8868
}
8850
public void testCompletionKeywordNew15() throws JavaModelException {
8869
public void testCompletionKeywordThrows1() throws JavaModelException {
8851
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8870
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8852
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew15.java");
8871
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrows1.java");
8853
8872
8854
		String str = cu.getSource();
8873
		String str = cu.getSource();
8855
		String completeBehind = "ne";
8874
		String completeBehind = "thro";
8856
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8875
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8857
		cu.codeComplete(cursorLocation, requestor);
8876
		cu.codeComplete(cursorLocation, requestor);
8858
8877
8859
		assertEquals(
8878
		assertEquals(
8860
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8879
			"element:throws    completion:throws    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8861
			requestor.getResults());
8880
			requestor.getResults());
8862
}
8881
}
8863
public void testCompletionKeywordNew16() throws JavaModelException {
8882
public void testCompletionKeywordThrows2() throws JavaModelException {
8864
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8883
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8865
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNew16.java");
8884
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrows2.java");
8866
8885
8867
		String str = cu.getSource();
8886
		String str = cu.getSource();
8868
		String completeBehind = "ne";
8887
		String completeBehind = "thro";
8869
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8888
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8870
		cu.codeComplete(cursorLocation, requestor);
8889
		cu.codeComplete(cursorLocation, requestor);
8871
8890
8872
		assertEquals(
8891
		assertEquals(
8873
			"element:new    completion:new    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8892
			"",
8874
			requestor.getResults());
8893
			requestor.getResults());
8875
}
8894
}
8876
public void testCompletionKeywordStatic6() throws JavaModelException {
8895
public void testCompletionKeywordThrows3() throws JavaModelException {
8877
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8896
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8878
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic6.java");
8897
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrows3.java");
8879
8898
8880
		String str = cu.getSource();
8899
		String str = cu.getSource();
8881
		String completeBehind = "sta";
8900
		String completeBehind = "thro";
8882
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8901
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8883
		cu.codeComplete(cursorLocation, requestor);
8902
		cu.codeComplete(cursorLocation, requestor);
8884
8903
8885
		assertEquals(
8904
		assertEquals(
8886
			"element:static    completion:static    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8905
			"element:throws    completion:throws    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8887
			requestor.getResults());
8906
			requestor.getResults());
8888
}
8907
}
8889
public void testCompletionKeywordStatic7() throws JavaModelException {
8908
public void testCompletionKeywordThrows4() throws JavaModelException {
8890
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8909
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8891
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic7.java");
8910
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrows4.java");
8892
8911
8893
		String str = cu.getSource();
8912
		String str = cu.getSource();
8894
		String completeBehind = "sta";
8913
		String completeBehind = "thro";
8895
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8914
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8896
		cu.codeComplete(cursorLocation, requestor);
8915
		cu.codeComplete(cursorLocation, requestor);
8897
8916
8898
		assertEquals(
8917
		assertEquals(
8899
			"element:static    completion:static    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8918
			"element:throws    completion:throws    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8900
			requestor.getResults());
8919
			requestor.getResults());
8901
}
8920
}
8902
public void testCompletionKeywordStatic8() throws JavaModelException {
8921
public void testCompletionKeywordThrows5() throws JavaModelException {
8903
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8922
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8904
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic8.java");
8923
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrows5.java");
8905
8924
8906
		String str = cu.getSource();
8925
		String str = cu.getSource();
8907
		String completeBehind = "sta";
8926
		String completeBehind = "thro";
8908
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8927
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8909
		cu.codeComplete(cursorLocation, requestor);
8928
		cu.codeComplete(cursorLocation, requestor);
8910
8929
8911
		assertEquals(
8930
		assertEquals(
8912
			"element:static    completion:static    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8931
			"element:throws    completion:throws    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8913
			requestor.getResults());
8932
			requestor.getResults());
8914
}
8933
}
8915
public void testCompletionKeywordStatic9() throws JavaModelException {
8934
public void testCompletionKeywordThrows6() throws JavaModelException {
8916
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8935
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8917
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic9.java");
8936
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrows6.java");
8918
8937
8919
		String str = cu.getSource();
8938
		String str = cu.getSource();
8920
		String completeBehind = "sta";
8939
		String completeBehind = "thro";
8921
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8940
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8922
		cu.codeComplete(cursorLocation, requestor);
8941
		cu.codeComplete(cursorLocation, requestor);
8923
8942
Lines 8925-8975 Link Here
8925
			"",
8944
			"",
8926
			requestor.getResults());
8945
			requestor.getResults());
8927
}
8946
}
8928
public void testCompletionKeywordStatic10() throws JavaModelException {
8947
public void testCompletionKeywordThrows7() throws JavaModelException {
8929
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8948
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8930
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordStatic10.java");
8949
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrows7.java");
8931
8950
8932
		String str = cu.getSource();
8951
		String str = cu.getSource();
8933
		String completeBehind = "sta";
8952
		String completeBehind = "thro";
8934
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8953
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8935
		cu.codeComplete(cursorLocation, requestor);
8954
		cu.codeComplete(cursorLocation, requestor);
8936
8955
8937
		assertEquals(
8956
		assertEquals(
8938
			"element:static    completion:static    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8957
			"element:throws    completion:throws    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8939
			requestor.getResults());
8958
			requestor.getResults());
8940
}
8959
}
8941
public void testCompletionKeywordPublic20() throws JavaModelException {
8960
public void testCompletionKeywordThrows8() throws JavaModelException {
8942
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8961
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8943
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic10.java");
8962
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordThrows8.java");
8944
8963
8945
		String str = cu.getSource();
8964
		String str = cu.getSource();
8946
		String completeBehind = "pub";
8965
		String completeBehind = "thro";
8947
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8966
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8948
		cu.codeComplete(cursorLocation, requestor);
8967
		cu.codeComplete(cursorLocation, requestor);
8949
8968
8950
		assertEquals(
8969
		assertEquals(
8951
			"",
8970
			"element:throws    completion:throws    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8952
			requestor.getResults());
8971
			requestor.getResults());
8953
}
8972
}
8954
public void testCompletionKeywordPublic11() throws JavaModelException {
8973
public void testCompletionKeywordTransient1() throws JavaModelException {
8955
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8974
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8956
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic11.java");
8975
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTransient1.java");
8957
8976
8958
		String str = cu.getSource();
8977
		String str = cu.getSource();
8959
		String completeBehind = "pub";
8978
		String completeBehind = "tran";
8960
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8979
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8961
		cu.codeComplete(cursorLocation, requestor);
8980
		cu.codeComplete(cursorLocation, requestor);
8962
8981
8963
		assertEquals(
8982
		assertEquals(
8964
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8983
			"element:transient    completion:transient    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8965
			requestor.getResults());
8984
			requestor.getResults());
8966
}
8985
}
8967
public void testCompletionKeywordPublic12() throws JavaModelException {
8986
public void testCompletionKeywordTransient2() throws JavaModelException {
8968
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8987
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8969
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic12.java");
8988
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTransient2.java");
8970
8989
8971
		String str = cu.getSource();
8990
		String str = cu.getSource();
8972
		String completeBehind = "pub";
8991
		String completeBehind = "tran";
8973
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8992
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8974
		cu.codeComplete(cursorLocation, requestor);
8993
		cu.codeComplete(cursorLocation, requestor);
8975
8994
Lines 8977-9027 Link Here
8977
			"",
8996
			"",
8978
			requestor.getResults());
8997
			requestor.getResults());
8979
}
8998
}
8980
public void testCompletionKeywordPublic13() throws JavaModelException {
8999
public void testCompletionKeywordTransient3() throws JavaModelException {
8981
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9000
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8982
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic13.java");
9001
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTransient3.java");
8983
9002
8984
		String str = cu.getSource();
9003
		String str = cu.getSource();
8985
		String completeBehind = "pub";
9004
		String completeBehind = "tran";
8986
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9005
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
8987
		cu.codeComplete(cursorLocation, requestor);
9006
		cu.codeComplete(cursorLocation, requestor);
8988
9007
8989
		assertEquals(
9008
		assertEquals(
8990
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9009
			"element:transient    completion:transient    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
8991
			requestor.getResults());
9010
			requestor.getResults());
8992
}
9011
}
8993
public void testCompletionKeywordPublic14() throws JavaModelException {
9012
public void testCompletionKeywordTransient4() throws JavaModelException {
8994
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9013
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
8995
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic14.java");
9014
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTransient4.java");
8996
9015
8997
		String str = cu.getSource();
9016
		String str = cu.getSource();
8998
		String completeBehind = "pub";
9017
		String completeBehind = "tran";
8999
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9018
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9000
		cu.codeComplete(cursorLocation, requestor);
9019
		cu.codeComplete(cursorLocation, requestor);
9001
9020
9002
		assertEquals(
9021
		assertEquals(
9003
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9022
			"",
9004
			requestor.getResults());
9023
			requestor.getResults());
9005
}
9024
}
9006
public void testCompletionKeywordPublic15() throws JavaModelException {
9025
public void testCompletionKeywordTransient5() throws JavaModelException {
9007
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9026
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9008
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic15.java");
9027
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTransient5.java");
9009
9028
9010
		String str = cu.getSource();
9029
		String str = cu.getSource();
9011
		String completeBehind = "pub";
9030
		String completeBehind = "tran";
9012
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9031
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9013
		cu.codeComplete(cursorLocation, requestor);
9032
		cu.codeComplete(cursorLocation, requestor);
9014
9033
9015
		assertEquals(
9034
		assertEquals(
9016
			"",
9035
			"element:transient    completion:transient    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9017
			requestor.getResults());
9036
			requestor.getResults());
9018
}
9037
}
9019
public void testCompletionKeywordPublic16() throws JavaModelException {
9038
public void testCompletionKeywordTransient6() throws JavaModelException {
9020
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9039
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9021
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic16.java");
9040
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTransient6.java");
9022
9041
9023
		String str = cu.getSource();
9042
		String str = cu.getSource();
9024
		String completeBehind = "pub";
9043
		String completeBehind = "tran";
9025
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9044
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9026
		cu.codeComplete(cursorLocation, requestor);
9045
		cu.codeComplete(cursorLocation, requestor);
9027
9046
Lines 9029-9183 Link Here
9029
			"",
9048
			"",
9030
			requestor.getResults());
9049
			requestor.getResults());
9031
}
9050
}
9032
public void testCompletionKeywordPublic17() throws JavaModelException {
9051
public void testCompletionKeywordTransient7() throws JavaModelException {
9033
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9052
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9034
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic17.java");
9053
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTransient7.java");
9035
9054
9036
		String str = cu.getSource();
9055
		String str = cu.getSource();
9037
		String completeBehind = "pub";
9056
		String completeBehind = "tran";
9038
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9057
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9039
		cu.codeComplete(cursorLocation, requestor);
9058
		cu.codeComplete(cursorLocation, requestor);
9040
9059
9041
		assertEquals(
9060
		assertEquals(
9042
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9061
			"element:transient    completion:transient    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9043
			requestor.getResults());
9062
			requestor.getResults());
9044
}
9063
}
9045
public void testCompletionKeywordPublic18() throws JavaModelException {
9064
public void testCompletionKeywordTransient8() throws JavaModelException {
9046
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9065
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9047
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic18.java");
9066
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTransient8.java");
9048
9067
9049
		String str = cu.getSource();
9068
		String str = cu.getSource();
9050
		String completeBehind = "pub";
9069
		String completeBehind = "tran";
9051
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9070
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9052
		cu.codeComplete(cursorLocation, requestor);
9071
		cu.codeComplete(cursorLocation, requestor);
9053
9072
9054
		assertEquals(
9073
		assertEquals(
9055
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9074
			"",
9056
			requestor.getResults());
9075
			requestor.getResults());
9057
}
9076
}
9058
public void testCompletionKeywordPublic19() throws JavaModelException {
9077
public void testCompletionKeywordTrue1() throws JavaModelException {
9059
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9078
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9060
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPublic19.java");
9079
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTrue1.java");
9061
9080
9062
		String str = cu.getSource();
9081
		String str = cu.getSource();
9063
		String completeBehind = "pub";
9082
		String completeBehind = "tru";
9064
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9083
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9065
		cu.codeComplete(cursorLocation, requestor);
9084
		cu.codeComplete(cursorLocation, requestor);
9066
9085
9067
		assertEquals(
9086
		assertEquals(
9068
			"element:public    completion:public    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9087
			"",
9069
			requestor.getResults());
9088
			requestor.getResults());
9070
}
9089
}
9071
public void testCompletionKeywordPrivate6() throws JavaModelException {
9090
public void testCompletionKeywordTrue2() throws JavaModelException {
9072
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9091
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9073
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate6.java");
9092
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTrue2.java");
9074
9093
9075
		String str = cu.getSource();
9094
		String str = cu.getSource();
9076
		String completeBehind = "pri";
9095
		String completeBehind = "tru";
9077
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9096
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9078
		cu.codeComplete(cursorLocation, requestor);
9097
		cu.codeComplete(cursorLocation, requestor);
9079
9098
9080
		assertEquals(
9099
		assertEquals(
9081
			"element:private    completion:private    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9100
			"element:true    completion:true    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
9082
			requestor.getResults());
9101
			requestor.getResults());
9083
}
9102
}
9084
public void testCompletionKeywordPrivate7() throws JavaModelException {
9103
public void testCompletionKeywordTrue3() throws JavaModelException {
9085
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9104
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9086
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate7.java");
9105
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTrue3.java");
9087
9106
9088
		String str = cu.getSource();
9107
		String str = cu.getSource();
9089
		String completeBehind = "pri";
9108
		String completeBehind = "tru";
9090
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9109
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9091
		cu.codeComplete(cursorLocation, requestor);
9110
		cu.codeComplete(cursorLocation, requestor);
9092
9111
9093
		assertEquals(
9112
		assertEquals(
9094
			"element:private    completion:private    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9113
			"",
9095
			requestor.getResults());
9114
			requestor.getResults());
9096
}
9115
}
9097
public void testCompletionKeywordPrivate8() throws JavaModelException {
9116
public void testCompletionKeywordTrue4() throws JavaModelException {
9098
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9117
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9099
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate8.java");
9118
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTrue4.java");
9100
9119
9101
		String str = cu.getSource();
9120
		String str = cu.getSource();
9102
		String completeBehind = "pri";
9121
		String completeBehind = "tru";
9103
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9122
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9104
		cu.codeComplete(cursorLocation, requestor);
9123
		cu.codeComplete(cursorLocation, requestor);
9105
9124
9106
		assertEquals(
9125
		assertEquals(
9107
			"element:private    completion:private    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9126
			"element:true    completion:true    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
9108
			requestor.getResults());
9127
			requestor.getResults());
9109
}
9128
}
9110
public void testCompletionKeywordPrivate9() throws JavaModelException {
9129
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=90615
9130
public void testCompletionKeywordTrue5() throws JavaModelException {
9131
	this.wc = getWorkingCopy(
9132
			"/Completion/src/test/CompletionKeywordTrue5.java",
9133
			"package test;\n" +
9134
			"public class CompletionKeywordTrue5 {\n" +
9135
			"  public void foo() {\n" +
9136
			"    boolean var;\n" +
9137
			"    var = tr\n" +
9138
			"  }\n" +
9139
			"}");
9140
	
9141
	
9142
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9143
	String str = this.wc.getSource();
9144
	String completeBehind = "tr";
9145
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9146
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9147
9148
	assertResults(
9149
			"true[KEYWORD]{true, null, null, true, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
9150
			requestor.getResults());
9151
}
9152
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=90615
9153
public void testCompletionKeywordTrue6() throws JavaModelException {
9154
	this.wc = getWorkingCopy(
9155
			"/Completion/src/test/CompletionKeywordTrue6.java",
9156
			"package test;\n" +
9157
			"public class CompletionKeywordTrue6 {\n" +
9158
			"  public void foo() {\n" +
9159
			"    boolean var;\n" +
9160
			"    var = \n" +
9161
			"  }\n" +
9162
			"}");
9163
	
9164
	
9165
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9166
	String str = this.wc.getSource();
9167
	String completeBehind = "var = ";
9168
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9169
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9170
9171
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
9172
		assertResults(
9173
				"clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9174
				"finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9175
				"foo[METHOD_REF]{foo(), Ltest.CompletionKeywordTrue6;, ()V, foo, null, " +(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9176
				"getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9177
				"hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9178
				"notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9179
				"notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9180
				"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9181
				"wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9182
				"wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9183
				"wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9184
				"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n"+
9185
				"var[LOCAL_VARIABLE_REF]{var, null, Z, var, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n"+
9186
				"false[KEYWORD]{false, null, null, false, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_TRUE_OR_FALSE + R_NON_RESTRICTED)+"}\n"+
9187
				"true[KEYWORD]{true, null, null, true, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_TRUE_OR_FALSE + R_NON_RESTRICTED) + "}",
9188
				requestor.getResults());
9189
	} else {
9190
		assertResults(
9191
				"CompletionKeywordTrue6[TYPE_REF]{CompletionKeywordTrue6, test, Ltest.CompletionKeywordTrue6;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9192
				"clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9193
				"finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9194
				"foo[METHOD_REF]{foo(), Ltest.CompletionKeywordTrue6;, ()V, foo, null, " +(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9195
				"getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9196
				"hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9197
				"notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9198
				"notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9199
				"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9200
				"wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9201
				"wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9202
				"wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9203
				"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n"+
9204
				"var[LOCAL_VARIABLE_REF]{var, null, Z, var, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n"+
9205
				"false[KEYWORD]{false, null, null, false, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_TRUE_OR_FALSE + R_NON_RESTRICTED)+"}\n"+
9206
				"true[KEYWORD]{true, null, null, true, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_TRUE_OR_FALSE + R_NON_RESTRICTED) + "}",
9207
				requestor.getResults());
9208
	}
9209
}
9210
public void testCompletionKeywordTry1() throws JavaModelException {
9111
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9211
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9112
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate9.java");
9212
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTry1.java");
9113
9213
9114
		String str = cu.getSource();
9214
		String str = cu.getSource();
9115
		String completeBehind = "pri";
9215
		String completeBehind = "tr";
9116
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9216
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9117
		cu.codeComplete(cursorLocation, requestor);
9217
		cu.codeComplete(cursorLocation, requestor);
9118
9218
9119
		assertEquals(
9219
		assertEquals(
9120
			"",
9220
			"element:try    completion:try    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9121
			requestor.getResults());
9221
			requestor.getResults());
9122
}
9222
}
9123
public void testCompletionKeywordPrivate10() throws JavaModelException {
9223
public void testCompletionKeywordTry2() throws JavaModelException {
9124
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9224
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9125
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordPrivate10.java");
9225
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTry2.java");
9126
9226
9127
		String str = cu.getSource();
9227
		String str = cu.getSource();
9128
		String completeBehind = "pri";
9228
		String completeBehind = "tr";
9129
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9229
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9130
		cu.codeComplete(cursorLocation, requestor);
9230
		cu.codeComplete(cursorLocation, requestor);
9131
9231
9132
		assertEquals(
9232
		assertEquals(
9133
			"",
9233
			"element:true    completion:true    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
9134
			requestor.getResults());
9234
			requestor.getResults());
9135
}
9235
}
9136
public void testCompletionKeywordProtected6() throws JavaModelException {
9236
public void testCompletionKeywordTry3() throws JavaModelException {
9137
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9237
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9138
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected6.java");
9238
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTry3.java");
9139
9239
9140
		String str = cu.getSource();
9240
		String str = cu.getSource();
9141
		String completeBehind = "pro";
9241
		String completeBehind = "try";
9142
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9242
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9143
		cu.codeComplete(cursorLocation, requestor);
9243
		cu.codeComplete(cursorLocation, requestor);
9144
9244
9145
		assertEquals(
9245
		assertEquals(
9146
			"element:protected    completion:protected    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9246
			"",
9147
			requestor.getResults());
9247
			requestor.getResults());
9148
}
9248
}
9149
public void testCompletionKeywordProtected7() throws JavaModelException {
9249
public void testCompletionKeywordTry4() throws JavaModelException {
9150
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9250
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9151
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected7.java");
9251
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTry4.java");
9152
9252
9153
		String str = cu.getSource();
9253
		String str = cu.getSource();
9154
		String completeBehind = "pro";
9254
		String completeBehind = "tr";
9155
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9255
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9156
		cu.codeComplete(cursorLocation, requestor);
9256
		cu.codeComplete(cursorLocation, requestor);
9157
9257
9158
		assertEquals(
9258
		assertEquals(
9159
			"element:protected    completion:protected    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9259
			"element:try    completion:try    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9160
			requestor.getResults());
9260
			requestor.getResults());
9161
}
9261
}
9162
public void testCompletionKeywordProtected8() throws JavaModelException {
9262
public void testCompletionKeywordTry5() throws JavaModelException {
9163
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9263
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9164
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected8.java");
9264
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTry5.java");
9165
9265
9166
		String str = cu.getSource();
9266
		String str = cu.getSource();
9167
		String completeBehind = "pro";
9267
		String completeBehind = "tr";
9168
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9268
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9169
		cu.codeComplete(cursorLocation, requestor);
9269
		cu.codeComplete(cursorLocation, requestor);
9170
9270
9171
		assertEquals(
9271
		assertEquals(
9172
			"element:protected    completion:protected    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9272
			"element:true    completion:true    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
9173
			requestor.getResults());
9273
			requestor.getResults());
9174
}
9274
}
9175
public void testCompletionKeywordProtected9() throws JavaModelException {
9275
public void testCompletionKeywordTry6() throws JavaModelException {
9176
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9276
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9177
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected9.java");
9277
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTry6.java");
9178
9278
9179
		String str = cu.getSource();
9279
		String str = cu.getSource();
9180
		String completeBehind = "pro";
9280
		String completeBehind = "try";
9181
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9281
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9182
		cu.codeComplete(cursorLocation, requestor);
9282
		cu.codeComplete(cursorLocation, requestor);
9183
9283
Lines 9185-9236 Link Here
9185
			"",
9285
			"",
9186
			requestor.getResults());
9286
			requestor.getResults());
9187
}
9287
}
9188
public void testCompletionKeywordProtected10() throws JavaModelException {
9288
public void testCompletionKeywordVolatile1() throws JavaModelException {
9189
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9289
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9190
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordProtected10.java");
9290
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordVolatile1.java");
9191
9291
9192
		String str = cu.getSource();
9292
		String str = cu.getSource();
9193
		String completeBehind = "pro";
9293
		String completeBehind = "vol";
9194
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9294
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9195
		cu.codeComplete(cursorLocation, requestor);
9295
		cu.codeComplete(cursorLocation, requestor);
9196
9296
9197
		assertEquals(
9297
		assertEquals(
9198
			"",
9298
			"element:volatile    completion:volatile    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9199
			requestor.getResults());
9299
			requestor.getResults());
9200
}
9300
}
9201
public void testCompletionKeywordFinal18() throws JavaModelException {
9301
public void testCompletionKeywordVolatile2() throws JavaModelException {
9202
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9302
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9203
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal18.java");
9303
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordVolatile2.java");
9204
9304
9205
		String str = cu.getSource();
9305
		String str = cu.getSource();
9206
		String completeBehind = "fin";
9306
		String completeBehind = "vol";
9207
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9307
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9208
		cu.codeComplete(cursorLocation, requestor);
9308
		cu.codeComplete(cursorLocation, requestor);
9209
9309
9210
		assertEquals(
9310
		assertEquals(
9211
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
9311
			"",
9212
			"element:finalize    completion:finalize()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
9213
			requestor.getResults());
9312
			requestor.getResults());
9214
}
9313
}
9215
public void testCompletionKeywordFinal10() throws JavaModelException {
9314
public void testCompletionKeywordVolatile3() throws JavaModelException {
9216
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9315
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9217
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal10.java");
9316
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordVolatile3.java");
9218
9317
9219
		String str = cu.getSource();
9318
		String str = cu.getSource();
9220
		String completeBehind = "fin";
9319
		String completeBehind = "vol";
9221
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9320
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9222
		cu.codeComplete(cursorLocation, requestor);
9321
		cu.codeComplete(cursorLocation, requestor);
9223
9322
9224
		assertEquals(
9323
		assertEquals(
9225
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9324
			"element:volatile    completion:volatile    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9226
			requestor.getResults());
9325
			requestor.getResults());
9227
}
9326
}
9228
public void testCompletionKeywordFinal11() throws JavaModelException {
9327
public void testCompletionKeywordVolatile4() throws JavaModelException {
9229
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9328
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9230
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal11.java");
9329
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordVolatile4.java");
9231
9330
9232
		String str = cu.getSource();
9331
		String str = cu.getSource();
9233
		String completeBehind = "fin";
9332
		String completeBehind = "vol";
9234
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9333
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9235
		cu.codeComplete(cursorLocation, requestor);
9334
		cu.codeComplete(cursorLocation, requestor);
9236
9335
Lines 9238-9289 Link Here
9238
			"",
9337
			"",
9239
			requestor.getResults());
9338
			requestor.getResults());
9240
}
9339
}
9241
public void testCompletionKeywordFinal12() throws JavaModelException {
9340
public void testCompletionKeywordVolatile5() throws JavaModelException {
9242
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9341
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9243
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal12.java");
9342
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordVolatile5.java");
9244
9343
9245
		String str = cu.getSource();
9344
		String str = cu.getSource();
9246
		String completeBehind = "fin";
9345
		String completeBehind = "vol";
9247
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9346
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9248
		cu.codeComplete(cursorLocation, requestor);
9347
		cu.codeComplete(cursorLocation, requestor);
9249
9348
9250
		assertEquals(
9349
		assertEquals(
9251
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9350
			"element:volatile    completion:volatile    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9252
			requestor.getResults());
9351
			requestor.getResults());
9253
}
9352
}
9254
public void testCompletionKeywordFinal13() throws JavaModelException {
9353
public void testCompletionKeywordVolatile6() throws JavaModelException {
9255
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9354
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9256
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal13.java");
9355
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordVolatile6.java");
9257
9356
9258
		String str = cu.getSource();
9357
		String str = cu.getSource();
9259
		String completeBehind = "fin";
9358
		String completeBehind = "vol";
9260
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9359
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9261
		cu.codeComplete(cursorLocation, requestor);
9360
		cu.codeComplete(cursorLocation, requestor);
9262
9361
9263
		assertEquals(
9362
		assertEquals(
9264
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9363
			"",
9265
			requestor.getResults());
9364
			requestor.getResults());
9266
}
9365
}
9267
public void testCompletionKeywordFinal14() throws JavaModelException {
9366
public void testCompletionKeywordVolatile7() throws JavaModelException {
9268
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9367
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9269
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal14.java");
9368
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordVolatile7.java");
9270
9369
9271
		String str = cu.getSource();
9370
		String str = cu.getSource();
9272
		String completeBehind = "fin";
9371
		String completeBehind = "vol";
9273
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9372
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9274
		cu.codeComplete(cursorLocation, requestor);
9373
		cu.codeComplete(cursorLocation, requestor);
9275
9374
9276
		assertEquals(
9375
		assertEquals(
9277
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
9376
			"element:volatile    completion:volatile    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9278
			"element:finalize    completion:protected void finalize() throws Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
9279
			requestor.getResults());
9377
			requestor.getResults());
9280
}
9378
}
9281
public void testCompletionKeywordFinal15() throws JavaModelException {
9379
public void testCompletionKeywordVolatile8() throws JavaModelException {
9282
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9380
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9283
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal15.java");
9381
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordVolatile8.java");
9284
9382
9285
		String str = cu.getSource();
9383
		String str = cu.getSource();
9286
		String completeBehind = "fin";
9384
		String completeBehind = "vol";
9287
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9385
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9288
		cu.codeComplete(cursorLocation, requestor);
9386
		cu.codeComplete(cursorLocation, requestor);
9289
9387
Lines 9291-9342 Link Here
9291
			"",
9389
			"",
9292
			requestor.getResults());
9390
			requestor.getResults());
9293
}
9391
}
9294
public void testCompletionKeywordFinal16() throws JavaModelException {
9392
public void testCompletionKeywordWhile1() throws JavaModelException {
9295
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9393
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9296
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal16.java");
9394
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile1.java");
9297
9395
9298
		String str = cu.getSource();
9396
		String str = cu.getSource();
9299
		String completeBehind = "fin";
9397
		String completeBehind = "wh";
9300
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9398
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9301
		cu.codeComplete(cursorLocation, requestor);
9399
		cu.codeComplete(cursorLocation, requestor);
9302
9400
9303
		assertEquals(
9401
		assertEquals(
9304
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
9402
			"element:while    completion:while    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9305
			"element:finalize    completion:protected void finalize() throws Throwable    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
9306
			requestor.getResults());
9403
			requestor.getResults());
9307
}
9404
}
9308
public void testCompletionKeywordFinal17() throws JavaModelException {
9405
public void testCompletionKeywordWhile10() throws JavaModelException {
9309
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9406
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9310
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFinal17.java");
9407
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile10.java");
9311
9408
9312
		String str = cu.getSource();
9409
		String str = cu.getSource();
9313
		String completeBehind = "fin";
9410
		String completeBehind = "wh";
9314
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9411
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9315
		cu.codeComplete(cursorLocation, requestor);
9412
		cu.codeComplete(cursorLocation, requestor);
9316
9413
9317
		assertEquals(
9414
		assertEquals(
9318
			"element:final    completion:final    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9415
			"element:while    completion:while    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9319
			requestor.getResults());
9416
			requestor.getResults());
9320
}
9417
}
9321
public void testCompletionKeywordAbstract9() throws JavaModelException {
9418
public void testCompletionKeywordWhile2() throws JavaModelException {
9322
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9419
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9323
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract9.java");
9420
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile2.java");
9324
9421
9325
		String str = cu.getSource();
9422
		String str = cu.getSource();
9326
		String completeBehind = "abs";
9423
		String completeBehind = "wh";
9327
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9424
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9328
		cu.codeComplete(cursorLocation, requestor);
9425
		cu.codeComplete(cursorLocation, requestor);
9329
9426
9330
		assertEquals(
9427
		assertEquals(
9331
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9428
			"",
9332
			requestor.getResults());
9429
			requestor.getResults());
9333
}
9430
}
9334
public void testCompletionKeywordAbstract10() throws JavaModelException {
9431
public void testCompletionKeywordWhile3() throws JavaModelException {
9335
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9432
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9336
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract10.java");
9433
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile3.java");
9337
9434
9338
		String str = cu.getSource();
9435
		String str = cu.getSource();
9339
		String completeBehind = "abs";
9436
		String completeBehind = "wh";
9340
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9437
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9341
		cu.codeComplete(cursorLocation, requestor);
9438
		cu.codeComplete(cursorLocation, requestor);
9342
9439
Lines 9344-9394 Link Here
9344
			"",
9441
			"",
9345
			requestor.getResults());
9442
			requestor.getResults());
9346
}
9443
}
9347
public void testCompletionKeywordAbstract11() throws JavaModelException {
9444
public void testCompletionKeywordWhile4() throws JavaModelException {
9348
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9445
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9349
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract11.java");
9446
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile4.java");
9350
9447
9351
		String str = cu.getSource();
9448
		String str = cu.getSource();
9352
		String completeBehind = "abs";
9449
		String completeBehind = "wh";
9353
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9450
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9354
		cu.codeComplete(cursorLocation, requestor);
9451
		cu.codeComplete(cursorLocation, requestor);
9355
9452
9356
		assertEquals(
9453
		assertEquals(
9357
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9454
			"element:while    completion:while    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9358
			requestor.getResults());
9455
			requestor.getResults());
9359
}
9456
}
9360
public void testCompletionKeywordAbstract12() throws JavaModelException {
9457
public void testCompletionKeywordWhile5() throws JavaModelException {
9361
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9458
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9362
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract12.java");
9459
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile5.java");
9363
9460
9364
		String str = cu.getSource();
9461
		String str = cu.getSource();
9365
		String completeBehind = "abs";
9462
		String completeBehind = "wh";
9366
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9463
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9367
		cu.codeComplete(cursorLocation, requestor);
9464
		cu.codeComplete(cursorLocation, requestor);
9368
9465
9369
		assertEquals(
9466
		assertEquals(
9370
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9467
			"element:while    completion:while    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9371
			requestor.getResults());
9468
			requestor.getResults());
9372
}
9469
}
9373
public void testCompletionKeywordAbstract13() throws JavaModelException {
9470
public void testCompletionKeywordWhile6() throws JavaModelException {
9374
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9471
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9375
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract13.java");
9472
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile6.java");
9376
9473
9377
		String str = cu.getSource();
9474
		String str = cu.getSource();
9378
		String completeBehind = "abs";
9475
		String completeBehind = "wh";
9379
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9476
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9380
		cu.codeComplete(cursorLocation, requestor);
9477
		cu.codeComplete(cursorLocation, requestor);
9381
9478
9382
		assertEquals(
9479
		assertEquals(
9383
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9480
			"element:while    completion:while    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9384
			requestor.getResults());
9481
			requestor.getResults());
9385
}
9482
}
9386
public void testCompletionKeywordAbstract14() throws JavaModelException {
9483
public void testCompletionKeywordWhile7() throws JavaModelException {
9387
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9484
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9388
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract14.java");
9485
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile7.java");
9389
9486
9390
		String str = cu.getSource();
9487
		String str = cu.getSource();
9391
		String completeBehind = "abs";
9488
		String completeBehind = "wh";
9392
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9489
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9393
		cu.codeComplete(cursorLocation, requestor);
9490
		cu.codeComplete(cursorLocation, requestor);
9394
9491
Lines 9396-9911 Link Here
9396
			"",
9493
			"",
9397
			requestor.getResults());
9494
			requestor.getResults());
9398
}
9495
}
9399
public void testCompletionKeywordAbstract15() throws JavaModelException {
9496
public void testCompletionKeywordWhile8() throws JavaModelException {
9400
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9401
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract15.java");
9402
9403
		String str = cu.getSource();
9404
		String completeBehind = "abs";
9405
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9406
		cu.codeComplete(cursorLocation, requestor);
9407
9408
		assertEquals(
9409
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9410
			requestor.getResults());
9411
}
9412
public void testCompletionKeywordAbstract16() throws JavaModelException {
9413
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9497
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9414
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordAbstract16.java");
9498
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile8.java");
9415
9499
9416
		String str = cu.getSource();
9500
		String str = cu.getSource();
9417
		String completeBehind = "abs";
9501
		String completeBehind = "wh";
9418
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9502
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9419
		cu.codeComplete(cursorLocation, requestor);
9503
		cu.codeComplete(cursorLocation, requestor);
9420
9504
9421
		assertEquals(
9505
		assertEquals(
9422
			"element:abstract    completion:abstract    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9506
			"",
9423
			requestor.getResults());
9507
			requestor.getResults());
9424
}
9508
}
9425
public void testCompletionKeywordTrue3() throws JavaModelException {
9509
public void testCompletionKeywordWhile9() throws JavaModelException {
9426
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9510
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9427
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTrue3.java");
9511
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordWhile9.java");
9428
9512
9429
		String str = cu.getSource();
9513
		String str = cu.getSource();
9430
		String completeBehind = "tru";
9514
		String completeBehind = "wh";
9431
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9515
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9432
		cu.codeComplete(cursorLocation, requestor);
9516
		cu.codeComplete(cursorLocation, requestor);
9433
9517
9434
		assertEquals(
9518
		assertEquals(
9435
			"",
9519
			"element:while    completion:while    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9436
			requestor.getResults());
9520
			requestor.getResults());
9437
}
9521
}
9438
public void testCompletionKeywordTrue4() throws JavaModelException {
9522
public void testCompletionLocalName() throws JavaModelException {
9439
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9523
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9440
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordTrue4.java");
9524
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionLocalName.java");
9441
9525
9442
		String str = cu.getSource();
9526
	String str = cu.getSource();
9443
		String completeBehind = "tru";
9527
	String completeBehind = "ClassWithComplexName ";
9444
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9528
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9445
		cu.codeComplete(cursorLocation, requestor);
9529
	cu.codeComplete(cursorLocation, requestor);
9446
9530
9447
		assertEquals(
9531
	assertEquals(
9448
			"element:true    completion:true    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
9532
		"should have two completions", 
9449
			requestor.getResults());
9533
		"element:classWithComplexName    completion:classWithComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
9534
		"element:complexName2    completion:complexName2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
9535
		"element:name    completion:name    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
9536
		"element:withComplexName    completion:withComplexName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9537
		requestor.getResults());
9450
}
9538
}
9451
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=90615
9539
public void testCompletionLocalType1() throws JavaModelException {
9452
public void testCompletionKeywordTrue5() throws JavaModelException {
9540
	this.workingCopies = new ICompilationUnit[1];
9453
	this.wc = getWorkingCopy(
9541
	this.workingCopies[0] = getWorkingCopy(
9454
			"/Completion/src/test/CompletionKeywordTrue5.java",
9542
		"/Completion/src/CompletionLocalType1.java",
9455
			"package test;\n" +
9543
		"public class CompletionLocalType1 {\n" +
9456
			"public class CompletionKeywordTrue5 {\n" +
9544
		"	void foo() {\n" +
9457
			"  public void foo() {\n" +
9545
		"		class ZZZZ {\n" +
9458
			"    boolean var;\n" +
9546
		"			ZZZ\n" +
9459
			"    var = tr\n" +
9547
		"		}\n" +
9460
			"  }\n" +
9548
		"	}\n" +
9461
			"}");
9549
		"}");
9462
	
9463
	
9550
	
9464
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9551
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9465
	String str = this.wc.getSource();
9552
	String str = this.workingCopies[0].getSource();
9466
	String completeBehind = "tr";
9553
	String completeBehind = "ZZZ";
9467
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9554
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9468
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9555
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9469
9556
9470
	assertResults(
9557
	assertResults(
9471
			"true[KEYWORD]{true, null, null, true, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
9558
			"ZZZ[POTENTIAL_METHOD_DECLARATION]{ZZZ, LZZZZ;, ()V, ZZZ, null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n"+
9559
			"ZZZZ[TYPE_REF]{ZZZZ, , LZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}",
9472
			requestor.getResults());
9560
			requestor.getResults());
9473
}
9561
}
9474
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=90615
9562
/*
9475
public void testCompletionKeywordTrue6() throws JavaModelException {
9563
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25815
9564
*/
9565
public void testCompletionMemberType() throws JavaModelException {
9476
	this.wc = getWorkingCopy(
9566
	this.wc = getWorkingCopy(
9477
			"/Completion/src/test/CompletionKeywordTrue6.java",
9567
            "/Completion/src/CompletionMemberType.java",
9478
			"package test;\n" +
9568
            "public class CompletionMemberType {\n"+
9479
			"public class CompletionKeywordTrue6 {\n" +
9569
            "	public class Y {\n"+
9480
			"  public void foo() {\n" +
9570
            "		public void foo(){\n"+
9481
			"    boolean var;\n" +
9571
            "			Y var = new Y\n"+
9482
			"    var = \n" +
9572
            "		}\n"+
9483
			"  }\n" +
9573
            "	}\n"+
9484
			"}");
9574
            "}");
9485
	
9575
    
9486
	
9576
    
9487
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9577
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9488
	String str = this.wc.getSource();
9578
    String str = this.wc.getSource();
9489
	String completeBehind = "var = ";
9579
    String completeBehind = "new Y";
9490
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9580
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9491
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9581
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9582
9583
    assertResults(
9584
		"CompletionMemberType.Y[TYPE_REF]{Y, , LCompletionMemberType$Y;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_EXACT_NAME+ R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
9585
		requestor.getResults());
9586
}
9587
public void testCompletionMemberType2() throws JavaModelException {
9588
	this.wc = getWorkingCopy(
9589
            "/Completion/src/test/CompletionMemberType2.java",
9590
            "public class CompletionMemberType2 {\n"+
9591
            "	public class MemberException extends Exception {\n"+
9592
            "	}\n"+
9593
            "	void foo() {\n"+
9594
            "		throw new \n"+
9595
            "	}\n"+
9596
            "}");
9597
    
9598
    
9599
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9600
    String str = this.wc.getSource();
9601
    String completeBehind = "new ";
9602
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9603
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9492
9604
9493
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
9605
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
9494
		assertResults(
9606
		assertResults(
9495
				"clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9607
			"",
9496
				"finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9608
			requestor.getResults());
9497
				"foo[METHOD_REF]{foo(), Ltest.CompletionKeywordTrue6;, ()V, foo, null, " +(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9498
				"getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9499
				"hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9500
				"notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9501
				"notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9502
				"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9503
				"wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9504
				"wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9505
				"wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9506
				"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n"+
9507
				"var[LOCAL_VARIABLE_REF]{var, null, Z, var, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n"+
9508
				"false[KEYWORD]{false, null, null, false, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_TRUE_OR_FALSE + R_NON_RESTRICTED)+"}\n"+
9509
				"true[KEYWORD]{true, null, null, true, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_TRUE_OR_FALSE + R_NON_RESTRICTED) + "}",
9510
				requestor.getResults());
9511
	} else {
9609
	} else {
9512
		assertResults(
9610
		assertResults(
9513
				"CompletionKeywordTrue6[TYPE_REF]{CompletionKeywordTrue6, test, Ltest.CompletionKeywordTrue6;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9611
			"CompletionMemberType2[TYPE_REF]{CompletionMemberType2, test, Ltest.CompletionMemberType2;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9514
				"clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9612
			"CompletionMemberType2.MemberException[TYPE_REF]{MemberException, test, Ltest.CompletionMemberType2$MemberException;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION+ R_NON_RESTRICTED)+"}",
9515
				"finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9613
			requestor.getResults());
9516
				"foo[METHOD_REF]{foo(), Ltest.CompletionKeywordTrue6;, ()V, foo, null, " +(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9517
				"getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9518
				"hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9519
				"notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9520
				"notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9521
				"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9522
				"wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9523
				"wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9524
				"wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9525
				"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n"+
9526
				"var[LOCAL_VARIABLE_REF]{var, null, Z, var, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"}\n"+
9527
				"false[KEYWORD]{false, null, null, false, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_TRUE_OR_FALSE + R_NON_RESTRICTED)+"}\n"+
9528
				"true[KEYWORD]{true, null, null, true, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_TRUE_OR_FALSE + R_NON_RESTRICTED) + "}",
9529
				requestor.getResults());
9530
	}
9614
	}
9531
}
9615
}
9532
public void testCompletionKeywordFalse3() throws JavaModelException {
9616
public void testCompletionMemberType3() throws JavaModelException {
9533
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9617
	this.wc = getWorkingCopy(
9534
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFalse3.java");
9618
            "/Completion/src/test/CompletionArrayClone.java",
9535
9619
            "public class CompletionMemberType3 {\n"+
9536
		String str = cu.getSource();
9620
            "	public class MemberException extends Exception {\n"+
9537
		String completeBehind = "fal";
9621
            "	}\n"+
9538
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9622
            "	void foo() {\n"+
9539
		cu.codeComplete(cursorLocation, requestor);
9623
            "		throw new MemberE\n"+
9624
            "	}\n"+
9625
            "}");
9626
    
9627
    
9628
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9629
    String str = this.wc.getSource();
9630
    String completeBehind = "new MemberE";
9631
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9632
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9540
9633
9541
		assertEquals(
9634
	assertResults(
9542
			"",
9635
		"CompletionMemberType3.MemberException[TYPE_REF]{MemberException, test, Ltest.CompletionMemberType3$MemberException;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXCEPTION+ R_UNQUALIFIED + R_NON_RESTRICTED) +"}",
9543
			requestor.getResults());
9636
		requestor.getResults());
9544
}
9637
}
9545
public void testCompletionKeywordFalse4() throws JavaModelException {
9638
public void testCompletionMessageSendIsParent1() throws JavaModelException {
9546
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9639
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9547
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordFalse4.java");
9640
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMessageSendIsParent1.java");
9548
9549
		String str = cu.getSource();
9550
		String completeBehind = "fal";
9551
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9552
		cu.codeComplete(cursorLocation, requestor);
9553
9554
		assertEquals(
9555
			"element:false    completion:false    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
9556
			requestor.getResults());
9557
}
9558
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=95008
9559
public void testCompletionKeywordFalse5() throws JavaModelException {
9560
	this.workingCopies = new ICompilationUnit[1];
9561
	this.workingCopies[0] = getWorkingCopy(
9562
		"/Completion/src/test/Test.java",
9563
		"package test;"+
9564
		"public class Test {\n" + 
9565
		"  boolean test = ;\n" + 
9566
		"}\n");
9567
9641
9568
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9642
	String str = cu.getSource();
9569
	String str = this.workingCopies[0].getSource();
9643
	String completeBehind = "zz";
9570
	String completeBehind = "boolean test = ";
9571
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9644
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9572
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9645
	cu.codeComplete(cursorLocation, requestor);
9573
9574
	assertResults(
9575
			"Test[TYPE_REF]{Test, test, Ltest.Test;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
9576
			"clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
9577
			"finalize[METHOD_REF]{finalize(), Ljava.lang.Object;, ()V, finalize, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
9578
			"getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class;, getClass, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
9579
			"hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
9580
			"notify[METHOD_REF]{notify(), Ljava.lang.Object;, ()V, notify, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
9581
			"notifyAll[METHOD_REF]{notifyAll(), Ljava.lang.Object;, ()V, notifyAll, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
9582
			"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
9583
			"wait[METHOD_REF]{wait(), Ljava.lang.Object;, ()V, wait, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
9584
			"wait[METHOD_REF]{wait(), Ljava.lang.Object;, (J)V, wait, (millis), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
9585
			"wait[METHOD_REF]{wait(), Ljava.lang.Object;, (JI)V, wait, (millis, nanos), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
9586
			"test[FIELD_REF]{test, Ltest.Test;, Z, test, null, " + (R_DEFAULT + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" +
9587
			"equals[METHOD_REF]{equals(), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" +
9588
			"false[KEYWORD]{false, null, null, false, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_TRUE_OR_FALSE + R_NON_RESTRICTED) + "}\n" +
9589
			"true[KEYWORD]{true, null, null, true, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_TRUE_OR_FALSE + R_NON_RESTRICTED) + "}",
9590
			requestor.getResults());
9591
}
9592
public void testCompletionKeywordNull3() throws JavaModelException {
9593
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9594
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNull3.java");
9595
9596
		String str = cu.getSource();
9597
		String completeBehind = "nul";
9598
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9599
		cu.codeComplete(cursorLocation, requestor);
9600
9601
		assertEquals(
9602
			"",
9603
			requestor.getResults());
9604
}
9605
public void testCompletionKeywordNull4() throws JavaModelException {
9606
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9607
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordNull4.java");
9608
9609
		String str = cu.getSource();
9610
		String completeBehind = "nul";
9611
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9612
		cu.codeComplete(cursorLocation, requestor);
9613
9614
		assertEquals(
9615
			"element:null    completion:null    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9616
			requestor.getResults());
9617
}
9618
public void testCompletionKeywordInstanceof4() throws JavaModelException {
9619
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9620
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInstanceof4.java");
9621
9622
		String str = cu.getSource();
9623
		String completeBehind = "ins";
9624
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9625
		cu.codeComplete(cursorLocation, requestor);
9626
9627
		assertEquals(
9628
			"element:instanceof    completion:instanceof    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
9629
			requestor.getResults());
9630
}
9631
public void testCompletionKeywordInstanceof5() throws JavaModelException {
9632
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9633
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInstanceof5.java");
9634
9635
		String str = cu.getSource();
9636
		String completeBehind = "ins";
9637
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9638
		cu.codeComplete(cursorLocation, requestor);
9639
9640
		assertEquals(
9641
			"",
9642
			requestor.getResults());
9643
}
9644
public void testCompletionKeywordInstanceof6() throws JavaModelException {
9645
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9646
		ICompilationUnit cu= getCompilationUnit("Completion", "src2", "", "CompletionKeywordInstanceof6.java");
9647
9648
		String str = cu.getSource();
9649
		String completeBehind = "ins";
9650
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9651
		cu.codeComplete(cursorLocation, requestor);
9652
9653
		assertEquals(
9654
			"",
9655
			requestor.getResults());
9656
}
9657
public void testCompletionMemberType2() throws JavaModelException {
9658
	this.wc = getWorkingCopy(
9659
            "/Completion/src/test/CompletionMemberType2.java",
9660
            "public class CompletionMemberType2 {\n"+
9661
            "	public class MemberException extends Exception {\n"+
9662
            "	}\n"+
9663
            "	void foo() {\n"+
9664
            "		throw new \n"+
9665
            "	}\n"+
9666
            "}");
9667
    
9668
    
9669
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9670
    String str = this.wc.getSource();
9671
    String completeBehind = "new ";
9672
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9673
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9674
9675
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
9676
		assertResults(
9677
			"",
9678
			requestor.getResults());
9679
	} else {
9680
		assertResults(
9681
			"CompletionMemberType2[TYPE_REF]{CompletionMemberType2, test, Ltest.CompletionMemberType2;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9682
			"CompletionMemberType2.MemberException[TYPE_REF]{MemberException, test, Ltest.CompletionMemberType2$MemberException;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION+ R_NON_RESTRICTED)+"}",
9683
			requestor.getResults());
9684
	}
9685
}
9686
public void testCompletionMemberType3() throws JavaModelException {
9687
	this.wc = getWorkingCopy(
9688
            "/Completion/src/test/CompletionArrayClone.java",
9689
            "public class CompletionMemberType3 {\n"+
9690
            "	public class MemberException extends Exception {\n"+
9691
            "	}\n"+
9692
            "	void foo() {\n"+
9693
            "		throw new MemberE\n"+
9694
            "	}\n"+
9695
            "}");
9696
    
9697
    
9698
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9699
    String str = this.wc.getSource();
9700
    String completeBehind = "new MemberE";
9701
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9702
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9703
9646
9704
	assertResults(
9647
	assertEquals(
9705
		"CompletionMemberType3.MemberException[TYPE_REF]{MemberException, test, Ltest.CompletionMemberType3$MemberException;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXCEPTION+ R_UNQUALIFIED + R_NON_RESTRICTED) +"}",
9648
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9649
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9650
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9651
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9652
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
9706
		requestor.getResults());
9653
		requestor.getResults());
9707
}
9654
}
9708
public void testCompletionAfterCase1() throws JavaModelException {
9655
public void testCompletionMessageSendIsParent2() throws JavaModelException {
9709
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9710
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAfterCase1.java");
9711
9712
		String str = cu.getSource();
9713
		String completeBehind = "zz";
9714
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9715
		cu.codeComplete(cursorLocation, requestor);
9716
9717
		assertEquals(
9718
			"element:zzz    completion:zzz    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
9719
			requestor.getResults());
9720
}
9721
public void testCompletionAfterCase2() throws JavaModelException {
9722
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9656
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9723
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAfterCase2.java");
9657
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMessageSendIsParent2.java");
9724
9658
9725
		String str = cu.getSource();
9659
	String str = cu.getSource();
9726
		String completeBehind = "zz";
9660
	String completeBehind = "zz";
9727
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9661
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9728
		cu.codeComplete(cursorLocation, requestor);
9662
	cu.codeComplete(cursorLocation, requestor);
9729
9663
9730
		assertEquals(
9664
	assertEquals(
9731
			"element:zzz    completion:zzz    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
9665
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9732
			requestor.getResults());
9666
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9667
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9668
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9669
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
9670
		requestor.getResults());
9733
}
9671
}
9734
public void testCompletionToplevelType1() throws JavaModelException {
9672
public void testCompletionMessageSendIsParent3() throws JavaModelException {
9735
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9673
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9736
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "p3", "CompletionToplevelType1.java");
9674
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMessageSendIsParent3.java");
9737
9675
9738
		String str = cu.getSource();
9676
	String str = cu.getSource();
9739
		String completeBehind = "CompletionToplevelType1";
9677
	String completeBehind = "zz";
9740
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9678
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9741
		cu.codeComplete(cursorLocation, requestor);
9679
	cu.codeComplete(cursorLocation, requestor);
9742
9680
9743
		assertEquals(
9681
	assertEquals(
9744
			"element:CompletionToplevelType1    completion:CompletionToplevelType1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME+ R_NON_RESTRICTED),
9682
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9745
			requestor.getResults());
9683
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9684
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9685
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9686
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
9687
		requestor.getResults());
9746
}
9688
}
9747
public void testCompletionCatchArgumentName2() throws JavaModelException {
9689
public void testCompletionMessageSendIsParent4() throws JavaModelException {
9748
	Hashtable options = JavaCore.getOptions();
9749
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_ARGUMENT_PREFIXES);
9750
	options.put(JavaCore.CODEASSIST_ARGUMENT_PREFIXES,"arg"); //$NON-NLS-1$
9751
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
9752
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"loc"); //$NON-NLS-1$
9753
	
9754
	JavaCore.setOptions(options);
9755
9756
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9690
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9757
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionCatchArgumentName2.java");
9691
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMessageSendIsParent4.java");
9758
9692
9759
	String str = cu.getSource();
9693
	String str = cu.getSource();
9760
	String completeBehind = "Exception ";
9694
	String completeBehind = "zz";
9761
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9695
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9762
	cu.codeComplete(cursorLocation, requestor);
9696
	cu.codeComplete(cursorLocation, requestor);
9763
9697
9764
	options.put(JavaCore.CODEASSIST_ARGUMENT_PREFIXES,argumentPrefixPreviousValue);
9765
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,localPrefixPreviousValue);
9766
	JavaCore.setOptions(options);
9767
9768
	assertEquals(
9698
	assertEquals(
9769
		"element:exception    completion:exception    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
9699
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9770
		"element:locException    completion:locException    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX+ R_NON_RESTRICTED),
9700
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9701
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9702
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9703
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
9771
		requestor.getResults());
9704
		requestor.getResults());
9772
}
9705
}
9773
public void testCompletionArrayAccess1() throws JavaModelException {
9706
public void testCompletionMessageSendIsParent5() throws JavaModelException {
9774
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9707
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9775
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionArrayAccess1.java");
9708
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMessageSendIsParent5.java");
9776
9709
9777
	String str = cu.getSource();
9710
	String str = cu.getSource();
9778
	String completeBehind = "zzz";
9711
	String completeBehind = "zz";
9779
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9712
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9780
	cu.codeComplete(cursorLocation, requestor);
9713
	cu.codeComplete(cursorLocation, requestor);
9781
9714
9782
	assertEquals(
9715
	assertEquals(
9783
		"element:zzz1    completion:zzz1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
9716
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9784
		"element:zzz2    completion:zzz2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE +R_UNQUALIFIED+ R_NON_RESTRICTED),
9717
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9718
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9719
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9720
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
9785
		requestor.getResults());
9721
		requestor.getResults());
9786
}
9722
}
9787
public void testCompletionVariableName3() throws JavaModelException {
9723
public void testCompletionMessageSendIsParent6() throws JavaModelException {
9788
	Hashtable options = JavaCore.getOptions();
9724
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9789
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
9725
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMessageSendIsParent6.java");
9790
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"p1,p2"); //$NON-NLS-1$
9791
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
9792
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"s1,s2"); //$NON-NLS-1$
9793
	
9794
	JavaCore.setOptions(options);
9795
9726
9796
	try {
9727
	String str = cu.getSource();
9797
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9728
	String completeBehind = "zz";
9798
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableName3.java");
9729
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9799
	
9730
	cu.codeComplete(cursorLocation, requestor);
9800
		String str = cu.getSource();
9731
9801
		String completeBehind = "OneName ";
9732
	assertEquals(
9802
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9733
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9803
		cu.codeComplete(cursorLocation, requestor);
9734
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9804
	
9735
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9805
		assertEquals(
9736
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
9806
			"element:name    completion:name    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
9737
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
9807
			"element:names1    completion:names1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"\n"+
9738
		requestor.getResults());
9808
			"element:names2    completion:names2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_SUFFIX + R_NON_RESTRICTED)+"\n"+
9809
			"element:oneName    completion:oneName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
9810
			"element:oneNames1    completion:oneNames1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"\n"+
9811
			"element:oneNames2    completion:oneNames2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_SUFFIX + R_NON_RESTRICTED)+"\n"+
9812
			"element:p1Name    completion:p1Name    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NON_RESTRICTED)+"\n"+
9813
			"element:p1Names1    completion:p1Names1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"\n"+
9814
			"element:p1Names2    completion:p1Names2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NAME_SUFFIX + R_NON_RESTRICTED)+"\n"+
9815
			"element:p1OneName    completion:p1OneName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NON_RESTRICTED)+"\n"+
9816
			"element:p1OneNames1    completion:p1OneNames1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"\n"+
9817
			"element:p1OneNames2    completion:p1OneNames2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NAME_SUFFIX + R_NON_RESTRICTED)+"\n"+
9818
			"element:p2Name    completion:p2Name    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_PREFIX + R_NON_RESTRICTED)+"\n"+
9819
			"element:p2Names1    completion:p2Names1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"\n"+
9820
			"element:p2Names2    completion:p2Names2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_PREFIX + R_NAME_SUFFIX + R_NON_RESTRICTED)+"\n"+
9821
			"element:p2OneName    completion:p2OneName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_PREFIX + R_NON_RESTRICTED)+"\n"+
9822
			"element:p2OneNames1    completion:p2OneNames1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"\n"+
9823
			"element:p2OneNames2    completion:p2OneNames2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_PREFIX + R_NAME_SUFFIX+ R_NON_RESTRICTED),
9824
			requestor.getResults());
9825
	} finally {
9826
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
9827
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
9828
		JavaCore.setOptions(options);
9829
	}
9830
}
9739
}
9831
public void testCompletionVariableName4() throws JavaModelException {
9740
public void testCompletionMethodDeclaration() throws JavaModelException {
9832
	this.wc = getWorkingCopy(
9833
            "/Completion/src/CompletionVariableName4.java",
9834
            "class FooBar {\n"+
9835
            "}\n"+
9836
            "public class CompletionVariableName4 {\n"+
9837
            "	void foo(){\n"+
9838
            "		FooBar the\n"+
9839
            "	}\n"+
9840
            "}");
9841
    
9842
    
9843
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9844
    String str = this.wc.getSource();
9845
    String completeBehind = "the";
9846
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9847
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9848
9741
9849
    assertResults(
9742
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9850
    		"theBar[VARIABLE_DECLARATION]{theBar, null, LFooBar;, theBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
9743
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMethodDeclaration.java");
9851
			"theFooBar[VARIABLE_DECLARATION]{theFooBar, null, LFooBar;, theFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
9744
9852
			requestor.getResults());
9745
	String str = cu.getSource();
9746
	String completeBehind = "eq";
9747
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
9748
	cu.codeComplete(cursorLocation, requestor);
9749
9750
	assertEquals(
9751
		"should have two completions", 
9752
		"element:eqFoo    completion:public int eqFoo(int a, Object b)    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"\n" +
9753
		"element:equals    completion:public boolean equals(Object obj)    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
9754
		requestor.getResults());
9853
}
9755
}
9854
public void testCompletionVariableName5() throws JavaModelException {
9756
public void testCompletionMethodDeclaration10() throws JavaModelException {
9855
	this.wc = getWorkingCopy(
9856
            "/Completion/src/CompletionVariableName5.java",
9857
            "class FooBar {\n"+
9858
            "}\n"+
9859
            "public class CompletionVariableName5 {\n"+
9860
            "	void foo(){\n"+
9861
            "		FooBar thefo\n"+
9862
            "	}\n"+
9863
            "}");
9864
    
9865
    
9866
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9867
    String str = this.wc.getSource();
9868
    String completeBehind = "thefo";
9869
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9870
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9871
9757
9872
    assertResults(
9758
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
9873
    		"thefoBar[VARIABLE_DECLARATION]{thefoBar, null, LFooBar;, thefoBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
9759
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMethodDeclaration10.java");
9874
			"theFooBar[VARIABLE_DECLARATION]{theFooBar, null, LFooBar;, theFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}",
9760
9875
			requestor.getResults());
9761
	String str = cu.getSource();
9762
	String completeBehind = "clon";
9763
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9764
	cu.codeComplete(cursorLocation, requestor);
9765
9766
	assertEquals(
9767
		"should have one completion", 
9768
		"element:CloneNotSupportedException    completion:CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
9769
		"element:clone    completion:protected Object clone() throws CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
9770
		requestor.getResults());
9876
}
9771
}
9877
public void testCompletionVariableName6() throws JavaModelException {
9772
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=80063
9773
public void testCompletionMethodDeclaration11() throws JavaModelException {
9878
	this.wc = getWorkingCopy(
9774
	this.wc = getWorkingCopy(
9879
            "/Completion/src/CompletionVariableName6.java",
9775
			"/Completion/src/test/CompletionMethodDeclaration11.java",
9880
            "class FooBar {\n"+
9776
			"package test;\n" +
9881
            "}\n"+
9777
			"public class CompletionMethodDeclaration11 {\n" +
9882
            "public class CompletionVariableName6 {\n"+
9778
			"  private void foo() {\n" +
9883
            "	void foo(){\n"+
9779
			"  }\n" +
9884
            "		FooBar theba\n"+
9780
			"}\n" +
9885
            "	}\n"+
9781
			"class CompletionMethodDeclaration11_2 extends CompletionMethodDeclaration11 {\n" +
9886
            "}");
9782
			"  fo\n" +
9887
    
9783
			"}");
9888
    
9784
	
9889
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9785
	
9890
    String str = this.wc.getSource();
9786
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9891
    String completeBehind = "theba";
9787
	String str = this.wc.getSource();
9892
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9788
	String completeBehind = "fo";
9893
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9789
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9790
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9894
9791
9895
    assertResults(
9792
	assertResults(
9896
    		"thebaFooBar[VARIABLE_DECLARATION]{thebaFooBar, null, LFooBar;, thebaFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
9793
			"fo[POTENTIAL_METHOD_DECLARATION]{fo, Ltest.CompletionMethodDeclaration11_2;, ()V, fo, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}",
9897
			"theBar[VARIABLE_DECLARATION]{theBar, null, LFooBar;, theBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}",
9898
			requestor.getResults());
9794
			requestor.getResults());
9899
}
9795
}
9900
public void testCompletionVariableName7() throws JavaModelException {
9796
public void testCompletionMethodDeclaration12() throws JavaModelException {
9901
	this.wc = getWorkingCopy(
9797
    this.wc = getWorkingCopy(
9902
            "/Completion/src/CompletionVariableName7.java",
9798
            "/Completion/src/test/CompletionMethodDeclaration12.java",
9903
            "class FooBar {\n"+
9799
            "package test;\n" +
9904
            "}\n"+
9800
            "public class CompletionMethodDeclaration12 {\n" +
9905
            "public class CompletionVariableName7 {\n"+
9801
            "  public void foo() {\n" +
9906
            "	void foo(){\n"+
9802
            "  }\n" +
9907
            "		FooBar fo\n"+
9803
            "}\n" +
9908
            "	}\n"+
9804
            "class CompletionMethodDeclaration12_2 extends CompletionMethodDeclaration12{\n" +
9805
            "  public final void foo() {\n" +
9806
            "  }\n" +
9807
            "}\n" +
9808
            "class CompletionMethodDeclaration12_3 extends CompletionMethodDeclaration12_2 {\n" +
9809
            "  fo\n" +
9909
            "}");
9810
            "}");
9910
    
9811
    
9911
    
9812
    
Lines 9916-10898 Link Here
9916
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9817
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9917
9818
9918
    assertResults(
9819
    assertResults(
9919
			"foBar[VARIABLE_DECLARATION]{foBar, null, LFooBar;, foBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
9820
            "fo[POTENTIAL_METHOD_DECLARATION]{fo, Ltest.CompletionMethodDeclaration12_3;, ()V, fo, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}",
9920
			"fooBar[VARIABLE_DECLARATION]{fooBar, null, LFooBar;, fooBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}",
9821
            requestor.getResults());
9921
			requestor.getResults());
9922
}
9822
}
9923
public void testCompletionVariableName8() throws JavaModelException {
9823
public void testCompletionMethodDeclaration2() throws JavaModelException {
9924
	Hashtable options = JavaCore.getOptions();
9824
	ICompilationUnit superClass = null;
9925
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
9926
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pre"); //$NON-NLS-1$
9927
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
9928
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"suf"); //$NON-NLS-1$
9929
	
9930
	JavaCore.setOptions(options);
9931
9932
	try {
9825
	try {
9826
		superClass = getWorkingCopy(
9827
	            "/Completion/src/CompletionSuperClass.java",
9828
	            "public class CompletionSuperClass{\n" +
9829
	            "	public class Inner {}\n" +
9830
	            "	public int eqFoo(int a,Object b){\n" +
9831
	            "		return 1;\n" +
9832
	            "	}\n" +
9833
	            "}");
9834
		
9933
		this.wc = getWorkingCopy(
9835
		this.wc = getWorkingCopy(
9934
	            "/Completion/src/CompletionVariableName8.java",
9836
	            "/Completion/src/CompletionMethodDeclaration2.java",
9935
	            "class FooBar {\n"+
9837
	            "public class CompletionMethodDeclaration2 extends CompletionSuperClass {\n" +
9936
	            "}\n"+
9838
	            "	eq\n" +
9937
	            "public class CompletionVariableName8 {\n"+
9938
	            "	void foo(){\n"+
9939
	            "		FooBar the\n"+
9940
	            "	}\n"+
9941
	            "}");
9839
	            "}");
9942
	    
9840
	    
9943
	    
9841
	    
9944
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9842
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9945
	    String str = this.wc.getSource();
9843
	    String str = this.wc.getSource();
9946
	    String completeBehind = "the";
9844
	    String completeBehind = "eq";
9947
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9845
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9948
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9846
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9949
	
9847
	
9950
	    assertResults(
9848
		assertResults(
9951
				"theBar[VARIABLE_DECLARATION]{theBar, null, LFooBar;, theBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
9849
			"eq[POTENTIAL_METHOD_DECLARATION]{eq, LCompletionMethodDeclaration2;, ()V, eq, null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n" +
9952
				"theFooBar[VARIABLE_DECLARATION]{theFooBar, null, LFooBar;, theFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
9850
			"eqFoo[METHOD_DECLARATION]{public int eqFoo(int a, Object b), LCompletionSuperClass;, (ILjava.lang.Object;)I, eqFoo, (a, b), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n" +
9953
				"theBarsuf[VARIABLE_DECLARATION]{theBarsuf, null, LFooBar;, theBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}\n"+
9851
			"equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED)+"}",
9954
				"theFooBarsuf[VARIABLE_DECLARATION]{theFooBarsuf, null, LFooBar;, theFooBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_CASE + R_NON_RESTRICTED)+"}",
9852
			requestor.getResults());
9955
				requestor.getResults());
9956
	} finally {
9853
	} finally {
9957
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
9854
		if(superClass != null) {
9958
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
9855
			superClass.discardWorkingCopy();
9959
		JavaCore.setOptions(options);
9856
		}
9960
	}
9857
	}
9961
}
9858
}
9962
public void testCompletionVariableName9() throws JavaModelException {
9859
/**
9963
	Hashtable options = JavaCore.getOptions();
9860
 * Completion should not propose declarations of method already locally implemented
9964
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
9861
 */
9965
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pre"); //$NON-NLS-1$
9862
public void testCompletionMethodDeclaration3() throws JavaModelException {
9966
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
9863
	ICompilationUnit superClass = null;
9967
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"suf"); //$NON-NLS-1$
9968
	
9969
	JavaCore.setOptions(options);
9970
9971
	try {
9864
	try {
9972
		this.wc = getWorkingCopy(
9865
		superClass = getWorkingCopy(
9973
	            "/Completion/src/CompletionVariableName9.java",
9866
	            "/Completion/src/CompletionSuperClass.java",
9974
	            "class FooBar {\n"+
9867
	            "public class CompletionSuperClass{\n" +
9975
	            "}\n"+
9868
	            "	public class Inner {}\n" +
9976
	            "public class CompletionVariableName9 {\n"+
9869
	            "	public int eqFoo(int a,Object b){\n" +
9977
	            "	void foo(){\n"+
9870
	            "		return 1;\n" +
9978
	            "		FooBar thefo\n"+
9871
	            "	}\n" +
9979
	            "	}\n"+
9980
	            "}");
9872
	            "}");
9981
	    
9873
		
9982
	    
9983
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9984
	    String str = this.wc.getSource();
9985
	    String completeBehind = "thefo";
9986
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9987
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9988
	
9989
	    assertResults(
9990
				"thefoBar[VARIABLE_DECLARATION]{thefoBar, null, LFooBar;, thefoBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
9991
				"thefoBarsuf[VARIABLE_DECLARATION]{thefoBarsuf, null, LFooBar;, thefoBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}\n"+
9992
				"theFooBar[VARIABLE_DECLARATION]{theFooBar, null, LFooBar;, theFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}\n"+
9993
				"theFooBarsuf[VARIABLE_DECLARATION]{theFooBarsuf, null, LFooBar;, theFooBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_LESS_NEW_CHARACTERS + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}",
9994
				requestor.getResults());
9995
	} finally {
9996
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
9997
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
9998
		JavaCore.setOptions(options);
9999
	}
10000
}
10001
public void testCompletionVariableName10() throws JavaModelException {
10002
	Hashtable options = JavaCore.getOptions();
10003
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
10004
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pre"); //$NON-NLS-1$
10005
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
10006
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"suf"); //$NON-NLS-1$
10007
	
10008
	JavaCore.setOptions(options);
10009
10010
	try {
10011
		this.wc = getWorkingCopy(
9874
		this.wc = getWorkingCopy(
10012
	            "/Completion/src/CompletionVariableName10.java",
9875
	            "/Completion/src/CompletionMethodDeclaration3.java",
10013
	            "class FooBar {\n"+
9876
	            "public class CompletionMethodDeclaration3 extends CompletionSuperClass {\n" +
10014
	            "}\n"+
9877
	            "	eq\n" +
10015
	            "public class CompletionVariableName10 {\n"+
9878
	            "	\n" +
10016
	            "	void foo(){\n"+
9879
	            "	public int eqFoo(int a,Object b){\n" +
10017
	            "		FooBar fo\n"+
9880
	            "		return 1;\n" +
10018
	            "	}\n"+
9881
	            "	}\n" +
10019
	            "}");
9882
	            "}");
10020
	    
9883
	    
10021
	    
9884
	    
10022
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9885
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10023
	    String str = this.wc.getSource();
9886
	    String str = this.wc.getSource();
10024
	    String completeBehind = "fo";
9887
	    String completeBehind = "eq";
10025
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9888
	    int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
10026
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9889
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10027
	
9890
	
10028
	    assertResults(
9891
		assertResults(
10029
				"foBar[VARIABLE_DECLARATION]{foBar, null, LFooBar;, foBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
9892
			"eq[POTENTIAL_METHOD_DECLARATION]{eq, LCompletionMethodDeclaration3;, ()V, eq, null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n" +
10030
				"foBarsuf[VARIABLE_DECLARATION]{foBarsuf, null, LFooBar;, foBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}\n"+
9893
			"equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED)+"}",
10031
				"fooBar[VARIABLE_DECLARATION]{fooBar, null, LFooBar;, fooBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}\n"+
9894
			requestor.getResults());
10032
				"fooBarsuf[VARIABLE_DECLARATION]{fooBarsuf, null, LFooBar;, fooBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_LESS_NEW_CHARACTERS + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}",
10033
				requestor.getResults());
10034
	} finally {
9895
	} finally {
10035
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
9896
		if(superClass != null) {
10036
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
9897
			superClass.discardWorkingCopy();
10037
		JavaCore.setOptions(options);
9898
		}
10038
	}
9899
	}
10039
}
9900
}
10040
public void testCompletionVariableName11() throws JavaModelException {
9901
public void testCompletionMethodDeclaration4() throws JavaModelException {
10041
	Hashtable options = JavaCore.getOptions();
9902
	ICompilationUnit superClass = null;
10042
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
10043
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pre"); //$NON-NLS-1$
10044
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
10045
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"suf"); //$NON-NLS-1$
10046
	
10047
	JavaCore.setOptions(options);
10048
10049
	try {
9903
	try {
9904
		superClass = getWorkingCopy(
9905
	            "/Completion/src/CompletionSuperInterface.java",
9906
	            "public interface CompletionSuperInterface{\n"+
9907
	            "	public int eqFoo(int a,Object b);\n"+
9908
	            "}");
9909
		
10050
		this.wc = getWorkingCopy(
9910
		this.wc = getWorkingCopy(
10051
	            "/Completion/src/CompletionVariableName11.java",
9911
	            "/Completion/src/CompletionMethodDeclaration4.java",
10052
	            "class FooBar {\n"+
9912
	            "public abstract class CompletionMethodDeclaration4 implements CompletionSuperInterface {\n"+
10053
	            "}\n"+
9913
	            "	eq\n"+
10054
	            "public class CompletionVariableName11 {\n"+
10055
	            "	void foo(){\n"+
10056
	            "		FooBar pr\n"+
10057
	            "	}\n"+
10058
	            "}");
9914
	            "}");
10059
	    
9915
	    
10060
	    
9916
	    
10061
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9917
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10062
	    String str = this.wc.getSource();
9918
	    String str = this.wc.getSource();
10063
	    String completeBehind = "pr";
9919
	    String completeBehind = "eq";
10064
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9920
	    int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
10065
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9921
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10066
	
9922
	
10067
	    assertResults(
9923
		assertResults(
10068
				"preBar[VARIABLE_DECLARATION]{preBar, null, LFooBar;, preBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NON_RESTRICTED)+"}\n"+
9924
			"eq[POTENTIAL_METHOD_DECLARATION]{eq, LCompletionMethodDeclaration4;, ()V, eq, null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n" +
10069
				"preFooBar[VARIABLE_DECLARATION]{preFooBar, null, LFooBar;, preFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NON_RESTRICTED)+"}\n"+
9925
			"equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
10070
				"preBarsuf[VARIABLE_DECLARATION]{preBarsuf, null, LFooBar;, preBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX+ R_NON_RESTRICTED)+"}\n"+
9926
			"eqFoo[METHOD_DECLARATION]{public int eqFoo(int a, Object b), LCompletionSuperInterface;, (ILjava.lang.Object;)I, eqFoo, (a, b), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_ABSTRACT_METHOD + R_METHOD_OVERIDE+ R_NON_RESTRICTED)+"}",
10071
				"preFooBarsuf[VARIABLE_DECLARATION]{preFooBarsuf, null, LFooBar;, preFooBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}",
9927
			requestor.getResults());
10072
				requestor.getResults());
10073
	} finally {
9928
	} finally {
10074
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
9929
		if(superClass != null) {
10075
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
9930
			superClass.discardWorkingCopy();
10076
		JavaCore.setOptions(options);
9931
		}
10077
	}
9932
	}
10078
}
9933
}
10079
public void testCompletionVariableName12() throws JavaModelException {
9934
public void testCompletionMethodDeclaration5() throws JavaModelException {
10080
	Hashtable options = JavaCore.getOptions();
9935
	ICompilationUnit superClass = null;
10081
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
10082
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pre"); //$NON-NLS-1$
10083
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
10084
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"suf"); //$NON-NLS-1$
10085
	
10086
	JavaCore.setOptions(options);
10087
10088
	try {
9936
	try {
9937
		superClass = getWorkingCopy(
9938
	            "/Completion/src/CompletionSuperClass.java",
9939
	            "public class CompletionSuperClass{\n" +
9940
	            "	public class Inner {}\n" +
9941
	            "	public int eqFoo(int a,Object b){\n" +
9942
	            "		return 1;\n" +
9943
	            "	}\n" +
9944
	            "}");
9945
		
10089
		this.wc = getWorkingCopy(
9946
		this.wc = getWorkingCopy(
10090
	            "/Completion/src/CompletionVariableName12.java",
9947
	            "/Completion/src/CompletionMethodDeclaration5.java",
10091
	            "class FooBar {\n"+
9948
	            "public class CompletionMethodDeclaration5 {\n" +
10092
	            "}\n"+
9949
	            "	public static void main(String[] args) {\n" +
10093
	            "public class CompletionVariableName12 {\n"+
9950
	            "		new CompletionSuperClass() {\n" +
10094
	            "	void foo(){\n"+
9951
	            "	}\n" +
10095
	            "		FooBar prethe\n"+
9952
	            "\n" +
10096
	            "	}\n"+
10097
	            "}");
9953
	            "}");
10098
	    
9954
	    
10099
	    
9955
	    
10100
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9956
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10101
	    String str = this.wc.getSource();
9957
	    String str = this.wc.getSource();
10102
	    String completeBehind = "prethe";
9958
	    String completeBehind = "new CompletionSuperClass() {";
10103
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9959
	    int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
10104
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
9960
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10105
	
9961
	
10106
	    assertResults(
9962
	    if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
10107
				"preTheBar[VARIABLE_DECLARATION]{preTheBar, null, LFooBar;, preTheBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NON_RESTRICTED)+"}\n"+
9963
			assertResults(
10108
				"preTheFooBar[VARIABLE_DECLARATION]{preTheFooBar, null, LFooBar;, preTheFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NON_RESTRICTED)+"}\n"+
9964
				"[POTENTIAL_METHOD_DECLARATION]{, LCompletionSuperClass;, ()V, , null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n" +
10109
				"preTheBarsuf[VARIABLE_DECLARATION]{preTheBarsuf, null, LFooBar;, preTheBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}\n"+
9965
				"clone[METHOD_DECLARATION]{protected Object clone() throws CloneNotSupportedException, Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
10110
				"preTheFooBarsuf[VARIABLE_DECLARATION]{preTheFooBarsuf, null, LFooBar;, preTheFooBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}",
9966
				"eqFoo[METHOD_DECLARATION]{public int eqFoo(int a, Object b), LCompletionSuperClass;, (ILjava.lang.Object;)I, eqFoo, (a, b), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
9967
				"equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
9968
				"finalize[METHOD_DECLARATION]{protected void finalize() throws Throwable, Ljava.lang.Object;, ()V, finalize, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
9969
				"hashCode[METHOD_DECLARATION]{public int hashCode(), Ljava.lang.Object;, ()I, hashCode, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
9970
				"toString[METHOD_DECLARATION]{public String toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED)+ "}",
9971
				requestor.getResults());
9972
		} else {
9973
			assertResults(
9974
				"[POTENTIAL_METHOD_DECLARATION]{, LCompletionSuperClass;, ()V, , null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n" +
9975
				"CompletionMethodDeclaration5[TYPE_REF]{CompletionMethodDeclaration5, , LCompletionMethodDeclaration5;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
9976
				"clone[METHOD_DECLARATION]{protected Object clone() throws CloneNotSupportedException, Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
9977
				"eqFoo[METHOD_DECLARATION]{public int eqFoo(int a, Object b), LCompletionSuperClass;, (ILjava.lang.Object;)I, eqFoo, (a, b), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
9978
				"equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, (obj), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
9979
				"finalize[METHOD_DECLARATION]{protected void finalize() throws Throwable, Ljava.lang.Object;, ()V, finalize, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
9980
				"hashCode[METHOD_DECLARATION]{public int hashCode(), Ljava.lang.Object;, ()I, hashCode, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED)+"}\n"+
9981
				"toString[METHOD_DECLARATION]{public String toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED)+ "}",
10111
				requestor.getResults());
9982
				requestor.getResults());
9983
		}
10112
	} finally {
9984
	} finally {
10113
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
9985
		if(superClass != null) {
10114
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
9986
			superClass.discardWorkingCopy();
10115
		JavaCore.setOptions(options);
9987
		}
10116
	}
9988
	}
10117
}
9989
}
10118
public void testCompletionVariableName13() throws JavaModelException {
9990
public void testCompletionMethodDeclaration6() throws JavaModelException {
10119
	Hashtable options = JavaCore.getOptions();
10120
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
10121
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pre"); //$NON-NLS-1$
10122
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
10123
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"suf"); //$NON-NLS-1$
10124
	
10125
	JavaCore.setOptions(options);
10126
9991
10127
	try {
9992
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10128
		this.wc = getWorkingCopy(
9993
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMethodDeclaration6.java");
10129
	            "/Completion/src/CompletionVariableName13.java",
9994
10130
	            "class FooBar {\n"+
9995
	String str = cu.getSource();
10131
	            "}\n"+
9996
	String completeBehind = "clon";
10132
	            "public class CompletionVariableName13 {\n"+
9997
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10133
	            "	void foo(){\n"+
9998
	cu.codeComplete(cursorLocation, requestor);
10134
	            "		FooBar prefo\n"+
9999
10135
	            "	}\n"+
10000
	assertEquals(
10136
	            "}");
10001
		"should have one completion", 
10137
	    
10002
		"element:CloneNotSupportedException    completion:CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
10138
	    
10003
		requestor.getResults());
10139
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10140
	    String str = this.wc.getSource();
10141
	    String completeBehind = "prefo";
10142
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10143
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10144
	
10145
	    assertResults(
10146
				"preFoBar[VARIABLE_DECLARATION]{preFoBar, null, LFooBar;, preFoBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NON_RESTRICTED)+"}\n"+
10147
				"preFoBarsuf[VARIABLE_DECLARATION]{preFoBarsuf, null, LFooBar;, preFoBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}\n"+
10148
				"preFooBar[VARIABLE_DECLARATION]{preFooBar, null, LFooBar;, preFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}\n"+
10149
				"preFooBarsuf[VARIABLE_DECLARATION]{preFooBarsuf, null, LFooBar;, preFooBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}",
10150
				requestor.getResults());
10151
	} finally {
10152
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
10153
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
10154
		JavaCore.setOptions(options);
10155
	}
10156
}
10004
}
10157
public void testCompletionVariableName14() throws JavaModelException {
10005
public void testCompletionMethodDeclaration7() throws JavaModelException {
10158
	Hashtable options = JavaCore.getOptions();
10159
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
10160
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pre"); //$NON-NLS-1$
10161
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
10162
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"suf"); //$NON-NLS-1$
10163
	
10164
	JavaCore.setOptions(options);
10165
10006
10166
	try {
10007
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10167
		this.wc = getWorkingCopy(
10008
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMethodDeclaration7.java");
10168
	            "/Completion/src/CompletionVariableName14.java",
10169
	            "class FooBar {\n"+
10170
	            "}\n"+
10171
	            "public class CompletionVariableName14 {\n"+
10172
	            "	void foo(){\n"+
10173
	            "		FooBar prethefo\n"+
10174
	            "	}\n"+
10175
	            "}");
10176
	    
10177
	    
10178
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10179
	    String str = this.wc.getSource();
10180
	    String completeBehind = "prethefo";
10181
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10182
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10183
	
10184
	    assertResults(
10185
				"preThefoBar[VARIABLE_DECLARATION]{preThefoBar, null, LFooBar;, preThefoBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NON_RESTRICTED)+"}\n"+
10186
				"preThefoBarsuf[VARIABLE_DECLARATION]{preThefoBarsuf, null, LFooBar;, preThefoBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}\n"+
10187
				"preTheFooBar[VARIABLE_DECLARATION]{preTheFooBar, null, LFooBar;, preTheFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}\n"+
10188
				"preTheFooBarsuf[VARIABLE_DECLARATION]{preTheFooBarsuf, null, LFooBar;, preTheFooBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}",
10189
				requestor.getResults());
10190
	} finally {
10191
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
10192
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
10193
		JavaCore.setOptions(options);
10194
	}
10195
}
10196
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=128045
10197
public void testCompletionVariableName15() throws JavaModelException {
10198
	Hashtable options = JavaCore.getOptions();
10199
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
10200
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pre"); //$NON-NLS-1$
10201
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
10202
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"suf"); //$NON-NLS-1$
10203
	
10204
	JavaCore.setOptions(options);
10205
10009
10206
	try {
10010
	String str = cu.getSource();
10207
		this.wc = getWorkingCopy(
10011
	String completeBehind = "clon";
10208
	            "/Completion/src/CompletionVariableName15.java",
10012
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10209
	            "class FooBar {\n"+
10013
	cu.codeComplete(cursorLocation, requestor);
10210
	            "}\n"+
10211
	            "public class CompletionVariableName15 {\n"+
10212
	            "	void foo(){\n"+
10213
	            "		FooBar pro\n"+
10214
	            "	}\n"+
10215
	            "}");
10216
	    
10217
	    
10218
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10219
	    String str = this.wc.getSource();
10220
	    String completeBehind = "pro";
10221
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10222
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10223
	
10224
	    assertResults(
10225
				"proBar[VARIABLE_DECLARATION]{proBar, null, LFooBar;, proBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10226
				"proFooBar[VARIABLE_DECLARATION]{proFooBar, null, LFooBar;, proFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10227
				"proBarsuf[VARIABLE_DECLARATION]{proBarsuf, null, LFooBar;, proBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_CASE + R_NON_RESTRICTED)+"}\n"+
10228
				"proFooBarsuf[VARIABLE_DECLARATION]{proFooBarsuf, null, LFooBar;, proFooBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_CASE + R_NON_RESTRICTED)+"}",
10229
				requestor.getResults());
10230
	} finally {
10231
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
10232
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
10233
		JavaCore.setOptions(options);
10234
	}
10235
}
10236
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
10237
public void testCompletionVariableName16() throws JavaModelException {
10238
	this.workingCopies = new ICompilationUnit[1];
10239
	this.workingCopies[0] = getWorkingCopy(
10240
            "/Completion/src/test/Test.java",
10241
            "package test;\n"+
10242
            "public class Test {\n"+
10243
            "	void foo(){\n"+
10244
            "		Object ;\n"+
10245
            "		foo = null;\n"+
10246
            "	}\n"+
10247
            "}");
10248
    
10249
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10250
    String str = this.workingCopies[0].getSource();
10251
    String completeBehind = "Object ";
10252
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10253
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10254
10014
10255
    assertResults(
10015
	assertEquals(
10256
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10016
		"should have one completion", 
10257
			"foo[VARIABLE_DECLARATION]{foo, null, Ljava.lang.Object;, foo, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10017
		"element:CloneNotSupportedException    completion:CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10258
			requestor.getResults());
10018
		"element:clone    completion:protected Object clone() throws CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
10019
		requestor.getResults());
10259
}
10020
}
10260
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
10021
public void testCompletionMethodDeclaration8() throws JavaModelException {
10261
public void testCompletionVariableName17() throws JavaModelException {
10262
	this.workingCopies = new ICompilationUnit[1];
10263
	this.workingCopies[0] = getWorkingCopy(
10264
            "/Completion/src/test/Test.java",
10265
            "package test;\n"+
10266
            "public class Test {\n"+
10267
            "	void foo(){\n"+
10268
            "		Object foo1;\n"+
10269
            "		/*here*/Object ;\n"+
10270
            "		Object foo3;\n"+
10271
            "		foo1 = null;\n"+
10272
            "		foo2 = null;\n"+
10273
            "		foo3 = null;\n"+
10274
            "	}\n"+
10275
            "}");
10276
    
10277
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10278
    String str = this.workingCopies[0].getSource();
10279
    String completeBehind = "/*here*/Object ";
10280
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10281
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10282
10022
10283
    assertResults(
10023
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10284
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10024
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMethodDeclaration8.java");
10285
			"foo2[VARIABLE_DECLARATION]{foo2, null, Ljava.lang.Object;, foo2, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10286
			requestor.getResults());
10287
}
10288
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
10289
public void testCompletionVariableName18() throws JavaModelException {
10290
	this.workingCopies = new ICompilationUnit[1];
10291
	this.workingCopies[0] = getWorkingCopy(
10292
            "/Completion/src/test/Test.java",
10293
            "package test;\n"+
10294
            "public class Test {\n"+
10295
            "	void foo(){\n"+
10296
            "		Object ;\n"+
10297
            "		foo = Test.class;\n"+
10298
            "	}\n"+
10299
            "}");
10300
    
10301
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10302
    String str = this.workingCopies[0].getSource();
10303
    String completeBehind = "Object ";
10304
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10305
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10306
10025
10307
    assertResults(
10026
	String str = cu.getSource();
10308
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10027
	String completeBehind = "clon";
10309
			"foo[VARIABLE_DECLARATION]{foo, null, Ljava.lang.Object;, foo, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10028
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10310
			requestor.getResults());
10029
	cu.codeComplete(cursorLocation, requestor);
10311
}
10312
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
10313
public void testCompletionVariableName19() throws JavaModelException {
10314
	this.workingCopies = new ICompilationUnit[1];
10315
	this.workingCopies[0] = getWorkingCopy(
10316
            "/Completion/src/test/Test.java",
10317
            "package test;\n"+
10318
            "public class Test {\n"+
10319
            "	void foo(){\n"+
10320
            "		Object ;\n"+
10321
            "		object = null;\n"+
10322
            "	}\n"+
10323
            "}");
10324
    
10325
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10326
    String str = this.workingCopies[0].getSource();
10327
    String completeBehind = "Object ";
10328
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10329
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10330
10030
10331
    assertResults(
10031
	assertEquals(
10332
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10032
		"should have one completion", 
10333
			requestor.getResults());
10033
		"element:CloneNotSupportedException    completion:CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10034
		"element:clone    completion:protected Object clone() throws CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
10035
		requestor.getResults());
10334
}
10036
}
10335
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
10037
public void testCompletionMethodDeclaration9() throws JavaModelException {
10336
public void testCompletionVariableName20() throws JavaModelException {
10337
	this.workingCopies = new ICompilationUnit[1];
10338
	this.workingCopies[0] = getWorkingCopy(
10339
            "/Completion/src/test/Test.java",
10340
            "package test;\n"+
10341
            "public class Test {\n"+
10342
            "	void foo(){\n"+
10343
            "		/*here*/Object ;\n"+
10344
            "		class X {\n"+
10345
            "		  Object foo1 = foo2;\n"+
10346
            "		  void bar() {\n"+
10347
            "		    foo1 = null;\n"+
10348
            "		    Object foo3 = foo4;\n"+
10349
            "		    foo3 = null;\n"+
10350
            "		  }\n"+
10351
            "		}\n"+
10352
            "		foo5 = null;\n"+
10353
            "	}\n"+
10354
            "}");
10355
    
10356
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10357
    String str = this.workingCopies[0].getSource();
10358
    String completeBehind = "/*here*/Object ";
10359
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10360
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10361
10038
10362
    assertResults(
10039
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10363
    		"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10040
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMethodDeclaration9.java");
10364
    		"foo2[VARIABLE_DECLARATION]{foo2, null, Ljava.lang.Object;, foo2, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}\n"+
10365
    		"foo4[VARIABLE_DECLARATION]{foo4, null, Ljava.lang.Object;, foo4, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}\n"+
10366
			"foo5[VARIABLE_DECLARATION]{foo5, null, Ljava.lang.Object;, foo5, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10367
			requestor.getResults());
10368
}
10369
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
10370
public void testCompletionVariableName21() throws JavaModelException {
10371
	this.workingCopies = new ICompilationUnit[1];
10372
	this.workingCopies[0] = getWorkingCopy(
10373
            "/Completion/src/test/Test.java",
10374
            "package test;\n"+
10375
            "public class Test {\n"+
10376
            "	void foo(){\n"+
10377
            "		{\n"+
10378
            "		  /*here*/Object ;\n"+
10379
            "		  foo1 = null;\n"+
10380
            "		}\n"+
10381
            "		foo2 = null;\n"+
10382
            "	}\n"+
10383
            "}");
10384
    
10385
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10386
    String str = this.workingCopies[0].getSource();
10387
    String completeBehind = "/*here*/Object ";
10388
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10389
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10390
10041
10391
    assertResults(
10042
	String str = cu.getSource();
10392
    		"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10043
	String completeBehind = "clon";
10393
			"foo1[VARIABLE_DECLARATION]{foo1, null, Ljava.lang.Object;, foo1, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10044
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10394
			requestor.getResults());
10045
	cu.codeComplete(cursorLocation, requestor);
10046
10047
	assertEquals(
10048
		"should have one completion", 
10049
		"element:CloneNotSupportedException    completion:CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10050
		"element:clone    completion:protected Object clone() throws CloneNotSupportedException    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE+ R_NON_RESTRICTED),
10051
		requestor.getResults());
10395
}
10052
}
10396
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
10053
public void testCompletionMethodThrowsClause() throws JavaModelException {
10397
public void testCompletionVariableName22() throws JavaModelException {
10054
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10398
	this.workingCopies = new ICompilationUnit[1];
10055
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMethodThrowsClause.java");
10399
	this.workingCopies[0] = getWorkingCopy(
10400
            "/Completion/src/test/Test.java",
10401
            "package test;\n"+
10402
            "public class Test {\n"+
10403
            "	void foo(){\n"+
10404
            "		Object foo1;\n"+
10405
            "		/*here*/Object ;\n"+
10406
            "		{\n"+
10407
            "		  Object foo3;\n"+
10408
            "		  foo1 = null;\n"+
10409
            "		  foo2 = null;\n"+
10410
            "		  foo3 = null;\n"+
10411
            "		}\n"+
10412
            "	}\n"+
10413
            "}");
10414
    
10415
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10416
    String str = this.workingCopies[0].getSource();
10417
    String completeBehind = "/*here*/Object ";
10418
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10419
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10420
10056
10421
    assertResults(
10057
	String str = cu.getSource();
10422
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10058
	String completeBehind = "Ex";
10423
			"foo2[VARIABLE_DECLARATION]{foo2, null, Ljava.lang.Object;, foo2, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10059
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10424
			requestor.getResults());
10060
	cu.codeComplete(cursorLocation, requestor);
10061
10062
	assertEquals(
10063
		"element:Exception    completion:Exception    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXCEPTION + R_UNQUALIFIED+ R_NON_RESTRICTED),
10064
		requestor.getResults());
10425
}
10065
}
10426
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
10066
public void testCompletionMethodThrowsClause2() throws JavaModelException {
10427
public void testCompletionVariableName23() throws JavaModelException {
10067
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10428
	this.workingCopies = new ICompilationUnit[1];
10068
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionMethodThrowsClause2.java");
10429
	this.workingCopies[0] = getWorkingCopy(
10430
            "/Completion/src/test/Test.java",
10431
            "package test;\n"+
10432
            "public class Test {\n"+
10433
            "	void foo(){\n"+
10434
            "		/*here*/Object ;\n"+
10435
            "		foo1 = null;\n"+
10436
            "		#\n"+
10437
            "	}\n"+
10438
            "}");
10439
    
10440
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10441
    String str = this.workingCopies[0].getSource();
10442
    String completeBehind = "/*here*/Object ";
10443
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10444
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10445
10069
10446
    assertResults(
10070
	String str = cu.getSource();
10447
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10071
	String completeBehind = "Ex";
10448
			"foo1[VARIABLE_DECLARATION]{foo1, null, Ljava.lang.Object;, foo1, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10072
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10449
			requestor.getResults());
10073
	cu.codeComplete(cursorLocation, requestor);
10074
10075
	assertEquals(
10076
		"element:Exception    completion:Exception    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXCEPTION+ R_NON_RESTRICTED),
10077
		requestor.getResults());
10450
}
10078
}
10451
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
10079
public void testCompletionNonEmptyToken1() throws JavaModelException {
10452
public void testCompletionVariableName24() throws JavaModelException {
10080
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10453
	this.workingCopies = new ICompilationUnit[1];
10081
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionNonEmptyToken1.java");
10454
	this.workingCopies[0] = getWorkingCopy(
10455
            "/Completion/src/test/Test.java",
10456
            "package test;\n"+
10457
            "public class Test {\n"+
10458
            "	void foo(){\n"+
10459
            "		/*here*/Object ;\n"+
10460
            "		#\n"+
10461
            "		foo1 = null;\n"+
10462
            "	}\n"+
10463
            "}");
10464
    
10465
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10466
    String str = this.workingCopies[0].getSource();
10467
    String completeBehind = "/*here*/Object ";
10468
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10469
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10470
10082
10471
    assertResults(
10083
	String str = cu.getSource();
10472
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10084
	String completeBehind = "zz";
10473
			"foo1[VARIABLE_DECLARATION]{foo1, null, Ljava.lang.Object;, foo1, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10085
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10474
			requestor.getResults());
10086
	int start = cursorLocation - 2;
10087
	int end = start + 4;
10088
	cu.codeComplete(cursorLocation, requestor);
10089
10090
	assertEquals(
10091
		"element:zzyy    completion:zzyy    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
10092
		requestor.getResultsWithPosition());
10475
}
10093
}
10476
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
10094
public void testCompletionNonStaticFieldRelevance() throws JavaModelException {
10477
public void testCompletionVariableName25() throws JavaModelException {
10095
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10478
	this.workingCopies = new ICompilationUnit[1];
10096
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionNonStaticFieldRelevance.java");
10479
	this.workingCopies[0] = getWorkingCopy(
10480
            "/Completion/src/test/Test.java",
10481
            "package test;\n"+
10482
            "public class Test {\n"+
10483
            "	void foo(){\n"+
10484
            "		/*here*/Object ;\n"+
10485
            "		#\n"+
10486
            "		foo1 = null;\n"+
10487
            "		#\n"+
10488
            "		foo2 = null;\n"+
10489
            "	}\n"+
10490
            "}");
10491
    
10492
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10493
    String str = this.workingCopies[0].getSource();
10494
    String completeBehind = "/*here*/Object ";
10495
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10496
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10497
10097
10498
    assertResults(
10098
	String str = cu.getSource();
10499
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10099
	String completeBehind = "var.Ii";
10500
			"foo1[VARIABLE_DECLARATION]{foo1, null, Ljava.lang.Object;, foo1, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}\n"+
10100
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10501
    		"foo2[VARIABLE_DECLARATION]{foo2, null, Ljava.lang.Object;, foo2, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10101
	cu.codeComplete(cursorLocation, requestor);
10102
10103
	assertEquals(
10104
			"element:Ii0    completion:Ii0    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "\n" +
10105
			"element:ii1    completion:ii1    relevance:" + (R_DEFAULT + R_INTERESTING + R_NON_STATIC+ R_NON_RESTRICTED),
10502
			requestor.getResults());
10106
			requestor.getResults());
10503
}
10107
}
10504
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
10108
/**
10505
public void testCompletionVariableName26() throws JavaModelException {
10109
 * Attempt to do completion with a null requestor
10506
	this.workingCopies = new ICompilationUnit[1];
10110
 */
10507
	this.workingCopies[0] = getWorkingCopy(
10111
public void testCompletionNullRequestor() throws JavaModelException {
10508
            "/Completion/src/test/Test.java",
10112
	try {
10509
            "package test;\n"+
10113
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindThisDotField.java");
10510
            "public class Test {\n"+
10114
		cu.codeComplete(5, (CompletionRequestor)null);
10511
            "	void foo(){\n"+
10115
	} catch (IllegalArgumentException iae) {
10512
            "		/*here*/Object ;\n"+
10116
		return;
10513
            "		#\n"+
10117
	}
10514
            "		foo1 = null;\n"+
10118
	assertTrue("Should not be able to do completion with a null requestor", false);
10515
            "		#\n"+
10119
}
10516
            "		foo2 = null;\n"+
10120
/*
10517
            "		#\n"+
10121
* http://dev.eclipse.org/bugs/show_bug.cgi?id=24565
10518
            "	}\n"+
10122
*/
10519
            "}");
10123
public void testCompletionObjectsMethodWithInterfaceReceiver() throws JavaModelException {
10520
    
10124
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10521
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10125
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionObjectsMethodWithInterfaceReceiver.java");
10522
    String str = this.workingCopies[0].getSource();
10523
    String completeBehind = "/*here*/Object ";
10524
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10525
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10526
10126
10527
    assertResults(
10127
	String str = cu.getSource();
10528
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10128
	String completeBehind = "hash";
10529
			"foo1[VARIABLE_DECLARATION]{foo1, null, Ljava.lang.Object;, foo1, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}\n"+
10129
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10530
    		"foo2[VARIABLE_DECLARATION]{foo2, null, Ljava.lang.Object;, foo2, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10130
	cu.codeComplete(cursorLocation, requestor);
10531
			requestor.getResults());
10131
10132
	assertEquals(
10133
		"element:hashCode    completion:hashCode()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_EXACT_EXPECTED_TYPE+ R_NON_RESTRICTED),
10134
		requestor.getResults());
10532
}
10135
}
10533
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
10136
/**
10534
public void testCompletionVariableName27() throws JavaModelException {
10137
 * Ensures that the code assist features works on class files with associated source.
10535
	this.workingCopies = new ICompilationUnit[1];
10138
 */
10536
	this.workingCopies[0] = getWorkingCopy(
10139
public void testCompletionOnClassFile() throws JavaModelException {
10537
            "/Completion/src/test/Test.java",
10140
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10538
            "package test;\n"+
10141
	IClassFile cu = getClassFile("Completion", "zzz.jar", "jarpack1", "X.class");
10539
            "public class Test {\n"+
10142
	
10540
            "	void foo(){\n"+
10143
	String str = cu.getSource();
10541
            "		/*here*/Object ;\n"+
10144
	String completeBehind = "Obj";
10542
            "		Object foo0 = null;\n"+
10145
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10543
            "		foo0 = null;\n"+
10146
	cu.codeComplete(cursorLocation, requestor);
10544
            "		#\n"+
10147
	assertEquals(
10545
            "		class X {\n"+
10148
		"should have one class", 
10546
            "		  Object foo1 = foo2;\n"+
10149
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
10547
            "		  void bar() {\n"+
10150
		requestor.getResults());
10548
            "		    foo1 = null;\n"+
10151
}
10549
            "		    Object foo3 = foo4;\n"+
10152
/*
10550
            "		    foo3 = null;\n"+
10153
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25890
10551
            "		  }\n"+
10154
*/
10552
            "		}\n"+
10155
public void testCompletionOnStaticMember1() throws JavaModelException {
10553
            "		foo5 = null;\n"+
10156
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10554
            "	}\n"+
10157
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionOnStaticMember1.java");
10555
            "}");
10556
    
10557
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10558
    String str = this.workingCopies[0].getSource();
10559
    String completeBehind = "/*here*/Object ";
10560
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10561
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10562
10158
10563
    assertResults(
10159
		String str = cu.getSource();
10564
    		"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10160
		String completeBehind = "var";
10565
    		"foo2[VARIABLE_DECLARATION]{foo2, null, Ljava.lang.Object;, foo2, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}\n"+
10161
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10566
    		"foo4[VARIABLE_DECLARATION]{foo4, null, Ljava.lang.Object;, foo4, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}\n"+
10162
		cu.codeComplete(cursorLocation, requestor);
10567
			"foo5[VARIABLE_DECLARATION]{foo5, null, Ljava.lang.Object;, foo5, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10163
10164
		assertEquals(
10165
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
10166
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
10568
			requestor.getResults());
10167
			requestor.getResults());
10569
}
10168
}
10570
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
10169
/*
10571
public void testCompletionVariableName28() throws JavaModelException {
10170
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25890
10572
	this.workingCopies = new ICompilationUnit[1];
10171
*/
10573
	this.workingCopies[0] = getWorkingCopy(
10172
public void testCompletionOnStaticMember2() throws JavaModelException {
10574
            "/Completion/src/test/Test.java",
10173
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10575
            "package test;\n"+
10174
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionOnStaticMember2.java");
10576
            "public class Test {\n"+
10577
            "	void foo(){\n"+
10578
            "		/*here*/Object ;\n"+
10579
            "		Object foo1 = null;\n"+
10580
            "		foo1.foo2 = null;\n"+
10581
            "		foo3.foo4 = null;\n"+
10582
            "	}\n"+
10583
            "}");
10584
    
10585
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10586
    String str = this.workingCopies[0].getSource();
10587
    String completeBehind = "/*here*/Object ";
10588
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10589
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10590
10175
10591
    assertResults(
10176
		String str = cu.getSource();
10592
    		"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10177
		String completeBehind = "method";
10593
    		"foo3[VARIABLE_DECLARATION]{foo3, null, Ljava.lang.Object;, foo3, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10178
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10179
		cu.codeComplete(cursorLocation, requestor);
10180
10181
		assertEquals(
10182
			"element:method1    completion:method1()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
10183
			"element:method2    completion:method2()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
10594
			requestor.getResults());
10184
			requestor.getResults());
10595
}
10185
}
10596
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
10186
/**
10597
public void testCompletionVariableName29() throws JavaModelException {
10187
 * Test that an out of bounds index causes an exception.
10598
	this.workingCopies = new ICompilationUnit[1];
10188
 */
10599
	this.workingCopies[0] = getWorkingCopy(
10189
public void testCompletionOutOfBounds() throws JavaModelException {
10600
            "/Completion/src/test/Test.java",
10190
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10601
            "package test;\n"+
10191
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionOutOfBounds.java");
10602
            "public class Test {\n"+
10192
	try {
10603
            "	void foo(){\n"+
10193
		cu.codeComplete(cu.getSource().length() + 1, requestor);
10604
            "		/*here*/Object ;\n"+
10194
	} catch (JavaModelException e) {
10605
            "		class X {\n"+
10195
		return;
10606
            "			void bar1() {\n"+
10196
	}
10607
            "				var1 = null;\n"+
10197
	assertTrue("should have failed", false);
10608
            "			}\n"+
10198
}
10609
            "			void bar2() {\n"+
10199
public void testCompletionPackageAndClass1() throws JavaModelException {
10610
            "				Object var2 = null;\n"+
10200
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10611
            "				var2 = null;\n"+
10201
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "z1.z2.qla0", "Qla3.java");
10612
            "			}\n"+
10613
            "			void bar3() {\n"+
10614
            "				Object var3 = null;\n"+
10615
            "				{\n"+
10616
            "					var3 = null;\n"+
10617
            "					Object var4 = null;\n"+
10618
            "				}\n"+
10619
            "				var4 = null;\n"+
10620
            "			}\n"+
10621
            "		}\n"+
10622
            "	}\n"+
10623
            "}");
10624
    
10625
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10626
    String str = this.workingCopies[0].getSource();
10627
    String completeBehind = "/*here*/Object ";
10628
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10629
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10630
10202
10631
    assertResults(
10203
	String str = cu.getSource();
10632
    		"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10204
	String completeBehind = "z1.z2.ql";
10633
    		"var1[VARIABLE_DECLARATION]{var1, null, Ljava.lang.Object;, var1, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}\n"+
10205
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10634
			"var4[VARIABLE_DECLARATION]{var4, null, Ljava.lang.Object;, var4, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10206
	cu.codeComplete(cursorLocation, requestor);
10207
10208
	assertEquals(
10209
			"element:Qla1    completion:z1.z2.Qla1    relevance:" + (R_DEFAULT + R_INTERESTING + R_QUALIFIED + R_NON_RESTRICTED) + "\n" +
10210
			"element:qla2    completion:z1.z2.qla2    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_QUALIFIED + R_NON_RESTRICTED) + "\n" +
10211
			"element:z1.z2.qla0    completion:z1.z2.qla0    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_QUALIFIED+ R_NON_RESTRICTED),
10635
			requestor.getResults());
10212
			requestor.getResults());
10636
}
10213
}
10637
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
10214
public void testCompletionPackageAndClass2() throws JavaModelException {
10638
public void testCompletionVariableName30() throws JavaModelException {
10215
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10639
	this.workingCopies = new ICompilationUnit[1];
10216
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "z1.z2.qla0", "Wla.java");
10640
	this.workingCopies[0] = getWorkingCopy(
10641
            "/Completion/src/test/Test.java",
10642
            "package test;\n"+
10643
            "public class Test {\n"+
10644
            "	public Test(){\n"+
10645
            "		Object ;\n"+
10646
            "		foo = null;\n"+
10647
            "	}\n"+
10648
            "}");
10649
    
10650
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10651
    String str = this.workingCopies[0].getSource();
10652
    String completeBehind = "Object ";
10653
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10654
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10655
10217
10656
    assertResults(
10218
	String str = cu.getSource();
10657
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10219
	String completeBehind = "z1.z2.qla0.";
10658
			"foo[VARIABLE_DECLARATION]{foo, null, Ljava.lang.Object;, foo, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10220
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10221
	cu.codeComplete(cursorLocation, requestor);
10222
10223
	assertEquals(
10224
			"element:Qla3    completion:Qla3    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "\n" +
10225
			"element:Qla4    completion:Qla4    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "\n" +
10226
			"element:Wla    completion:Wla    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
10659
			requestor.getResults());
10227
			requestor.getResults());
10660
}
10228
}
10661
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
10229
public void testCompletionPrefixFieldName1() throws JavaModelException {
10662
public void testCompletionVariableName31() throws JavaModelException {
10230
	this.wc = getWorkingCopy(
10663
	this.workingCopies = new ICompilationUnit[1];
10231
            "/Completion/src/CompletionPrefixFieldName1.java",
10664
	this.workingCopies[0] = getWorkingCopy(
10232
            "public class CompletionPrefixFieldName1 {\n"+
10665
            "/Completion/src/test/Test.java",
10233
            "	int xBar;\n"+
10666
            "package test;\n"+
10234
            "	\n"+
10667
            "public class Test {\n"+
10235
            "	class classFoo {\n"+
10668
            "	{\n"+
10236
            "		int xBar;\n"+
10669
            "		Object ;\n"+
10237
            "		\n"+
10670
            "		foo = null;\n"+
10238
            "		public void foo(){\n"+
10239
            "			xBa\n"+
10240
            "		}\n"+
10671
            "	}\n"+
10241
            "	}\n"+
10672
            "}");
10242
            "}");
10673
    
10243
    
10244
    
10674
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10245
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10675
    String str = this.workingCopies[0].getSource();
10246
    String str = this.wc.getSource();
10676
    String completeBehind = "Object ";
10247
    String completeBehind = "xBa";
10677
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10248
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10678
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10249
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10679
10250
10680
    assertResults(
10251
	assertResults(
10681
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10252
		"xBar[FIELD_REF]{CompletionPrefixFieldName1.this.xBar, LCompletionPrefixFieldName1;, I, xBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
10682
			"foo[VARIABLE_DECLARATION]{foo, null, Ljava.lang.Object;, foo, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10253
		"xBar[FIELD_REF]{xBar, LCompletionPrefixFieldName1$classFoo;, I, xBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED)+"}",
10683
			requestor.getResults());
10254
		requestor.getResults());
10684
}
10255
}
10685
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
10256
public void testCompletionPrefixFieldName2() throws JavaModelException {
10686
public void testCompletionVariableName32() throws JavaModelException {
10257
	this.wc = getWorkingCopy(
10687
	this.workingCopies = new ICompilationUnit[1];
10258
            "/Completion/src/CompletionPrefixFieldName2.java",
10688
	this.workingCopies[0] = getWorkingCopy(
10259
            "public class CompletionPrefixFieldName2 {\n"+
10689
            "/Completion/src/test/Test.java",
10260
            "	int xBar;\n"+
10690
            "package test;\n"+
10261
            "	\n"+
10691
            "public class Test {\n"+
10262
            "	class classFoo {\n"+
10692
            "	void bar(Object ) {\n"+
10263
            "		int xBar;\n"+
10693
            "		foo = null;\n"+
10264
            "		\n"+
10265
            "		public void foo(){\n"+
10266
            "			new CompletionPrefixFieldName2().xBa\n"+
10267
            "		}\n"+
10694
            "	}\n"+
10268
            "	}\n"+
10695
            "}");
10269
            "}");
10696
    
10270
    
10271
    
10697
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10272
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10698
    String str = this.workingCopies[0].getSource();
10273
    String str = this.wc.getSource();
10699
    String completeBehind = "Object ";
10274
    String completeBehind = "xBa";
10700
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10275
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10701
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10276
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10702
10277
10703
    assertResults(
10278
	assertResults(
10704
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10279
		"xBar[FIELD_REF]{xBar, LCompletionPrefixFieldName2;, I, xBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED)+"}",
10705
			"foo[VARIABLE_DECLARATION]{foo, null, Ljava.lang.Object;, foo, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10280
		requestor.getResults());
10706
			requestor.getResults());
10707
}
10281
}
10708
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=162743
10282
public void testCompletionPrefixMethodName1() throws JavaModelException {
10709
public void testCompletionVariableName33() throws JavaModelException {
10283
	this.wc = getWorkingCopy(
10710
	this.workingCopies = new ICompilationUnit[1];
10284
            "/Completion/src/CompletionPrefixMethodName1.java",
10711
	this.workingCopies[0] = getWorkingCopy(
10285
            "public class CompletionPrefixMethodName1 {\n"+
10712
            "/Completion/src/test/Test.java",
10286
           "	int xBar(){}\n"+
10713
            "package test;\n"+
10287
           "	\n"+
10714
            "public class Test {\n"+
10288
           "	class classFoo {\n"+
10715
            "	void bar() {\n"+
10289
           "		int xBar(){}\n"+
10716
            "		/**/int v\n"+
10290
           "		\n"+
10717
            "		variable = null;\n"+
10291
           "		public void foo(){\n"+
10718
            "		variable = null;\n"+
10292
           "			xBa\n"+
10719
            "		variable = null;\n"+
10293
           "		}\n"+
10720
            "	}\n"+
10294
           "	}\n"+
10721
            "}");
10295
           "}");
10296
    
10722
    
10297
    
10723
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10298
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10724
    String str = this.workingCopies[0].getSource();
10299
    String str = this.wc.getSource();
10725
    String completeBehind = "/**/int v";
10300
    String completeBehind = "xBa";
10726
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10301
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10727
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10302
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10728
10303
10729
    assertResults(
10304
	assertResults(
10730
			"vI[VARIABLE_DECLARATION]{vI, null, I, vI, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10305
		"xBar[METHOD_REF]{CompletionPrefixMethodName1.this.xBar(), LCompletionPrefixMethodName1;, ()I, xBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
10731
			"variable[VARIABLE_DECLARATION]{variable, null, I, variable, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10306
		"xBar[METHOD_REF]{xBar(), LCompletionPrefixMethodName1$classFoo;, ()I, xBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED)+"}",
10732
			requestor.getResults());
10307
		requestor.getResults());
10733
}
10308
}
10734
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=162968
10309
public void testCompletionPrefixMethodName2() throws JavaModelException {
10735
public void testCompletionVariableName34() throws JavaModelException {
10310
	this.wc = getWorkingCopy(
10736
	this.workingCopies = new ICompilationUnit[1];
10311
            "/Completion/src/CompletionPrefixMethodName2.java",
10737
	this.workingCopies[0] = getWorkingCopy(
10312
            "public class CompletionPrefixMethodName2 {\n"+
10738
            "/Completion/src/test/Test.java",
10313
            "	int xBar(){}\n"+
10739
            "package test;\n"+
10314
            "	\n"+
10740
            "public class Test {\n"+
10315
            "	class classFoo {\n"+
10741
            "	int vDefined;\n"+
10316
            "		int xBar(){}\n"+
10742
            "	void bar() {\n"+
10317
            "		\n"+
10743
            "		/**/int v\n"+
10318
            "		public void foo(){\n"+
10744
            "		System.out.println(vUnknown);\n"+
10319
            "			new CompletionPrefixMethodName2().xBa\n"+
10745
            "		System.out.println(vUnknown);\n"+
10320
            "		}\n"+
10746
            "	}\n"+
10321
            "	}\n"+
10747
            "}");
10322
            "}");
10748
    
10323
    
10324
    
10749
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10325
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10750
    String str = this.workingCopies[0].getSource();
10326
    String str = this.wc.getSource();
10751
    String completeBehind = "/**/int v";
10327
    String completeBehind = "xBa";
10752
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10328
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10753
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10329
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10754
10755
    assertResults(
10756
			"vI[VARIABLE_DECLARATION]{vI, null, I, vI, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
10757
			"vUnknown[VARIABLE_DECLARATION]{vUnknown, null, I, vUnknown, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
10758
			requestor.getResults());
10759
}
10760
public void testCompletionNonEmptyToken1() throws JavaModelException {
10761
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10762
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionNonEmptyToken1.java");
10763
10764
	String str = cu.getSource();
10765
	String completeBehind = "zz";
10766
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10767
	int start = cursorLocation - 2;
10768
	int end = start + 4;
10769
	cu.codeComplete(cursorLocation, requestor);
10770
10771
	assertEquals(
10772
		"element:zzyy    completion:zzyy    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
10773
		requestor.getResultsWithPosition());
10774
}
10775
public void testCompletionEmptyToken1() throws JavaModelException {
10776
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10777
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionEmptyToken1.java");
10778
10779
	String str = cu.getSource();
10780
	String completeBehind = "zz";
10781
	// completion is just at start of 'zz'
10782
	int cursorLocation = str.lastIndexOf(completeBehind);
10783
	int start = cursorLocation;
10784
	int end = start + 4;
10785
	cu.codeComplete(cursorLocation, requestor);
10786
10330
10787
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
10331
	assertResults(
10788
		assertEquals(
10332
		"xBar[METHOD_REF]{xBar(), LCompletionPrefixMethodName2;, ()I, xBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED)+"}",
10789
			"element:clone    completion:clone()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10333
		requestor.getResults());
10790
			"element:equals    completion:equals()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10791
			"element:finalize    completion:finalize()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10792
			"element:foo    completion:foo()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10793
			"element:getClass    completion:getClass()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10794
			"element:hashCode    completion:hashCode()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10795
			"element:notify    completion:notify()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10796
			"element:notifyAll    completion:notifyAll()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10797
			"element:toString    completion:toString()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10798
			"element:wait    completion:wait()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10799
			"element:wait    completion:wait()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10800
			"element:wait    completion:wait()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10801
			"element:zzyy    completion:zzyy    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
10802
			requestor.getResultsWithPosition());
10803
	} else {
10804
		assertEquals(
10805
			"element:CompletionEmptyToken1    completion:CompletionEmptyToken1    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10806
			"element:clone    completion:clone()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10807
			"element:equals    completion:equals()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10808
			"element:finalize    completion:finalize()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10809
			"element:foo    completion:foo()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10810
			"element:getClass    completion:getClass()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10811
			"element:hashCode    completion:hashCode()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10812
			"element:notify    completion:notify()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10813
			"element:notifyAll    completion:notifyAll()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10814
			"element:toString    completion:toString()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10815
			"element:wait    completion:wait()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10816
			"element:wait    completion:wait()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10817
			"element:wait    completion:wait()    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10818
			"element:zzyy    completion:zzyy    position:["+start+","+end+"]    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
10819
			requestor.getResultsWithPosition());
10820
	}
10821
}
10334
}
10822
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=100808
10335
public void testCompletionPrefixMethodName3() throws JavaModelException {
10823
public void testCompletionEmptyToken2() throws JavaModelException {
10336
	this.wc = getWorkingCopy(
10824
    this.wc = getWorkingCopy(
10337
            "/Completion/src/CompletionPrefixMethodName2.java",
10825
            "/Completion/src/testCompletionEmptyToken2/Test.java",
10338
            "public class CompletionPrefixMethodName3 {\n"+
10826
            "package testCompletionEmptyToken2.");
10339
            "	int xBar(int a, int b){}\n"+
10340
            "	\n"+
10341
            "	class classFoo {\n"+
10342
            "		int xBar(int a, int b){}\n"+
10343
            "		\n"+
10344
            "		public void foo(){\n"+
10345
            "			xBar(1,\n"+
10346
            "		}\n"+
10347
            "	}\n"+
10348
            "}");
10827
    
10349
    
10828
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true);
10829
    
10350
    
10351
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10830
    String str = this.wc.getSource();
10352
    String str = this.wc.getSource();
10831
    String completeBehind = "testCompletionEmptyToken2.";
10353
    String completeBehind = "xBar(1,";
10832
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10354
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10833
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10355
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10834
10356
10835
    int start = str.lastIndexOf(completeBehind);
10836
    int end = start + completeBehind.length();
10837
    
10838
    assertResults(
10839
            "expectedTypesSignatures=null\n"+
10840
            "expectedTypesKeys=null",
10841
            requestor.getContext());
10842
    
10843
	assertResults(
10844
            "testCompletionEmptyToken2[PACKAGE_REF]{testCompletionEmptyToken2, testCompletionEmptyToken2, null, null, null, ["+start+", "+end+"], " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}",
10845
            requestor.getResults());
10846
}
10847
public void testCompletionFindSecondaryType1() throws JavaModelException {
10848
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10849
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionFindSecondaryType1.java");
10850
10851
	String str = cu.getSource();
10852
	String completeBehind = "/**/Secondary";
10853
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10854
	cu.codeComplete(cursorLocation, requestor);
10855
10856
	assertEquals(
10857
		"element:SecondaryType1    completion:SecondaryType1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10858
		"element:SecondaryType2    completion:SecondaryType2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
10859
		requestor.getResults());
10860
}
10861
public void testCompletionLocalType1() throws JavaModelException {
10862
	this.workingCopies = new ICompilationUnit[1];
10863
	this.workingCopies[0] = getWorkingCopy(
10864
		"/Completion/src/CompletionLocalType1.java",
10865
		"public class CompletionLocalType1 {\n" +
10866
		"	void foo() {\n" +
10867
		"		class ZZZZ {\n" +
10868
		"			ZZZ\n" +
10869
		"		}\n" +
10870
		"	}\n" +
10871
		"}");
10872
	
10873
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10874
	String str = this.workingCopies[0].getSource();
10875
	String completeBehind = "ZZZ";
10876
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10877
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10878
10879
	assertResults(
10357
	assertResults(
10880
			"ZZZ[POTENTIAL_METHOD_DECLARATION]{ZZZ, LZZZZ;, ()V, ZZZ, null, "+(R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED)+"}\n"+
10358
		"xBar[METHOD_REF]{CompletionPrefixMethodName3.this.xBar(1,, LCompletionPrefixMethodName3;, (II)I, xBar, (a, b), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME+ R_NON_RESTRICTED)+"}\n"+
10881
			"ZZZZ[TYPE_REF]{ZZZZ, , LZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}",
10359
		"xBar[METHOD_REF]{, LCompletionPrefixMethodName3$classFoo;, (II)I, xBar, (a, b), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
10882
			requestor.getResults());
10883
}
10884
public void testCompletionType1() throws JavaModelException {
10885
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10886
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionType1.java");
10887
10888
	String str = cu.getSource();
10889
	String completeBehind = "CT1";
10890
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10891
	cu.codeComplete(cursorLocation, requestor);
10892
10893
	assertEquals(
10894
		"element:CT1    completion:CT1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
10895
		"element:CT1    completion:q2.CT1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME+ R_NON_RESTRICTED),
10896
		requestor.getResults());
10360
		requestor.getResults());
10897
}
10361
}
10898
public void testCompletionQualifiedAllocationType1() throws JavaModelException {
10362
public void testCompletionQualifiedAllocationType1() throws JavaModelException {
Lines 10913-11055 Link Here
10913
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10377
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10914
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10378
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10915
10379
10916
    assertResults(
10380
    assertResults(
10917
		"CompletionQualifiedAllocationType1.YYY[TYPE_REF]{YYY, , LCompletionQualifiedAllocationType1$YYY;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME+ R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
10381
		"CompletionQualifiedAllocationType1.YYY[TYPE_REF]{YYY, , LCompletionQualifiedAllocationType1$YYY;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME+ R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
10382
		requestor.getResults());
10383
}
10384
/*
10385
* http://dev.eclipse.org/bugs/show_bug.cgi?id=26677
10386
*/
10387
public void testCompletionQualifiedExpectedType() throws JavaModelException {
10388
	this.wc = getWorkingCopy(
10389
            "/Completion/src/test/CompletionQualifiedExpectedType.java",
10390
            "import pack1.PX;\n"+
10391
            "\n"+
10392
            "public class CompletionQualifiedExpectedType {\n"+
10393
            "	void foo() {\n"+
10394
            "		pack2.PX var = new \n"+
10395
            "	}\n"+
10396
            "}");
10397
    
10398
    
10399
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10400
    String str = this.wc.getSource();
10401
    String completeBehind = "new ";
10402
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10403
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10404
10405
    if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
10406
    	assertResults(
10407
	            "PX[TYPE_REF]{pack2.PX, pack2, Lpack2.PX;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE+ R_NON_RESTRICTED)+ "}",
10408
				requestor.getResults());
10409
    } else {
10410
	    assertResults(
10411
	            "CompletionQualifiedExpectedType[TYPE_REF]{CompletionQualifiedExpectedType, test, Ltest.CompletionQualifiedExpectedType;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
10412
				"PX[TYPE_REF]{pack2.PX, pack2, Lpack2.PX;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE+ R_NON_RESTRICTED)+ "}",
10413
				requestor.getResults());
10414
    }
10415
}
10416
/**
10417
 * Complete the type "Repeated", "RepeatedOtherType from "Repeated".
10418
 */
10419
public void testCompletionRepeatedType() throws JavaModelException {
10420
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10421
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionRepeatedType.java");
10422
10423
	String str = cu.getSource();
10424
	String completeBehind = "/**/CompletionRepeated";
10425
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10426
	cu.codeComplete(cursorLocation, requestor);
10427
	assertEquals(
10428
		"should have two types",
10429
		"element:CompletionRepeatedOtherType    completion:CompletionRepeatedOtherType    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10430
		"element:CompletionRepeatedType    completion:CompletionRepeatedType    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
10431
		requestor.getResults());	
10432
}
10433
/*
10434
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25591
10435
*/
10436
public void testCompletionReturnInInitializer() throws JavaModelException {
10437
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10438
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionReturnInInitializer.java");
10439
10440
	String str = cu.getSource();
10441
	String completeBehind = "eq";
10442
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10443
	cu.codeComplete(cursorLocation, requestor);
10444
10445
	assertEquals(
10446
		"element:equals    completion:equals()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
10918
		requestor.getResults());
10447
		requestor.getResults());
10919
}
10448
}
10920
public void testCompletionClassLiteralAfterAnonymousType1() throws JavaModelException {
10449
public void testCompletionReturnStatementIsParent1() throws JavaModelException {
10921
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10450
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10922
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionClassLiteralAfterAnonymousType1.java");
10451
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionReturnStatementIsParent1.java");
10923
10452
10924
	String str = cu.getSource();
10453
	String str = cu.getSource();
10925
	String completeBehind = "double.";
10454
	String completeBehind = "zz";
10926
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10455
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10927
	cu.codeComplete(cursorLocation, requestor);
10456
	cu.codeComplete(cursorLocation, requestor);
10928
10457
10929
	assertEquals(
10458
	assertEquals(
10930
		"element:class    completion:class    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED),
10459
		"element:zz00    completion:zz00    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10460
		"element:zz00M    completion:zz00M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10461
		"element:zz01    completion:zz01    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10462
		"element:zz01M    completion:zz01M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10463
		"element:zz02    completion:zz02    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10464
		"element:zz02M    completion:zz02M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10465
		"element:zz10    completion:zz10    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10466
		"element:zz10M    completion:zz10M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10467
		"element:zz11    completion:zz11    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10468
		"element:zz11M    completion:zz11M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10469
		"element:zz12    completion:zz12    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10470
		"element:zz12M    completion:zz12M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10471
		"element:zz20    completion:zz20    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10472
		"element:zz20M    completion:zz20M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10473
		"element:zz21    completion:zz21    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10474
		"element:zz21M    completion:zz21M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10475
		"element:zz22    completion:zz22    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10476
		"element:zz22M    completion:zz22M()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10477
		"element:zzOb    completion:zzOb    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10478
		"element:zzObM    completion:zzObM()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
10931
		requestor.getResults());
10479
		requestor.getResults());
10932
}
10480
}
10933
public void testCompletionArraysCloneMethod() throws JavaModelException {
10481
public void testCompletionReturnStatementIsParent2() throws JavaModelException {
10934
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10482
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10935
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionArraysCloneMethod.java");
10483
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionReturnStatementIsParent2.java");
10936
10484
10937
	String str = cu.getSource();
10485
	String str = cu.getSource();
10938
	String completeBehind = ".cl";
10486
	String completeBehind = "xx";
10939
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10487
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10940
	cu.codeComplete(cursorLocation, requestor);
10488
	cu.codeComplete(cursorLocation, requestor);
10941
10489
10942
	assertEquals(
10490
	assertEquals(
10943
		"element:clone    completion:clone()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
10491
		"element:XX00    completion:XX00    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10492
		"element:XX01    completion:XX01    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10493
		"element:XX02    completion:XX02    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10494
		"element:XX10    completion:XX10    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10495
		"element:XX11    completion:XX11    relevance:"+(R_DEFAULT + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10496
		"element:XX12    completion:XX12    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10497
		"element:XX20    completion:XX20    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10498
		"element:XX21    completion:XX21    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
10499
		"element:XX22    completion:XX22    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
10944
		requestor.getResults());
10500
		requestor.getResults());
10945
}
10501
}
10946
public void testCompletionAbstractMethod1() throws JavaModelException {
10502
/*
10947
	this.wc = getWorkingCopy(
10503
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=66908
10948
            "/Completion/src/CompletionAbstractMethod1.java",
10504
 */
10949
            "public class CompletionAbstractMethod1 {\n" +
10505
public void testCompletionSameClass() throws JavaModelException {
10950
            "	abstract class A {\n" +
10506
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
10951
            "		abstract void foo();\n" +
10507
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionSameClass.java");
10952
            "	}\n" +
10953
            "	class B extends A {\n" +
10954
            "		void foo{} {}\n" +
10955
            "		void bar() {\n" +
10956
            "			super.fo\n" +
10957
            "		}\n" +
10958
            "	}\n" +
10959
            "}");
10960
    
10961
    
10962
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10963
    String str = this.wc.getSource();
10964
    String completeBehind = "fo";
10965
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10966
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10967
10508
10968
    assertResults(
10509
	String str = cu.getSource();
10969
            "",
10510
	String completeBehind = "(CompletionSameClas";
10970
            requestor.getResults());
10511
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
10971
}
10512
	cu.codeComplete(cursorLocation, requestor);
10972
public void testCompletionAbstractMethod2() throws JavaModelException {
10973
	this.wc = getWorkingCopy(
10974
            "/Completion/src/CompletionAbstractMethod2.java",
10975
            "public class CompletionAbstractMethod2 {\n" +
10976
            "	abstract class A {\n" +
10977
            "		abstract void foo();\n" +
10978
            "	}\n" +
10979
            "	class B extends A {\n" +
10980
            "		void foo{} {}\n" +
10981
            "		void bar() {\n" +
10982
            "			this.fo\n" +
10983
            "		}\n" +
10984
            "	}\n" +
10985
            "}");
10986
    
10987
    
10988
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10989
    String str = this.wc.getSource();
10990
    String completeBehind = "fo";
10991
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10992
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10993
10513
10994
    assertResults(
10514
	assertEquals(
10995
           "foo[METHOD_REF]{foo(), LCompletionAbstractMethod2$A;, ()V, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED) + "}",
10515
			"element:CompletionSameClass    completion:CompletionSameClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
10996
           requestor.getResults());
10516
			requestor.getResults());
10997
}
10517
}
10998
public void testCompletionAbstractMethod3() throws JavaModelException {
10518
public void testCompletionSameSuperClass() throws JavaModelException {
10999
	this.wc = getWorkingCopy(
10519
	this.wc = getWorkingCopy(
11000
            "/Completion/src/CompletionAbstractMethod3.java",
10520
            "/Completion/src/CompletionSameSuperClass.java",
11001
            "public class CompletionAbstractMethod3 {\n" +
10521
            "public class CompletionSameSuperClass extends A {\n" +
11002
            "	abstract class A {\n" +
10522
            "	class Inner extends A {\n" +
11003
            "		abstract void foo();\n" +
10523
            "		void foo(int bar){\n" +
11004
            "	}\n" +
10524
            "			bar\n" +
11005
            "	class B extends A {\n" +
11006
            "		void bar() {\n" +
11007
            "			this.fo\n" +
11008
            "		}\n" +
10525
            "		}\n" +
11009
            "	}\n" +
10526
            "	}	\n" +
11010
            "}");
10527
            "}");
11011
    
10528
    
11012
    
10529
    
11013
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10530
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11014
    String str = this.wc.getSource();
10531
    String str = this.wc.getSource();
11015
    String completeBehind = "fo";
10532
    String completeBehind = "bar";
11016
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10533
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11017
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10534
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11018
10535
11019
    assertResults(
10536
	assertResults(
11020
           "foo[METHOD_REF]{foo(), LCompletionAbstractMethod3$A;, ()V, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED)+"}",
10537
		"bar[FIELD_REF]{CompletionSameSuperClass.this.bar, LA;, I, bar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}\n"+
11021
           requestor.getResults());
10538
		"bar[FIELD_REF]{this.bar, LA;, I, bar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}\n"+
10539
		"bar[METHOD_REF]{CompletionSameSuperClass.this.bar(), LA;, ()V, bar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}\n"+
10540
		"bar[LOCAL_VARIABLE_REF]{bar, null, I, bar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n"+
10541
		"bar[METHOD_REF]{bar(), LA;, ()V, bar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
10542
		requestor.getResults());
10543
}
10544
public void testCompletionStaticMethod1() throws JavaModelException {
10545
	ICompilationUnit aType = null;
10546
	try {
10547
		aType = getWorkingCopy(
10548
	            "/Completion/src/TypeWithAMethodAndAStaticMethod .java",
10549
	            "public class TypeWithAMethodAndAStaticMethod {\n"+
10550
	            "	public static void foo(){}\n"+
10551
	            "	public void foo0(){}\n"+
10552
	            "}");
10553
			
10554
		this.wc = getWorkingCopy(
10555
	            "/Completion/src/CompletionStaticMethod1.java",
10556
	            "public class CompletionStaticMethod1 extends TypeWithAMethodAndAStaticMethod {\n"+
10557
	            "	void bar(){\n"+
10558
	            "		new TypeWithAMethodAndAStaticMethod(){\n"+
10559
	            "			class Inner1 extends TypeWithAMethodAndAStaticMethod {\n"+
10560
	            "				void bar(){\n"+
10561
	            "					foo\n"+
10562
	            "				}\n"+
10563
	            "			}\n"+
10564
	            "		};\n"+
10565
	            "	}\n"+
10566
	            "	\n"+
10567
	            "}");
10568
	    
10569
	    
10570
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10571
	    String str = this.wc.getSource();
10572
	    String completeBehind = "foo";
10573
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10574
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10575
	
10576
		assertResults(
10577
				"foo0[METHOD_REF]{CompletionStaticMethod1.this.foo0(), LTypeWithAMethodAndAStaticMethod;, ()V, foo0, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
10578
				"foo0[METHOD_REF]{foo0(), LTypeWithAMethodAndAStaticMethod;, ()V, foo0, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}\n" +
10579
				"foo[METHOD_REF]{CompletionStaticMethod1.foo(), LTypeWithAMethodAndAStaticMethod;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
10580
				"foo[METHOD_REF]{foo(), LTypeWithAMethodAndAStaticMethod;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_NAME + R_NON_RESTRICTED) + "}",
10581
				requestor.getResults());
10582
	} finally {
10583
		if(aType != null) {
10584
			aType.discardWorkingCopy();
10585
		}
10586
	}
10587
}
10588
public void testCompletionStaticMethodDeclaration1() throws JavaModelException {
10589
	ICompilationUnit aType = null;
10590
	try {
10591
		aType = getWorkingCopy(
10592
	            "/Completion/src/TypeWithAMethodAndAStaticMethod .java",
10593
	            "public class TypeWithAMethodAndAStaticMethod {\n"+
10594
	            "	public static void foo(){}\n"+
10595
	            "	public void foo0(){}\n"+
10596
	            "}");
10597
		
10598
		this.wc = getWorkingCopy(
10599
	            "/Completion/src/CompletionStaticMethodDeclaration1.java",
10600
	            "public class CompletionStaticMethodDeclaration1 extends TypeWithAMethodAndAStaticMethod {\n"+
10601
	            "	foo\n"+
10602
	            "}");
10603
	    
10604
	    
10605
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10606
	    String str = this.wc.getSource();
10607
	    String completeBehind = "foo";
10608
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10609
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10610
	
10611
		assertResults(
10612
				"foo[POTENTIAL_METHOD_DECLARATION]{foo, LCompletionStaticMethodDeclaration1;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
10613
				"foo0[METHOD_DECLARATION]{public void foo0(), LTypeWithAMethodAndAStaticMethod;, ()V, foo0, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED) + "}",
10614
				requestor.getResults());
10615
	} finally {
10616
		if(aType != null) {
10617
			aType.discardWorkingCopy();
10618
		}
10619
	}
10620
}
10621
public void testCompletionStaticMethodDeclaration2() throws JavaModelException {
10622
	ICompilationUnit aType = null;
10623
	try {
10624
		aType = getWorkingCopy(
10625
	            "/Completion/src/TypeWithAMethodAndAStaticMethod .java",
10626
	            "public class TypeWithAMethodAndAStaticMethod {\n"+
10627
	            "	public static void foo(){}\n"+
10628
	            "	public void foo0(){}\n"+
10629
	            "}");
10630
			
10631
		this.wc = getWorkingCopy(
10632
	            "/Completion/src/CompletionStaticMethodDeclaration2.java",
10633
	            "public class CompletionStaticMethodDeclaration2 {\n" +
10634
	            "	class Inner1 extends TypeWithAMethodAndAStaticMethod {\n" +
10635
	            "		foo\n" +
10636
	            "	}\n" +
10637
	            "}");
10638
	    
10639
	    
10640
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10641
	    String str = this.wc.getSource();
10642
	    String completeBehind = "foo";
10643
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10644
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10645
	
10646
		assertResults(
10647
				"foo[POTENTIAL_METHOD_DECLARATION]{foo, LCompletionStaticMethodDeclaration2$Inner1;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
10648
				"foo0[METHOD_DECLARATION]{public void foo0(), LTypeWithAMethodAndAStaticMethod;, ()V, foo0, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED) + "}",
10649
				requestor.getResults());
10650
	} finally {
10651
		if(aType != null) {
10652
			aType.discardWorkingCopy();
10653
		}
10654
	}
11022
}
10655
}
11023
public void testCompletionAbstractMethod4() throws JavaModelException {
10656
public void testCompletionStaticMethodDeclaration3() throws JavaModelException {
11024
	this.wc = getWorkingCopy(
10657
	ICompilationUnit aType = null;
11025
            "/Completion/src/CompletionAbstractMethod4.java",
10658
	try {
11026
            "public class CompletionAbstractMethod1 {\n" +
10659
		aType = getWorkingCopy(
11027
            "	class A {\n" +
10660
	            "/Completion/src/TypeWithAMethodAndAStaticMethod .java",
11028
            "		void foo(){}\n" +
10661
	            "public class TypeWithAMethodAndAStaticMethod {\n"+
11029
            "	}\n" +
10662
	            "	public static void foo(){}\n"+
11030
            "	abstract class B extends A {\n" +
10663
	            "	public void foo0(){}\n"+
11031
            "		abstract void foo();\n" +
10664
	            "}");
11032
            "	}\n" +
10665
			
11033
            "	class C extends B {\n" +
10666
		this.wc = getWorkingCopy(
11034
            "		void foo{} {}\n" +
10667
	            "/Completion/src/CompletionStaticMethodDeclaration3.java",
11035
            "		void bar() {\n" +
10668
	            "public class CompletionStaticMethodDeclaration3 {\n" +
11036
            "			super.fo\n" +
10669
	            "	static class Inner1 extends TypeWithAMethodAndAStaticMethod {\n" +
11037
            "		}\n" +
10670
	            "		foo\n" +
11038
            "	}\n" +
10671
	            "	}\n" +
11039
            "}");
10672
	            "}");
11040
    
10673
	    
11041
    
10674
	    
11042
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10675
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11043
    String str = this.wc.getSource();
10676
	    String str = this.wc.getSource();
11044
    String completeBehind = "fo";
10677
	    String completeBehind = "foo";
11045
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10678
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11046
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10679
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11047
10680
	
11048
    assertResults(
10681
		assertResults(
11049
           "",
10682
				"foo[POTENTIAL_METHOD_DECLARATION]{foo, LCompletionStaticMethodDeclaration3$Inner1;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
11050
           requestor.getResults());
10683
				"foo0[METHOD_DECLARATION]{public void foo0(), LTypeWithAMethodAndAStaticMethod;, ()V, foo0, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED) + "}",
10684
				requestor.getResults());
10685
	} finally {
10686
		if(aType != null) {
10687
			aType.discardWorkingCopy();
10688
		}
10689
	}
11051
}
10690
}
11052
public void testCompletionStaticMethodDeclaration1() throws JavaModelException {
10691
public void testCompletionStaticMethodDeclaration4() throws JavaModelException {
11053
	ICompilationUnit aType = null;
10692
	ICompilationUnit aType = null;
11054
	try {
10693
	try {
11055
		aType = getWorkingCopy(
10694
		aType = getWorkingCopy(
Lines 11058-11068 Link Here
11058
	            "	public static void foo(){}\n"+
10697
	            "	public static void foo(){}\n"+
11059
	            "	public void foo0(){}\n"+
10698
	            "	public void foo0(){}\n"+
11060
	            "}");
10699
	            "}");
11061
		
10700
			
11062
		this.wc = getWorkingCopy(
10701
		this.wc = getWorkingCopy(
11063
	            "/Completion/src/CompletionStaticMethodDeclaration1.java",
10702
	            "/Completion/src/CompletionStaticMethodDeclaration4.java",
11064
	            "public class CompletionStaticMethodDeclaration1 extends TypeWithAMethodAndAStaticMethod {\n"+
10703
	            "public class CompletionStaticMethodDeclaration4 {\n" +
11065
	            "	foo\n"+
10704
	            "	void bar() {\n" +
10705
	            "		class Local1 extends TypeWithAMethodAndAStaticMethod {\n" +
10706
	            "			foo\n" +
10707
	            "		}\n" +
10708
	            "	}\n" +
11066
	            "}");
10709
	            "}");
11067
	    
10710
	    
11068
	    
10711
	    
Lines 11073-11079 Link Here
11073
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10716
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11074
	
10717
	
11075
		assertResults(
10718
		assertResults(
11076
				"foo[POTENTIAL_METHOD_DECLARATION]{foo, LCompletionStaticMethodDeclaration1;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
10719
				"foo[POTENTIAL_METHOD_DECLARATION]{foo, LLocal1;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
11077
				"foo0[METHOD_DECLARATION]{public void foo0(), LTypeWithAMethodAndAStaticMethod;, ()V, foo0, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED) + "}",
10720
				"foo0[METHOD_DECLARATION]{public void foo0(), LTypeWithAMethodAndAStaticMethod;, ()V, foo0, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED) + "}",
11078
				requestor.getResults());
10721
				requestor.getResults());
11079
	} finally {
10722
	} finally {
Lines 11082-11088 Link Here
11082
		}
10725
		}
11083
	}
10726
	}
11084
}
10727
}
11085
public void testCompletionStaticMethodDeclaration2() throws JavaModelException {
10728
public void testCompletionStaticMethodDeclaration5() throws JavaModelException {
11086
	ICompilationUnit aType = null;
10729
	ICompilationUnit aType = null;
11087
	try {
10730
	try {
11088
		aType = getWorkingCopy(
10731
		aType = getWorkingCopy(
Lines 11093-12353 Link Here
11093
	            "}");
10736
	            "}");
11094
			
10737
			
11095
		this.wc = getWorkingCopy(
10738
		this.wc = getWorkingCopy(
11096
	            "/Completion/src/CompletionStaticMethodDeclaration2.java",
10739
	            "/Completion/src/CompletionStaticMethodDeclaration5.java",
11097
	            "public class CompletionStaticMethodDeclaration2 {\n" +
10740
	            "public class CompletionStaticMethodDeclaration5 {\n"+
11098
	            "	class Inner1 extends TypeWithAMethodAndAStaticMethod {\n" +
10741
	            "	void bar() {\n"+
11099
	            "		foo\n" +
10742
	            "		static class Local1 extends TypeWithAMethodAndAStaticMethod {\n"+
10743
	            "			foo\n"+
10744
	            "		}\n"+
10745
	            "	}\n"+
10746
	            "}");
10747
	    
10748
	    
10749
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10750
	    String str = this.wc.getSource();
10751
	    String completeBehind = "foo";
10752
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10753
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10754
	
10755
		assertResults(
10756
				"foo[POTENTIAL_METHOD_DECLARATION]{foo, LLocal1;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
10757
				"foo0[METHOD_DECLARATION]{public void foo0(), LTypeWithAMethodAndAStaticMethod;, ()V, foo0, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED) + "}",
10758
				requestor.getResults());
10759
	} finally {
10760
		if(aType != null) {
10761
			aType.discardWorkingCopy();
10762
		}
10763
	}
10764
}
10765
public void testCompletionStaticMethodDeclaration6() throws JavaModelException {
10766
	ICompilationUnit aType = null;
10767
	try {
10768
		aType = getWorkingCopy(
10769
	            "/Completion/src/TypeWithAMethodAndAStaticMethod .java",
10770
	            "public class TypeWithAMethodAndAStaticMethod {\n"+
10771
	            "	public static void foo(){}\n"+
10772
	            "	public void foo0(){}\n"+
10773
	            "}");
10774
			
10775
		this.wc = getWorkingCopy(
10776
	            "/Completion/src/CompletionStaticMethodDeclaration6.java",
10777
	            "public class CompletionStaticMethodDeclaration6 {\n"+
10778
	            "	void bar() {\n"+
10779
	            "		new TypeWithAMethodAndAStaticMethod() {\n"+
10780
	            "			foo\n"+
10781
	            "		};\n"+
10782
	            "	}\n"+
10783
	            "}");
10784
	    
10785
	    
10786
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10787
	    String str = this.wc.getSource();
10788
	    String completeBehind = "foo";
10789
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10790
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10791
	
10792
		assertResults(
10793
				"foo[POTENTIAL_METHOD_DECLARATION]{foo, LTypeWithAMethodAndAStaticMethod;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
10794
				"foo0[METHOD_DECLARATION]{public void foo0(), LTypeWithAMethodAndAStaticMethod;, ()V, foo0, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED) + "}",
10795
				requestor.getResults());
10796
	} finally {
10797
		if(aType != null) {
10798
			aType.discardWorkingCopy();
10799
		}
10800
	}
10801
}
10802
public void testCompletionSuperType() throws JavaModelException {
10803
	ICompilationUnit superClass = null;
10804
	try {
10805
		superClass = getWorkingCopy(
10806
	            "/Completion/src/CompletionSuperClass.java",
10807
	            "public class CompletionSuperClass{\n" +
10808
	            "	public class Inner {}\n" +
10809
	            "	public int eqFoo(int a,Object b){\n" +
10810
	            "		return 1;\n" +
10811
	            "	}\n" +
10812
	            "}");
10813
		
10814
		this.wc = getWorkingCopy(
10815
	            "/Completion/src/CompletionSuperType.java",
10816
	            "public class CompletionSuperType extends CompletionSuperClass.");
10817
	    
10818
	    
10819
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10820
	    String str = this.wc.getSource();
10821
	    String completeBehind = "CompletionSuperClass.";
10822
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10823
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10824
	
10825
		assertResults(
10826
			"CompletionSuperClass.Inner[TYPE_REF]{Inner, , LCompletionSuperClass$Inner;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_CLASS+ R_NON_RESTRICTED)+"}",
10827
			requestor.getResults());
10828
	} finally {
10829
		if(superClass != null) {
10830
			superClass.discardWorkingCopy();
10831
		}
10832
	}
10833
}
10834
public void testCompletionSuperType2() throws JavaModelException {
10835
	ICompilationUnit superClass = null;
10836
	ICompilationUnit superClass2 = null;
10837
	ICompilationUnit superInterface = null;
10838
	ICompilationUnit superInterface2 = null;
10839
	try {
10840
		superClass = getWorkingCopy(
10841
	            "/Completion/src/CompletionSuperClass.java",
10842
	            "public class CompletionSuperClass{\n" +
10843
	            "	public class Inner {}\n" +
10844
	            "	public int eqFoo(int a,Object b){\n" +
10845
	            "		return 1;\n" +
10846
	            "	}\n" +
10847
	            "}");
10848
		
10849
		superClass2 = getWorkingCopy(
10850
	            "/Completion/src/CompletionSuperClass2.java",
10851
	            "public class CompletionSuperClass2 {\n" +
10852
	            "	public class InnerClass {}\n" +
10853
	            "	public interface InnerInterface {}\n" +
10854
	            "}");
10855
		
10856
		superInterface = getWorkingCopy(
10857
	            "/Completion/src/CompletionSuperInterface.java",
10858
	            "public interface CompletionSuperInterface{\n" +
10859
	            "	public int eqFoo(int a,Object b);\n" +
10860
	            "}");
10861
		
10862
		superInterface2 = getWorkingCopy(
10863
	            "/Completion/src/CompletionSuperInterface2.java",
10864
	            "public interface CompletionSuperInterface2 {\n" +
10865
	            "	public class InnerClass {}\n" +
10866
	            "	public interface InnerInterface {}\n" +
10867
	            "}");
10868
		
10869
		this.wc = getWorkingCopy(
10870
	            "/Completion/src/CompletionSuperType2.java",
10871
	            "public class CompletionSuperType2 extends CompletionSuper");
10872
	    
10873
	    
10874
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10875
	    String str = this.wc.getSource();
10876
	    String completeBehind = "CompletionSuper";
10877
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10878
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10879
	
10880
		assertResults(
10881
			"CompletionSuperClass[TYPE_REF]{CompletionSuperClass, , LCompletionSuperClass;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_CLASS + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
10882
			"CompletionSuperClass2[TYPE_REF]{CompletionSuperClass2, , LCompletionSuperClass2;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_CLASS + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
10883
			requestor.getResults());
10884
	} finally {
10885
		if(superClass != null) {
10886
			superClass.discardWorkingCopy();
10887
		}
10888
		if(superClass2 != null) {
10889
			superClass2.discardWorkingCopy();
10890
		}
10891
		if(superInterface != null) {
10892
			superInterface.discardWorkingCopy();
10893
		}
10894
		if(superInterface2 != null) {
10895
			superInterface2.discardWorkingCopy();
10896
		}
10897
	}
10898
}
10899
public void testCompletionSuperType3() throws JavaModelException {
10900
	ICompilationUnit superClass = null;
10901
	ICompilationUnit superClass2 = null;
10902
	ICompilationUnit superInterface = null;
10903
	ICompilationUnit superInterface2 = null;
10904
	try {
10905
		superClass = getWorkingCopy(
10906
	            "/Completion/src/CompletionSuperClass.java",
10907
	            "public class CompletionSuperClass{\n" +
10908
	            "	public class Inner {}\n" +
10909
	            "	public int eqFoo(int a,Object b){\n" +
10910
	            "		return 1;\n" +
11100
	            "	}\n" +
10911
	            "	}\n" +
11101
	            "}");
10912
	            "}");
10913
		
10914
		superClass2 = getWorkingCopy(
10915
	            "/Completion/src/CompletionSuperClass2.java",
10916
	            "public class CompletionSuperClass2 {\n" +
10917
	            "	public class InnerClass {}\n" +
10918
	            "	public interface InnerInterface {}\n" +
10919
	            "}");
10920
		
10921
		superInterface = getWorkingCopy(
10922
	            "/Completion/src/CompletionSuperInterface.java",
10923
	            "public interface CompletionSuperInterface{\n" +
10924
	            "	public int eqFoo(int a,Object b);\n" +
10925
	            "}");
10926
		
10927
		superInterface2 = getWorkingCopy(
10928
	            "/Completion/src/CompletionSuperInterface2.java",
10929
	            "public interface CompletionSuperInterface2 {\n" +
10930
	            "	public class InnerClass {}\n" +
10931
	            "	public interface InnerInterface {}\n" +
10932
	            "}");
10933
		
10934
		this.wc = getWorkingCopy(
10935
	            "/Completion/src/CompletionSuperType3.java",
10936
	            "public class CompletionSuperType3 implements CompletionSuper");
11102
	    
10937
	    
11103
	    
10938
	    
11104
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10939
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11105
	    String str = this.wc.getSource();
10940
	    String str = this.wc.getSource();
11106
	    String completeBehind = "foo";
10941
	    String completeBehind = "CompletionSuper";
11107
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10942
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11108
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10943
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11109
	
10944
	
11110
		assertResults(
10945
		assertResults(
11111
				"foo[POTENTIAL_METHOD_DECLARATION]{foo, LCompletionStaticMethodDeclaration2$Inner1;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
10946
			"CompletionSuperInterface[TYPE_REF]{CompletionSuperInterface, , LCompletionSuperInterface;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_INTERFACE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}\n" +
11112
				"foo0[METHOD_DECLARATION]{public void foo0(), LTypeWithAMethodAndAStaticMethod;, ()V, foo0, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED) + "}",
10947
			"CompletionSuperInterface2[TYPE_REF]{CompletionSuperInterface2, , LCompletionSuperInterface2;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_INTERFACE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
11113
				requestor.getResults());
10948
			requestor.getResults());
11114
	} finally {
10949
	} finally {
11115
		if(aType != null) {
10950
		if(superClass != null) {
11116
			aType.discardWorkingCopy();
10951
			superClass.discardWorkingCopy();
10952
		}
10953
		if(superClass2 != null) {
10954
			superClass2.discardWorkingCopy();
10955
		}
10956
		if(superInterface != null) {
10957
			superInterface.discardWorkingCopy();
10958
		}
10959
		if(superInterface2 != null) {
10960
			superInterface2.discardWorkingCopy();
11117
		}
10961
		}
11118
	}
10962
	}
11119
}
10963
}
11120
public void testCompletionStaticMethodDeclaration3() throws JavaModelException {
10964
public void testCompletionSuperType4() throws JavaModelException {
11121
	ICompilationUnit aType = null;
10965
	ICompilationUnit superClass2 = null;
11122
	try {
10966
	try {
11123
		aType = getWorkingCopy(
10967
		superClass2 = getWorkingCopy(
11124
	            "/Completion/src/TypeWithAMethodAndAStaticMethod .java",
10968
	            "/Completion/src/CompletionSuperClass2.java",
11125
	            "public class TypeWithAMethodAndAStaticMethod {\n"+
10969
	            "public class CompletionSuperClass2 {\n" +
11126
	            "	public static void foo(){}\n"+
10970
	            "	public class InnerClass {}\n" +
11127
	            "	public void foo0(){}\n"+
10971
	            "	public interface InnerInterface {}\n" +
11128
	            "}");
10972
	            "}");
11129
			
10973
		
11130
		this.wc = getWorkingCopy(
10974
		this.wc = getWorkingCopy(
11131
	            "/Completion/src/CompletionStaticMethodDeclaration3.java",
10975
	            "/Completion/src/CompletionSuperType4.java",
11132
	            "public class CompletionStaticMethodDeclaration3 {\n" +
10976
	            "public class CompletionSuperType4 extends CompletionSuperClass2.Inner");
11133
	            "	static class Inner1 extends TypeWithAMethodAndAStaticMethod {\n" +
11134
	            "		foo\n" +
11135
	            "	}\n" +
11136
	            "}");
11137
	    
10977
	    
11138
	    
10978
	    
11139
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10979
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11140
	    String str = this.wc.getSource();
10980
	    String str = this.wc.getSource();
11141
	    String completeBehind = "foo";
10981
	    String completeBehind = "CompletionSuperClass2.Inner";
11142
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10982
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11143
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
10983
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11144
	
10984
	
11145
		assertResults(
10985
		assertResults(
11146
				"foo[POTENTIAL_METHOD_DECLARATION]{foo, LCompletionStaticMethodDeclaration3$Inner1;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
10986
			"CompletionSuperClass2.InnerInterface[TYPE_REF]{InnerInterface, , LCompletionSuperClass2$InnerInterface;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED)+ "}\n"+
11147
				"foo0[METHOD_DECLARATION]{public void foo0(), LTypeWithAMethodAndAStaticMethod;, ()V, foo0, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED) + "}",
10987
			"CompletionSuperClass2.InnerClass[TYPE_REF]{InnerClass, , LCompletionSuperClass2$InnerClass;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_CLASS + R_NON_RESTRICTED)+"}",
11148
				requestor.getResults());
10988
			requestor.getResults());
11149
	} finally {
10989
	} finally {
11150
		if(aType != null) {
10990
		if(superClass2 != null) {
11151
			aType.discardWorkingCopy();
10991
			superClass2.discardWorkingCopy();
11152
		}
10992
		}
11153
	}
10993
	}
11154
}
10994
}
11155
public void testCompletionStaticMethodDeclaration4() throws JavaModelException {
10995
public void testCompletionSuperType5() throws JavaModelException {
11156
	ICompilationUnit aType = null;
10996
	ICompilationUnit superInterface2 = null;
11157
	try {
10997
	try {
11158
		aType = getWorkingCopy(
10998
		superInterface2 = getWorkingCopy(
11159
	            "/Completion/src/TypeWithAMethodAndAStaticMethod .java",
10999
	            "/Completion/src/CompletionSuperInterface2.java",
11160
	            "public class TypeWithAMethodAndAStaticMethod {\n"+
11000
	            "public interface CompletionSuperInterface2 {\n" +
11161
	            "	public static void foo(){}\n"+
11001
	            "	public class InnerClass {}\n" +
11162
	            "	public void foo0(){}\n"+
11002
	            "	public interface InnerInterface {}\n" +
11163
	            "}");
11003
	            "}");
11164
			
11004
		
11165
		this.wc = getWorkingCopy(
11005
		this.wc = getWorkingCopy(
11166
	            "/Completion/src/CompletionStaticMethodDeclaration4.java",
11006
	            "/Completion/src/CompletionSuperType5.java",
11167
	            "public class CompletionStaticMethodDeclaration4 {\n" +
11007
	            "public class CompletionSuperType5 implements CompletionSuperInterface2.Inner");
11168
	            "	void bar() {\n" +
11169
	            "		class Local1 extends TypeWithAMethodAndAStaticMethod {\n" +
11170
	            "			foo\n" +
11171
	            "		}\n" +
11172
	            "	}\n" +
11173
	            "}");
11174
	    
11008
	    
11175
	    
11009
	    
11176
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11010
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11177
	    String str = this.wc.getSource();
11011
	    String str = this.wc.getSource();
11178
	    String completeBehind = "foo";
11012
	    String completeBehind = "CompletionSuperInterface2.Inner";
11179
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11013
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11180
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11014
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11181
	
11015
	
11182
		assertResults(
11016
		assertResults(
11183
				"foo[POTENTIAL_METHOD_DECLARATION]{foo, LLocal1;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
11017
			"CompletionSuperInterface2.InnerClass[TYPE_REF]{InnerClass, , LCompletionSuperInterface2$InnerClass;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
11184
				"foo0[METHOD_DECLARATION]{public void foo0(), LTypeWithAMethodAndAStaticMethod;, ()V, foo0, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED) + "}",
11018
			"CompletionSuperInterface2.InnerInterface[TYPE_REF]{InnerInterface, , LCompletionSuperInterface2$InnerInterface;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_INTERFACE+ R_NON_RESTRICTED)+"}",
11185
				requestor.getResults());
11019
			requestor.getResults());
11186
	} finally {
11020
	} finally {
11187
		if(aType != null) {
11021
		if(superInterface2 != null) {
11188
			aType.discardWorkingCopy();
11022
			superInterface2.discardWorkingCopy();
11189
		}
11023
		}
11190
	}
11024
	}
11191
}
11025
}
11192
public void testCompletionStaticMethodDeclaration5() throws JavaModelException {
11026
public void testCompletionSuperType6() throws JavaModelException {
11193
	ICompilationUnit aType = null;
11027
	ICompilationUnit superClass = null;
11028
	ICompilationUnit superClass2 = null;
11029
	ICompilationUnit superInterface = null;
11030
	ICompilationUnit superInterface2 = null;
11194
	try {
11031
	try {
11195
		aType = getWorkingCopy(
11032
		superClass = getWorkingCopy(
11196
	            "/Completion/src/TypeWithAMethodAndAStaticMethod .java",
11033
	            "/Completion/src/CompletionSuperClass.java",
11197
	            "public class TypeWithAMethodAndAStaticMethod {\n"+
11034
	            "public class CompletionSuperClass{\n" +
11198
	            "	public static void foo(){}\n"+
11035
	            "	public class Inner {}\n" +
11199
	            "	public void foo0(){}\n"+
11036
	            "	public int eqFoo(int a,Object b){\n" +
11037
	            "		return 1;\n" +
11038
	            "	}\n" +
11200
	            "}");
11039
	            "}");
11201
			
11040
		
11202
		this.wc = getWorkingCopy(
11041
		superClass2 = getWorkingCopy(
11203
	            "/Completion/src/CompletionStaticMethodDeclaration5.java",
11042
	            "/Completion/src/CompletionSuperClass2.java",
11204
	            "public class CompletionStaticMethodDeclaration5 {\n"+
11043
	            "public class CompletionSuperClass2 {\n" +
11205
	            "	void bar() {\n"+
11044
	            "	public class InnerClass {}\n" +
11206
	            "		static class Local1 extends TypeWithAMethodAndAStaticMethod {\n"+
11045
	            "	public interface InnerInterface {}\n" +
11207
	            "			foo\n"+
11046
	            "}");
11208
	            "		}\n"+
11047
		
11209
	            "	}\n"+
11048
		superInterface = getWorkingCopy(
11049
	            "/Completion/src/CompletionSuperInterface.java",
11050
	            "public interface CompletionSuperInterface{\n" +
11051
	            "	public int eqFoo(int a,Object b);\n" +
11052
	            "}");
11053
		
11054
		superInterface2 = getWorkingCopy(
11055
	            "/Completion/src/CompletionSuperInterface2.java",
11056
	            "public interface CompletionSuperInterface2 {\n" +
11057
	            "	public class InnerClass {}\n" +
11058
	            "	public interface InnerInterface {}\n" +
11210
	            "}");
11059
	            "}");
11060
		
11061
		this.wc = getWorkingCopy(
11062
	            "/Completion/src/CompletionSuperType6.java",
11063
	            "public interface CompletionSuperType6 extends CompletionSuper");
11211
	    
11064
	    
11212
	    
11065
	    
11213
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11066
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11214
	    String str = this.wc.getSource();
11067
	    String str = this.wc.getSource();
11215
	    String completeBehind = "foo";
11068
	    String completeBehind = "CompletionSuper";
11216
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11069
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11217
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11070
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11218
	
11071
	
11219
		assertResults(
11072
		assertResults(
11220
				"foo[POTENTIAL_METHOD_DECLARATION]{foo, LLocal1;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
11073
				"CompletionSuperInterface[TYPE_REF]{CompletionSuperInterface, , LCompletionSuperInterface;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_INTERFACE + R_NON_RESTRICTED)+"}\n" +
11221
				"foo0[METHOD_DECLARATION]{public void foo0(), LTypeWithAMethodAndAStaticMethod;, ()V, foo0, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED) + "}",
11074
				"CompletionSuperInterface2[TYPE_REF]{CompletionSuperInterface2, , LCompletionSuperInterface2;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_INTERFACE+ R_NON_RESTRICTED)+"}",
11222
				requestor.getResults());
11075
				requestor.getResults());
11223
	} finally {
11076
	} finally {
11224
		if(aType != null) {
11077
		if(superClass != null) {
11225
			aType.discardWorkingCopy();
11078
			superClass.discardWorkingCopy();
11079
		}
11080
		if(superClass2 != null) {
11081
			superClass2.discardWorkingCopy();
11082
		}
11083
		if(superInterface != null) {
11084
			superInterface.discardWorkingCopy();
11085
		}
11086
		if(superInterface2 != null) {
11087
			superInterface2.discardWorkingCopy();
11226
		}
11088
		}
11227
	}
11089
	}
11228
}
11090
}
11229
public void testCompletionStaticMethodDeclaration6() throws JavaModelException {
11091
public void testCompletionSuperType7() throws JavaModelException {
11230
	ICompilationUnit aType = null;
11092
	ICompilationUnit superClass2 = null;
11231
	try {
11093
	try {
11232
		aType = getWorkingCopy(
11094
		superClass2 = getWorkingCopy(
11233
	            "/Completion/src/TypeWithAMethodAndAStaticMethod .java",
11095
	            "/Completion/src/CompletionSuperClass2.java",
11234
	            "public class TypeWithAMethodAndAStaticMethod {\n"+
11096
	            "public class CompletionSuperClass2 {\n" +
11235
	            "	public static void foo(){}\n"+
11097
	            "	public class InnerClass {}\n" +
11236
	            "	public void foo0(){}\n"+
11098
	            "	public interface InnerInterface {}\n" +
11237
	            "}");
11099
	            "}");
11238
			
11100
		
11239
		this.wc = getWorkingCopy(
11101
		this.wc = getWorkingCopy(
11240
	            "/Completion/src/CompletionStaticMethodDeclaration6.java",
11102
	            "/Completion/src/CompletionSuperType7.java",
11241
	            "public class CompletionStaticMethodDeclaration6 {\n"+
11103
	            "public interface CompletionSuperType7 extends CompletionSuperClass2.Inner");
11242
	            "	void bar() {\n"+
11243
	            "		new TypeWithAMethodAndAStaticMethod() {\n"+
11244
	            "			foo\n"+
11245
	            "		};\n"+
11246
	            "	}\n"+
11247
	            "}");
11248
	    
11104
	    
11249
	    
11105
	    
11250
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11106
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11251
	    String str = this.wc.getSource();
11107
	    String str = this.wc.getSource();
11252
	    String completeBehind = "foo";
11108
	    String completeBehind = "CompletionSuperClass2.Inner";
11253
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11109
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11254
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11110
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11255
	
11111
	
11256
		assertResults(
11112
		assertResults(
11257
				"foo[POTENTIAL_METHOD_DECLARATION]{foo, LTypeWithAMethodAndAStaticMethod;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
11113
			"CompletionSuperClass2.InnerClass[TYPE_REF]{InnerClass, , LCompletionSuperClass2$InnerClass;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
11258
				"foo0[METHOD_DECLARATION]{public void foo0(), LTypeWithAMethodAndAStaticMethod;, ()V, foo0, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_NON_RESTRICTED) + "}",
11114
			"CompletionSuperClass2.InnerInterface[TYPE_REF]{InnerInterface, , LCompletionSuperClass2$InnerInterface;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_INTERFACE+ R_NON_RESTRICTED)+"}",
11259
				requestor.getResults());
11115
			requestor.getResults());
11260
	} finally {
11116
	} finally {
11261
		if(aType != null) {
11117
		if(superClass2 != null) {
11262
			aType.discardWorkingCopy();
11118
			superClass2.discardWorkingCopy();
11263
		}
11119
		}
11264
	}
11120
	}
11265
}
11121
}
11266
public void testCompletionStaticMethod1() throws JavaModelException {
11122
public void testCompletionSuperType8() throws JavaModelException {
11267
	ICompilationUnit aType = null;
11123
	ICompilationUnit superInterface2 = null;
11268
	try {
11124
	try {
11269
		aType = getWorkingCopy(
11125
		superInterface2 = getWorkingCopy(
11270
	            "/Completion/src/TypeWithAMethodAndAStaticMethod .java",
11126
	            "/Completion/src/CompletionSuperInterface2.java",
11271
	            "public class TypeWithAMethodAndAStaticMethod {\n"+
11127
	            "public interface CompletionSuperInterface2 {\n" +
11272
	            "	public static void foo(){}\n"+
11128
	            "	public class InnerClass {}\n" +
11273
	            "	public void foo0(){}\n"+
11129
	            "	public interface InnerInterface {}\n" +
11274
	            "}");
11275
			
11276
		this.wc = getWorkingCopy(
11277
	            "/Completion/src/CompletionStaticMethod1.java",
11278
	            "public class CompletionStaticMethod1 extends TypeWithAMethodAndAStaticMethod {\n"+
11279
	            "	void bar(){\n"+
11280
	            "		new TypeWithAMethodAndAStaticMethod(){\n"+
11281
	            "			class Inner1 extends TypeWithAMethodAndAStaticMethod {\n"+
11282
	            "				void bar(){\n"+
11283
	            "					foo\n"+
11284
	            "				}\n"+
11285
	            "			}\n"+
11286
	            "		};\n"+
11287
	            "	}\n"+
11288
	            "	\n"+
11289
	            "}");
11130
	            "}");
11131
		
11132
		this.wc = getWorkingCopy(
11133
	            "/Completion/src/CompletionSuperType8.java",
11134
	            "public interface CompletionSuperType8 extends CompletionSuperInterface2.Inner");
11290
	    
11135
	    
11291
	    
11136
	    
11292
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11137
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11293
	    String str = this.wc.getSource();
11138
	    String str = this.wc.getSource();
11294
	    String completeBehind = "foo";
11139
	    String completeBehind = "CompletionSuperInterface2.Inner";
11295
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11140
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11296
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11141
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11297
	
11142
	
11298
		assertResults(
11143
		assertResults(
11299
				"foo0[METHOD_REF]{CompletionStaticMethod1.this.foo0(), LTypeWithAMethodAndAStaticMethod;, ()V, foo0, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
11144
			"CompletionSuperInterface2.InnerClass[TYPE_REF]{InnerClass, , LCompletionSuperInterface2$InnerClass;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
11300
				"foo0[METHOD_REF]{foo0(), LTypeWithAMethodAndAStaticMethod;, ()V, foo0, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED) + "}\n" +
11145
			"CompletionSuperInterface2.InnerInterface[TYPE_REF]{InnerInterface, , LCompletionSuperInterface2$InnerInterface;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_INTERFACE+ R_NON_RESTRICTED)+"}",
11301
				"foo[METHOD_REF]{CompletionStaticMethod1.foo(), LTypeWithAMethodAndAStaticMethod;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
11146
			requestor.getResults());
11302
				"foo[METHOD_REF]{foo(), LTypeWithAMethodAndAStaticMethod;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_NAME + R_NON_RESTRICTED) + "}",
11303
				requestor.getResults());
11304
	} finally {
11147
	} finally {
11305
		if(aType != null) {
11148
		if(superInterface2 != null) {
11306
			aType.discardWorkingCopy();
11149
			superInterface2.discardWorkingCopy();
11307
		}
11150
		}
11308
	}
11151
	}
11309
}
11152
}
11310
public void testCompletionAfterSwitch() throws JavaModelException {
11153
public void testCompletionThrowStatement() throws JavaModelException {
11311
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11154
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11312
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionAfterSwitch.java");
11155
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionThrowStatement.java");
11313
11156
11314
	String str = cu.getSource();
11157
	String str = cu.getSource();
11315
	String completeBehind = "bar";
11158
	String completeBehind = "Ex";
11316
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
11159
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11317
	cu.codeComplete(cursorLocation, requestor);
11160
	cu.codeComplete(cursorLocation, requestor);
11318
11161
11319
	assertEquals(
11162
	assertEquals(
11320
			"element:bar    completion:bar()    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_NAME+ R_NON_RESTRICTED),
11163
		"element:Exception    completion:Exception    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXCEPTION + R_UNQUALIFIED+ R_NON_RESTRICTED),
11164
		requestor.getResults());
11165
}
11166
public void testCompletionToplevelType1() throws JavaModelException {
11167
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11168
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "p3", "CompletionToplevelType1.java");
11169
11170
		String str = cu.getSource();
11171
		String completeBehind = "CompletionToplevelType1";
11172
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11173
		cu.codeComplete(cursorLocation, requestor);
11174
11175
		assertEquals(
11176
			"element:CompletionToplevelType1    completion:CompletionToplevelType1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME+ R_NON_RESTRICTED),
11321
			requestor.getResults());
11177
			requestor.getResults());
11322
}
11178
}
11323
public void testCompletionAfterSupercall1() throws JavaModelException {
11179
public void testCompletionType1() throws JavaModelException {
11324
	this.workingCopies = new ICompilationUnit[1];
11180
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11325
	this.workingCopies[0] = getWorkingCopy(
11181
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionType1.java");
11326
		"/Completion/src/CompletionAfterSupercall1.java",
11327
		"public class CompletionAfterSupercall1 extends CompletionAfterSupercall1_1 {\n" +
11328
		"	public void foo(){\n" +
11329
		"		super.foo\n" +
11330
		"	}\n" +
11331
		"}\n" +
11332
		"abstract class CompletionAfterSupercall1_1 extends CompletionAfterSupercall1_2 implements CompletionAfterSupercall1_3 {\n" +
11333
		"	\n" +
11334
		"}\n" +
11335
		"class CompletionAfterSupercall1_2 implements CompletionAfterSupercall1_3 {\n" +
11336
		"	public void foo(){}\n" +
11337
		"}\n" +
11338
		"interface CompletionAfterSupercall1_3 {\n" +
11339
		"	public void foo();\n" +
11340
		"}");
11341
11182
11342
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11183
	String str = cu.getSource();
11343
	String str = this.workingCopies[0].getSource();
11184
	String completeBehind = "CT1";
11344
	String completeBehind = "super.foo";
11345
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11185
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11346
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11186
	cu.codeComplete(cursorLocation, requestor);
11347
11187
11348
	assertResults(
11188
	assertEquals(
11349
			"foo[METHOD_REF]{foo(), LCompletionAfterSupercall1_2;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC+ R_NON_RESTRICTED) + "}",
11189
		"element:CT1    completion:CT1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n"+
11190
		"element:CT1    completion:q2.CT1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME+ R_NON_RESTRICTED),
11191
		requestor.getResults());
11192
}
11193
public void testCompletionUnaryOperator1() throws JavaModelException {
11194
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11195
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionUnaryOperator1.java");
11196
11197
		String str = cu.getSource();
11198
		String completeBehind = "var";
11199
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11200
		cu.codeComplete(cursorLocation, requestor);
11201
11202
		assertEquals(
11203
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
11204
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11205
			"element:var3    completion:var3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
11350
			requestor.getResults());
11206
			requestor.getResults());
11351
}
11207
}
11352
public void testCompletionPackageAndClass1() throws JavaModelException {
11208
public void testCompletionUnaryOperator2() throws JavaModelException {
11209
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11210
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionUnaryOperator2.java");
11211
11212
		String str = cu.getSource();
11213
		String completeBehind = "var";
11214
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11215
		cu.codeComplete(cursorLocation, requestor);
11216
11217
		assertEquals(
11218
			"element:var1    completion:var1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11219
			"element:var2    completion:var2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED)+"\n" +
11220
			"element:var3    completion:var3    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
11221
			requestor.getResults());
11222
}
11223
/*
11224
 * bug : http://dev.eclipse.org/bugs/show_bug.cgi?id=24440
11225
 */
11226
public void testCompletionUnresolvedEnclosingType() throws JavaModelException {
11353
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11227
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11354
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "z1.z2.qla0", "Qla3.java");
11228
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionUnresolvedEnclosingType.java");
11355
11229
11356
	String str = cu.getSource();
11230
	String str = cu.getSource();
11357
	String completeBehind = "z1.z2.ql";
11231
	String completeBehind = "new ZZZ(";
11232
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11233
	cu.codeComplete(cursorLocation, requestor);
11234
11235
	assertTrue(
11236
		requestor.getResults().length() == 0);
11237
}
11238
public void testCompletionUnresolvedFieldType() throws JavaModelException {
11239
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11240
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionUnresolvedFieldType.java");
11241
11242
	String str = cu.getSource();
11243
	String completeBehind = "bar";
11358
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11244
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11359
	cu.codeComplete(cursorLocation, requestor);
11245
	cu.codeComplete(cursorLocation, requestor);
11360
11246
11361
	assertEquals(
11247
	assertEquals(
11362
			"element:Qla1    completion:z1.z2.Qla1    relevance:" + (R_DEFAULT + R_INTERESTING + R_QUALIFIED + R_NON_RESTRICTED) + "\n" +
11248
		"element:barPlus    completion:barPlus()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
11363
			"element:qla2    completion:z1.z2.qla2    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_QUALIFIED + R_NON_RESTRICTED) + "\n" +
11249
		requestor.getResults());
11364
			"element:z1.z2.qla0    completion:z1.z2.qla0    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_QUALIFIED+ R_NON_RESTRICTED),
11365
			requestor.getResults());
11366
}
11250
}
11367
public void testCompletionPackageAndClass2() throws JavaModelException {
11251
public void testCompletionUnresolvedParameterType() throws JavaModelException {
11368
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11252
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11369
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "z1.z2.qla0", "Wla.java");
11253
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionUnresolvedParameterType.java");
11370
11254
11371
	String str = cu.getSource();
11255
	String str = cu.getSource();
11372
	String completeBehind = "z1.z2.qla0.";
11256
	String completeBehind = "bar";
11373
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11257
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11374
	cu.codeComplete(cursorLocation, requestor);
11258
	cu.codeComplete(cursorLocation, requestor);
11375
11259
11376
	assertEquals(
11260
	assertEquals(
11377
			"element:Qla3    completion:Qla3    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "\n" +
11261
		"element:barPlus    completion:barPlus()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
11378
			"element:Qla4    completion:Qla4    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "\n" +
11262
		requestor.getResults());
11379
			"element:Wla    completion:Wla    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
11380
			requestor.getResults());
11381
}
11263
}
11382
public void testCompletionNonStaticFieldRelevance() throws JavaModelException {
11264
public void testCompletionUnresolvedReturnType() throws JavaModelException {
11383
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11265
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11384
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionNonStaticFieldRelevance.java");
11266
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionUnresolvedReturnType.java");
11385
11267
11386
	String str = cu.getSource();
11268
	String str = cu.getSource();
11387
	String completeBehind = "var.Ii";
11269
	String completeBehind = "bar";
11388
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11270
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11389
	cu.codeComplete(cursorLocation, requestor);
11271
	cu.codeComplete(cursorLocation, requestor);
11390
11272
11391
	assertEquals(
11273
	assertEquals(
11392
			"element:Ii0    completion:Ii0    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "\n" +
11274
		"element:barPlus    completion:barPlus()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
11393
			"element:ii1    completion:ii1    relevance:" + (R_DEFAULT + R_INTERESTING + R_NON_STATIC+ R_NON_RESTRICTED),
11275
		requestor.getResults());
11394
			requestor.getResults());
11395
}
11276
}
11396
public void testCompletionInsideStaticMethod() throws JavaModelException {
11277
public void testCompletionVariableInitializerInInitializer1() throws JavaModelException {
11397
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11278
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11398
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionInsideStaticMethod.java");
11279
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableInitializerInInitializer1.java");
11399
11280
11400
	String str = cu.getSource();
11281
	String str = cu.getSource();
11401
	String completeBehind = "doT";
11282
	String completeBehind = "zz";
11402
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
11283
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11403
	cu.codeComplete(cursorLocation, requestor);
11284
	cu.codeComplete(cursorLocation, requestor);
11404
11285
11405
	assertEquals(
11286
	assertEquals(
11406
			"element:doTheThing    completion:doTheThing()    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
11287
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11407
			requestor.getResults());
11288
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11289
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11290
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11291
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
11292
		requestor.getResults());
11293
}
11294
public void testCompletionVariableInitializerInInitializer2() throws JavaModelException {
11295
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11296
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableInitializerInInitializer2.java");
11297
11298
	String str = cu.getSource();
11299
	String completeBehind = "zz";
11300
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11301
	cu.codeComplete(cursorLocation, requestor);
11302
11303
	assertEquals(
11304
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11305
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11306
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11307
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11308
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
11309
		requestor.getResults());
11310
}
11311
public void testCompletionVariableInitializerInInitializer3() throws JavaModelException {
11312
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11313
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableInitializerInInitializer3.java");
11314
11315
	String str = cu.getSource();
11316
	String completeBehind = "Objec";
11317
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11318
	cu.codeComplete(cursorLocation, requestor);
11319
11320
	assertEquals(
11321
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
11322
		requestor.getResults());
11323
}
11324
public void testCompletionVariableInitializerInInitializer4() throws JavaModelException {
11325
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11326
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableInitializerInInitializer4.java");
11327
11328
	String str = cu.getSource();
11329
	String completeBehind = "Objec";
11330
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11331
	cu.codeComplete(cursorLocation, requestor);
11332
11333
	assertEquals(
11334
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
11335
		requestor.getResults());
11336
}
11337
public void testCompletionVariableInitializerInMethod1() throws JavaModelException {
11338
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11339
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableInitializerInMethod1.java");
11340
11341
	String str = cu.getSource();
11342
	String completeBehind = "zz";
11343
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11344
	cu.codeComplete(cursorLocation, requestor);
11345
11346
	assertEquals(
11347
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11348
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11349
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11350
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11351
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
11352
		requestor.getResults());
11353
}
11354
public void testCompletionVariableInitializerInMethod2() throws JavaModelException {
11355
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11356
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableInitializerInMethod2.java");
11357
11358
	String str = cu.getSource();
11359
	String completeBehind = "zz";
11360
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11361
	cu.codeComplete(cursorLocation, requestor);
11362
11363
	assertEquals(
11364
		"element:zzObject    completion:zzObject    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11365
		"element:zzboolean    completion:zzboolean    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11366
		"element:zzdouble    completion:zzdouble    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11367
		"element:zzint    completion:zzint    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
11368
		"element:zzlong    completion:zzlong    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
11369
		requestor.getResults());
11408
}
11370
}
11409
/*
11371
public void testCompletionVariableInitializerInMethod3() throws JavaModelException {
11410
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=65737
11411
 */
11412
public void testCompletion2InterfacesWithSameMethod() throws JavaModelException {
11413
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11372
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11414
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "Completion2InterfacesWithSameMethod.java");
11373
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableInitializerInMethod3.java");
11415
11374
11416
	String str = cu.getSource();
11375
	String str = cu.getSource();
11417
	String completeBehind = "var.meth";
11376
	String completeBehind = "Objec";
11418
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
11377
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11419
	cu.codeComplete(cursorLocation, requestor);
11378
	cu.codeComplete(cursorLocation, requestor);
11420
11379
11421
	assertEquals(
11380
	assertEquals(
11422
			"element:method    completion:method()    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
11381
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
11423
			requestor.getResults());
11382
		requestor.getResults());
11424
}
11383
}
11425
/*
11384
public void testCompletionVariableInitializerInMethod4() throws JavaModelException {
11426
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=66570
11427
 */
11428
public void testCompletionExactNameCaseInsensitive() throws JavaModelException {
11429
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11385
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11430
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionExactNameCaseInsensitive.java");
11386
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableInitializerInMethod4.java");
11431
11387
11432
	String str = cu.getSource();
11388
	String str = cu.getSource();
11433
	String completeBehind = "(compleTionexactnamecaseInsensitive";
11389
	String completeBehind = "Objec";
11434
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
11390
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11435
	cu.codeComplete(cursorLocation, requestor);
11391
	cu.codeComplete(cursorLocation, requestor);
11436
11392
11437
	assertEquals(
11393
	assertEquals(
11438
			"element:CompletionExactNameCaseInsensitive    completion:CompletionExactNameCaseInsensitive    relevance:"+(R_DEFAULT + R_INTERESTING + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+ "\n" +
11394
		"element:Object    completion:Object    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED+ R_NON_RESTRICTED),
11439
			"element:CompletionExactNameCaseInsensitivePlus    completion:CompletionExactNameCaseInsensitivePlus    relevance:"+(R_DEFAULT + R_INTERESTING + R_UNQUALIFIED+ R_NON_RESTRICTED),
11395
		requestor.getResults());
11440
			requestor.getResults());
11441
}
11396
}
11442
/*
11397
/*
11443
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=66908
11398
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25811
11444
 */
11399
*/
11445
public void testCompletionSameClass() throws JavaModelException {
11400
public void testCompletionVariableName1() throws JavaModelException {
11446
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11401
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11447
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionSameClass.java");
11402
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableName1.java");
11448
11403
11449
	String str = cu.getSource();
11404
	String str = cu.getSource();
11450
	String completeBehind = "(CompletionSameClas";
11405
	String completeBehind = "TEST_FOO_MyClass ";
11451
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
11406
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11452
	cu.codeComplete(cursorLocation, requestor);
11407
	cu.codeComplete(cursorLocation, requestor);
11453
11408
11454
	assertEquals(
11409
	assertEquals(
11455
			"element:CompletionSameClass    completion:CompletionSameClass    relevance:" + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED),
11410
		"element:class1    completion:class1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
11456
			requestor.getResults());
11411
		"element:myClass    completion:myClass    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
11412
		requestor.getResults());
11457
}
11413
}
11458
public void testCompletionBasicPackage1() throws JavaModelException {
11414
public void testCompletionVariableName10() throws JavaModelException {
11459
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
11415
	Hashtable options = JavaCore.getOptions();
11460
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBasicPackage1.java");
11416
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
11417
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pre"); //$NON-NLS-1$
11418
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
11419
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"suf"); //$NON-NLS-1$
11420
	
11421
	JavaCore.setOptions(options);
11461
11422
11462
	String str = cu.getSource();
11423
	try {
11463
	String completeBehind = "java.lan";
11424
		this.wc = getWorkingCopy(
11464
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
11425
	            "/Completion/src/CompletionVariableName10.java",
11465
	cu.codeComplete(cursorLocation, requestor);
11426
	            "class FooBar {\n"+
11427
	            "}\n"+
11428
	            "public class CompletionVariableName10 {\n"+
11429
	            "	void foo(){\n"+
11430
	            "		FooBar fo\n"+
11431
	            "	}\n"+
11432
	            "}");
11433
	    
11434
	    
11435
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11436
	    String str = this.wc.getSource();
11437
	    String completeBehind = "fo";
11438
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11439
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11440
	
11441
	    assertResults(
11442
				"foBar[VARIABLE_DECLARATION]{foBar, null, LFooBar;, foBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11443
				"foBarsuf[VARIABLE_DECLARATION]{foBarsuf, null, LFooBar;, foBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}\n"+
11444
				"fooBar[VARIABLE_DECLARATION]{fooBar, null, LFooBar;, fooBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}\n"+
11445
				"fooBarsuf[VARIABLE_DECLARATION]{fooBarsuf, null, LFooBar;, fooBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_LESS_NEW_CHARACTERS + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}",
11446
				requestor.getResults());
11447
	} finally {
11448
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
11449
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
11450
		JavaCore.setOptions(options);
11451
	}
11452
}
11453
public void testCompletionVariableName11() throws JavaModelException {
11454
	Hashtable options = JavaCore.getOptions();
11455
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
11456
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pre"); //$NON-NLS-1$
11457
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
11458
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"suf"); //$NON-NLS-1$
11459
	
11460
	JavaCore.setOptions(options);
11466
11461
11467
	assertResults(
11462
	try {
11468
			"java.lang[PACKAGE_REF]{java.lang, java.lang, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_QUALIFIED + R_NON_RESTRICTED) + "}",
11463
		this.wc = getWorkingCopy(
11469
			requestor.getResults());
11464
	            "/Completion/src/CompletionVariableName11.java",
11465
	            "class FooBar {\n"+
11466
	            "}\n"+
11467
	            "public class CompletionVariableName11 {\n"+
11468
	            "	void foo(){\n"+
11469
	            "		FooBar pr\n"+
11470
	            "	}\n"+
11471
	            "}");
11472
	    
11473
	    
11474
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11475
	    String str = this.wc.getSource();
11476
	    String completeBehind = "pr";
11477
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11478
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11479
	
11480
	    assertResults(
11481
				"preBar[VARIABLE_DECLARATION]{preBar, null, LFooBar;, preBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NON_RESTRICTED)+"}\n"+
11482
				"preFooBar[VARIABLE_DECLARATION]{preFooBar, null, LFooBar;, preFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NON_RESTRICTED)+"}\n"+
11483
				"preBarsuf[VARIABLE_DECLARATION]{preBarsuf, null, LFooBar;, preBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX+ R_NON_RESTRICTED)+"}\n"+
11484
				"preFooBarsuf[VARIABLE_DECLARATION]{preFooBarsuf, null, LFooBar;, preFooBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}",
11485
				requestor.getResults());
11486
	} finally {
11487
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
11488
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
11489
		JavaCore.setOptions(options);
11490
	}
11470
}
11491
}
11471
public void testCompletionBasicType1() throws JavaModelException {
11492
public void testCompletionVariableName12() throws JavaModelException {
11472
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
11493
	Hashtable options = JavaCore.getOptions();
11473
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBasicType1.java");
11494
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
11495
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pre"); //$NON-NLS-1$
11496
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
11497
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"suf"); //$NON-NLS-1$
11498
	
11499
	JavaCore.setOptions(options);
11474
11500
11475
	String str = cu.getSource();
11501
	try {
11476
	String completeBehind = "Objec";
11502
		this.wc = getWorkingCopy(
11477
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
11503
	            "/Completion/src/CompletionVariableName12.java",
11478
	cu.codeComplete(cursorLocation, requestor);
11504
	            "class FooBar {\n"+
11505
	            "}\n"+
11506
	            "public class CompletionVariableName12 {\n"+
11507
	            "	void foo(){\n"+
11508
	            "		FooBar prethe\n"+
11509
	            "	}\n"+
11510
	            "}");
11511
	    
11512
	    
11513
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11514
	    String str = this.wc.getSource();
11515
	    String completeBehind = "prethe";
11516
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11517
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11518
	
11519
	    assertResults(
11520
				"preTheBar[VARIABLE_DECLARATION]{preTheBar, null, LFooBar;, preTheBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NON_RESTRICTED)+"}\n"+
11521
				"preTheFooBar[VARIABLE_DECLARATION]{preTheFooBar, null, LFooBar;, preTheFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NON_RESTRICTED)+"}\n"+
11522
				"preTheBarsuf[VARIABLE_DECLARATION]{preTheBarsuf, null, LFooBar;, preTheBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}\n"+
11523
				"preTheFooBarsuf[VARIABLE_DECLARATION]{preTheFooBarsuf, null, LFooBar;, preTheFooBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}",
11524
				requestor.getResults());
11525
	} finally {
11526
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
11527
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
11528
		JavaCore.setOptions(options);
11529
	}
11530
}
11531
public void testCompletionVariableName13() throws JavaModelException {
11532
	Hashtable options = JavaCore.getOptions();
11533
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
11534
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pre"); //$NON-NLS-1$
11535
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
11536
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"suf"); //$NON-NLS-1$
11537
	
11538
	JavaCore.setOptions(options);
11479
11539
11480
	assertResults(
11540
	try {
11481
			"Object[TYPE_REF]{Object, java.lang, Ljava.lang.Object;, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11541
		this.wc = getWorkingCopy(
11482
			requestor.getResults());
11542
	            "/Completion/src/CompletionVariableName13.java",
11543
	            "class FooBar {\n"+
11544
	            "}\n"+
11545
	            "public class CompletionVariableName13 {\n"+
11546
	            "	void foo(){\n"+
11547
	            "		FooBar prefo\n"+
11548
	            "	}\n"+
11549
	            "}");
11550
	    
11551
	    
11552
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11553
	    String str = this.wc.getSource();
11554
	    String completeBehind = "prefo";
11555
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11556
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11557
	
11558
	    assertResults(
11559
				"preFoBar[VARIABLE_DECLARATION]{preFoBar, null, LFooBar;, preFoBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NON_RESTRICTED)+"}\n"+
11560
				"preFoBarsuf[VARIABLE_DECLARATION]{preFoBarsuf, null, LFooBar;, preFoBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}\n"+
11561
				"preFooBar[VARIABLE_DECLARATION]{preFooBar, null, LFooBar;, preFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}\n"+
11562
				"preFooBarsuf[VARIABLE_DECLARATION]{preFooBarsuf, null, LFooBar;, preFooBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}",
11563
				requestor.getResults());
11564
	} finally {
11565
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
11566
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
11567
		JavaCore.setOptions(options);
11568
	}
11569
}
11570
public void testCompletionVariableName14() throws JavaModelException {
11571
	Hashtable options = JavaCore.getOptions();
11572
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
11573
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pre"); //$NON-NLS-1$
11574
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
11575
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"suf"); //$NON-NLS-1$
11576
	
11577
	JavaCore.setOptions(options);
11578
11579
	try {
11580
		this.wc = getWorkingCopy(
11581
	            "/Completion/src/CompletionVariableName14.java",
11582
	            "class FooBar {\n"+
11583
	            "}\n"+
11584
	            "public class CompletionVariableName14 {\n"+
11585
	            "	void foo(){\n"+
11586
	            "		FooBar prethefo\n"+
11587
	            "	}\n"+
11588
	            "}");
11589
	    
11590
	    
11591
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11592
	    String str = this.wc.getSource();
11593
	    String completeBehind = "prethefo";
11594
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11595
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11596
	
11597
	    assertResults(
11598
				"preThefoBar[VARIABLE_DECLARATION]{preThefoBar, null, LFooBar;, preThefoBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NON_RESTRICTED)+"}\n"+
11599
				"preThefoBarsuf[VARIABLE_DECLARATION]{preThefoBarsuf, null, LFooBar;, preThefoBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}\n"+
11600
				"preTheFooBar[VARIABLE_DECLARATION]{preTheFooBar, null, LFooBar;, preTheFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}\n"+
11601
				"preTheFooBarsuf[VARIABLE_DECLARATION]{preTheFooBarsuf, null, LFooBar;, preTheFooBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}",
11602
				requestor.getResults());
11603
	} finally {
11604
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
11605
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
11606
		JavaCore.setOptions(options);
11607
	}
11483
}
11608
}
11484
public void testCompletionBasicField1() throws JavaModelException {
11609
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=128045
11485
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
11610
public void testCompletionVariableName15() throws JavaModelException {
11486
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBasicField1.java");
11611
	Hashtable options = JavaCore.getOptions();
11487
11612
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
11488
	String str = cu.getSource();
11613
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pre"); //$NON-NLS-1$
11489
	String completeBehind = "zzvar";
11614
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
11490
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11615
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"suf"); //$NON-NLS-1$
11491
	cu.codeComplete(cursorLocation, requestor);
11616
	
11617
	JavaCore.setOptions(options);
11492
11618
11493
	assertResults(
11619
	try {
11494
			"zzvarzz[FIELD_REF]{zzvarzz, LCompletionBasicField1;, I, zzvarzz, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11620
		this.wc = getWorkingCopy(
11495
			requestor.getResults());
11621
	            "/Completion/src/CompletionVariableName15.java",
11622
	            "class FooBar {\n"+
11623
	            "}\n"+
11624
	            "public class CompletionVariableName15 {\n"+
11625
	            "	void foo(){\n"+
11626
	            "		FooBar pro\n"+
11627
	            "	}\n"+
11628
	            "}");
11629
	    
11630
	    
11631
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11632
	    String str = this.wc.getSource();
11633
	    String completeBehind = "pro";
11634
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11635
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11636
	
11637
	    assertResults(
11638
				"proBar[VARIABLE_DECLARATION]{proBar, null, LFooBar;, proBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11639
				"proFooBar[VARIABLE_DECLARATION]{proFooBar, null, LFooBar;, proFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11640
				"proBarsuf[VARIABLE_DECLARATION]{proBarsuf, null, LFooBar;, proBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_CASE + R_NON_RESTRICTED)+"}\n"+
11641
				"proFooBarsuf[VARIABLE_DECLARATION]{proFooBarsuf, null, LFooBar;, proFooBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_CASE + R_NON_RESTRICTED)+"}",
11642
				requestor.getResults());
11643
	} finally {
11644
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
11645
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
11646
		JavaCore.setOptions(options);
11647
	}
11496
}
11648
}
11497
public void testCompletionBasicMethod1() throws JavaModelException {
11649
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
11498
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
11650
public void testCompletionVariableName16() throws JavaModelException {
11499
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBasicMethod1.java");
11651
	this.workingCopies = new ICompilationUnit[1];
11500
11652
	this.workingCopies[0] = getWorkingCopy(
11501
	String str = cu.getSource();
11653
            "/Completion/src/test/Test.java",
11502
	String completeBehind = "zzfo";
11654
            "package test;\n"+
11503
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11655
            "public class Test {\n"+
11504
	cu.codeComplete(cursorLocation, requestor);
11656
            "	void foo(){\n"+
11657
            "		Object ;\n"+
11658
            "		foo = null;\n"+
11659
            "	}\n"+
11660
            "}");
11661
    
11662
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11663
    String str = this.workingCopies[0].getSource();
11664
    String completeBehind = "Object ";
11665
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11666
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11505
11667
11506
	assertResults(
11668
    assertResults(
11507
			"zzfoo[METHOD_REF]{zzfoo(), LCompletionBasicMethod1;, ()V, zzfoo, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11669
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11670
			"foo[VARIABLE_DECLARATION]{foo, null, Ljava.lang.Object;, foo, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
11508
			requestor.getResults());
11671
			requestor.getResults());
11509
}
11672
}
11510
public void testCompletionBasicLocalVariable1() throws JavaModelException {
11673
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
11511
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
11674
public void testCompletionVariableName17() throws JavaModelException {
11512
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBasicLocalVariable1.java");
11675
	this.workingCopies = new ICompilationUnit[1];
11513
11676
	this.workingCopies[0] = getWorkingCopy(
11514
	String str = cu.getSource();
11677
            "/Completion/src/test/Test.java",
11515
	String completeBehind = "zzvar";
11678
            "package test;\n"+
11516
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11679
            "public class Test {\n"+
11517
	cu.codeComplete(cursorLocation, requestor);
11680
            "	void foo(){\n"+
11681
            "		Object foo1;\n"+
11682
            "		/*here*/Object ;\n"+
11683
            "		Object foo3;\n"+
11684
            "		foo1 = null;\n"+
11685
            "		foo2 = null;\n"+
11686
            "		foo3 = null;\n"+
11687
            "	}\n"+
11688
            "}");
11689
    
11690
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11691
    String str = this.workingCopies[0].getSource();
11692
    String completeBehind = "/*here*/Object ";
11693
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11694
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11518
11695
11519
	assertResults(
11696
    assertResults(
11520
			"zzvarzz[LOCAL_VARIABLE_REF]{zzvarzz, null, I, zzvarzz, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11697
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11698
			"foo2[VARIABLE_DECLARATION]{foo2, null, Ljava.lang.Object;, foo2, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
11521
			requestor.getResults());
11699
			requestor.getResults());
11522
}
11700
}
11523
public void testCompletionBasicKeyword1() throws JavaModelException {
11701
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
11524
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
11702
public void testCompletionVariableName18() throws JavaModelException {
11525
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBasicKeyword1.java");
11703
	this.workingCopies = new ICompilationUnit[1];
11526
11704
	this.workingCopies[0] = getWorkingCopy(
11527
	String str = cu.getSource();
11705
            "/Completion/src/test/Test.java",
11528
	String completeBehind = "whil";
11706
            "package test;\n"+
11529
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11707
            "public class Test {\n"+
11530
	cu.codeComplete(cursorLocation, requestor);
11708
            "	void foo(){\n"+
11709
            "		Object ;\n"+
11710
            "		foo = Test.class;\n"+
11711
            "	}\n"+
11712
            "}");
11713
    
11714
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11715
    String str = this.workingCopies[0].getSource();
11716
    String completeBehind = "Object ";
11717
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11718
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11531
11719
11532
	assertResults(
11720
    assertResults(
11533
			"while[KEYWORD]{while, null, null, while, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
11721
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11722
			"foo[VARIABLE_DECLARATION]{foo, null, Ljava.lang.Object;, foo, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
11534
			requestor.getResults());
11723
			requestor.getResults());
11535
}
11724
}
11536
public void testCompletionBasicVariableDeclaration1() throws JavaModelException {
11725
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
11726
public void testCompletionVariableName19() throws JavaModelException {
11537
	this.workingCopies = new ICompilationUnit[1];
11727
	this.workingCopies = new ICompilationUnit[1];
11538
	this.workingCopies[0] = getWorkingCopy(
11728
	this.workingCopies[0] = getWorkingCopy(
11539
		"/Completion/src/CompletionBasicVariableDeclaration1.java",
11729
            "/Completion/src/test/Test.java",
11540
		"public class CompletionBasicVariableDeclaration1 {\n"+
11730
            "package test;\n"+
11541
		"	public Object obj;\n"+
11731
            "public class Test {\n"+
11542
		"}\n");
11732
            "	void foo(){\n"+
11543
	
11733
            "		Object ;\n"+
11544
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11734
            "		object = null;\n"+
11545
	String str = this.workingCopies[0].getSource();
11735
            "	}\n"+
11546
	String completeBehind = "obj";
11736
            "}");
11547
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11737
    
11548
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11738
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11549
	
11739
    String str = this.workingCopies[0].getSource();
11550
	assertResults(
11740
    String completeBehind = "Object ";
11551
		"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED) + "}",
11741
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11552
		requestor.getResults());
11742
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11553
}
11554
public void testCompletionBasicMethodDeclaration1() throws JavaModelException {
11555
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
11556
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBasicMethodDeclaration1.java");
11557
11558
	String str = cu.getSource();
11559
	String completeBehind = "equals";
11560
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11561
	cu.codeComplete(cursorLocation, requestor);
11562
11743
11563
	assertResults(
11744
    assertResults(
11564
			"equals[POTENTIAL_METHOD_DECLARATION]{equals, LCompletionBasicMethodDeclaration1;, ()V, equals, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
11745
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
11565
			"equals[METHOD_DECLARATION]{public boolean equals(Object obj), Ljava.lang.Object;, (Ljava.lang.Object;)Z, equals, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_METHOD_OVERIDE + R_EXACT_NAME + R_NON_RESTRICTED) + "}",
11566
			requestor.getResults());
11746
			requestor.getResults());
11567
}
11747
}
11568
public void testCompletionBasicAnonymousDeclaration1() throws JavaModelException {
11748
/*
11569
	CompletionResult result = complete(
11749
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25811
11570
			"/Completion/src3/test0000/CompletionBasicCompletionContext.java",
11750
*/
11571
			"public class CompletionBasicAnonymousDeclaration1 {\n"+
11751
public void testCompletionVariableName2() throws JavaModelException {
11572
			"	void foo() {\n"+
11752
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11573
			"		new Object(\n"+
11753
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableName2.java");
11574
			"	}\n"+
11575
			"}",
11576
			"new Object(");
11577
	
11578
	assertResults(
11579
			"expectedTypesSignatures=null\n" +
11580
			"expectedTypesKeys=null",
11581
			result.context);
11582
	
11583
	assertResults(
11584
			"Object[ANONYMOUS_CLASS_DECLARATION]{, Ljava.lang.Object;, ()V, null, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
11585
			"Object[METHOD_REF<CONSTRUCTOR>]{, Ljava.lang.Object;, ()V, Object, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}",
11586
			result.proposals);
11587
}
11588
public void testCompletionBasicCompletionContext() throws JavaModelException {
11589
	CompletionResult result = complete(
11590
			"/Completion/src3/test0000/CompletionBasicCompletionContext.java",
11591
			"package test0000;\n" +
11592
			"public class CompletionBasicCompletionContext {\n" +
11593
			"  void bar(String o) {\n" +
11594
			"    String zzz = null; \n" + 
11595
			"    o = zzz\n" + 
11596
			"  }\n" +
11597
			"}",
11598
			"zzz");
11599
	
11600
	assertResults(
11601
			"expectedTypesSignatures={Ljava.lang.String;}\n" +
11602
			"expectedTypesKeys={Ljava/lang/String;}",
11603
			result.context);
11604
	
11605
	assertResults(
11606
			"zzz[LOCAL_VARIABLE_REF]{zzz, null, Ljava.lang.String;, zzz, null, " + (R_DEFAULT + R_INTERESTING + R_CASE +  + R_EXACT_NAME + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11607
			result.proposals);
11608
}
11609
public void testCompletionBasicPotentialMethodDeclaration1() throws JavaModelException {
11610
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
11611
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionBasicPotentialMethodDeclaration1.java");
11612
11754
11613
	String str = cu.getSource();
11755
	String str = cu.getSource();
11614
	String completeBehind = "zzpot";
11756
	String completeBehind = "Test_Bar_MyClass ";
11615
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11757
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11616
	cu.codeComplete(cursorLocation, requestor);
11758
	cu.codeComplete(cursorLocation, requestor);
11617
11759
11618
	assertResults(
11760
	assertEquals(
11619
			"zzpot[POTENTIAL_METHOD_DECLARATION]{zzpot, LCompletionBasicPotentialMethodDeclaration1;, ()V, zzpot, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}",
11761
		"element:bar_MyClass    completion:bar_MyClass    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
11762
		"element:class1    completion:class1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
11763
		"element:myClass    completion:myClass    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
11764
		"element:test_Bar_MyClass    completion:test_Bar_MyClass    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
11765
		requestor.getResults());
11766
}
11767
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
11768
public void testCompletionVariableName20() throws JavaModelException {
11769
	this.workingCopies = new ICompilationUnit[1];
11770
	this.workingCopies[0] = getWorkingCopy(
11771
            "/Completion/src/test/Test.java",
11772
            "package test;\n"+
11773
            "public class Test {\n"+
11774
            "	void foo(){\n"+
11775
            "		/*here*/Object ;\n"+
11776
            "		class X {\n"+
11777
            "		  Object foo1 = foo2;\n"+
11778
            "		  void bar() {\n"+
11779
            "		    foo1 = null;\n"+
11780
            "		    Object foo3 = foo4;\n"+
11781
            "		    foo3 = null;\n"+
11782
            "		  }\n"+
11783
            "		}\n"+
11784
            "		foo5 = null;\n"+
11785
            "	}\n"+
11786
            "}");
11787
    
11788
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11789
    String str = this.workingCopies[0].getSource();
11790
    String completeBehind = "/*here*/Object ";
11791
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11792
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11793
11794
    assertResults(
11795
    		"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11796
    		"foo2[VARIABLE_DECLARATION]{foo2, null, Ljava.lang.Object;, foo2, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}\n"+
11797
    		"foo4[VARIABLE_DECLARATION]{foo4, null, Ljava.lang.Object;, foo4, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}\n"+
11798
			"foo5[VARIABLE_DECLARATION]{foo5, null, Ljava.lang.Object;, foo5, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
11620
			requestor.getResults());
11799
			requestor.getResults());
11621
}
11800
}
11622
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=82740
11801
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
11623
public void testCompletionInsideGenericClass() throws JavaModelException {
11802
public void testCompletionVariableName21() throws JavaModelException {
11624
	this.wc = getWorkingCopy(
11803
	this.workingCopies = new ICompilationUnit[1];
11625
			"/Completion/src/test/CompletionInsideGenericClass.java",
11804
	this.workingCopies[0] = getWorkingCopy(
11626
			"package test;\n" +
11805
            "/Completion/src/test/Test.java",
11627
			"public class CompletionInsideGenericClass <CompletionInsideGenericClassParameter> {\n" +
11806
            "package test;\n"+
11628
			"  CompletionInsideGenericClas\n" +
11807
            "public class Test {\n"+
11629
			"}");
11808
            "	void foo(){\n"+
11630
	
11809
            "		{\n"+
11631
	
11810
            "		  /*here*/Object ;\n"+
11632
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11811
            "		  foo1 = null;\n"+
11633
	String str = this.wc.getSource();
11812
            "		}\n"+
11634
	String completeBehind = "CompletionInsideGenericClas";
11813
            "		foo2 = null;\n"+
11635
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11814
            "	}\n"+
11636
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11815
            "}");
11816
    
11817
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11818
    String str = this.workingCopies[0].getSource();
11819
    String completeBehind = "/*here*/Object ";
11820
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11821
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11637
11822
11638
	assertResults(
11823
    assertResults(
11639
			"CompletionInsideGenericClas[POTENTIAL_METHOD_DECLARATION]{CompletionInsideGenericClas, Ltest.CompletionInsideGenericClass;, ()V, CompletionInsideGenericClas, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
11824
    		"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11640
			"CompletionInsideGenericClass[TYPE_REF]{CompletionInsideGenericClass, test, Ltest.CompletionInsideGenericClass;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11825
			"foo1[VARIABLE_DECLARATION]{foo1, null, Ljava.lang.Object;, foo1, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
11641
			requestor.getResults());
11826
			requestor.getResults());
11642
}
11827
}
11828
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
11829
public void testCompletionVariableName22() throws JavaModelException {
11830
	this.workingCopies = new ICompilationUnit[1];
11831
	this.workingCopies[0] = getWorkingCopy(
11832
            "/Completion/src/test/Test.java",
11833
            "package test;\n"+
11834
            "public class Test {\n"+
11835
            "	void foo(){\n"+
11836
            "		Object foo1;\n"+
11837
            "		/*here*/Object ;\n"+
11838
            "		{\n"+
11839
            "		  Object foo3;\n"+
11840
            "		  foo1 = null;\n"+
11841
            "		  foo2 = null;\n"+
11842
            "		  foo3 = null;\n"+
11843
            "		}\n"+
11844
            "	}\n"+
11845
            "}");
11846
    
11847
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11848
    String str = this.workingCopies[0].getSource();
11849
    String completeBehind = "/*here*/Object ";
11850
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11851
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11643
11852
11644
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
11853
    assertResults(
11645
public void testCompletionInsideExtends1() throws JavaModelException {
11854
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11646
	this.wc = getWorkingCopy(
11855
			"foo2[VARIABLE_DECLARATION]{foo2, null, Ljava.lang.Object;, foo2, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
11647
			"/Completion/src/test/CompletionInsideExtends1.java",
11856
			requestor.getResults());
11648
			"package test;\n" +
11649
			"public class CompletionInsideExtends1 extends  {\n" +
11650
			"  public class CompletionInsideExtends1Inner {}\n" +
11651
			"}\n" +
11652
			"class CompletionInsideExtends1TopLevel {\n" +
11653
			"}");
11654
	
11655
	
11656
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11657
	String str = this.wc.getSource();
11658
	String completeBehind = "extends ";
11659
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11660
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11661
11662
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
11663
		assertResults(
11664
				"",
11665
				requestor.getResults());
11666
	} else {
11667
		assertResults(
11668
				"CompletionInsideExtends1TopLevel[TYPE_REF]{CompletionInsideExtends1TopLevel, test, Ltest.CompletionInsideExtends1TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11669
				requestor.getResults());
11670
	}
11671
	
11672
}
11857
}
11673
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
11858
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
11674
public void testCompletionInsideExtends2() throws JavaModelException {
11859
public void testCompletionVariableName23() throws JavaModelException {
11675
	this.wc = getWorkingCopy(
11860
	this.workingCopies = new ICompilationUnit[1];
11676
			"/Completion/src/test/CompletionInsideExtends2.java",
11861
	this.workingCopies[0] = getWorkingCopy(
11677
			"package test;\n" +
11862
            "/Completion/src/test/Test.java",
11678
			"public class CompletionInsideExtends2 extends CompletionInsideExtends {\n" +
11863
            "package test;\n"+
11679
			"  public class CompletionInsideExtends2Inner {}\n" +
11864
            "public class Test {\n"+
11680
			"}\n" +
11865
            "	void foo(){\n"+
11681
			"class CompletionInsideExtends2TopLevel {\n" +
11866
            "		/*here*/Object ;\n"+
11682
			"}");
11867
            "		foo1 = null;\n"+
11683
	
11868
            "		#\n"+
11684
	
11869
            "	}\n"+
11685
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11870
            "}");
11686
	String str = this.wc.getSource();
11871
    
11687
	String completeBehind = "extends CompletionInsideExtends";
11872
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11688
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11873
    String str = this.workingCopies[0].getSource();
11689
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11874
    String completeBehind = "/*here*/Object ";
11875
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11876
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11690
11877
11691
	assertResults(
11878
    assertResults(
11692
			"CompletionInsideExtends2TopLevel[TYPE_REF]{CompletionInsideExtends2TopLevel, test, Ltest.CompletionInsideExtends2TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11879
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11880
			"foo1[VARIABLE_DECLARATION]{foo1, null, Ljava.lang.Object;, foo1, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
11693
			requestor.getResults());
11881
			requestor.getResults());
11694
}
11882
}
11695
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
11883
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
11696
public void testCompletionInsideExtends3() throws JavaModelException {
11884
public void testCompletionVariableName24() throws JavaModelException {
11697
	this.wc = getWorkingCopy(
11885
	this.workingCopies = new ICompilationUnit[1];
11698
			"/Completion/src/test/CompletionInsideExtends3.java",
11886
	this.workingCopies[0] = getWorkingCopy(
11699
			"package test;\n" +
11887
            "/Completion/src/test/Test.java",
11700
			"public class CompletionInsideExtends3 {\n" +
11888
            "package test;\n"+
11701
			"  public class CompletionInsideExtends3Inner extends {\n" +
11889
            "public class Test {\n"+
11702
			"    public class CompletionInsideExtends3InnerInner {\n" +
11890
            "	void foo(){\n"+
11703
			"    }\n" +
11891
            "		/*here*/Object ;\n"+
11704
			"  }\n" +
11892
            "		#\n"+
11705
			"}\n" +
11893
            "		foo1 = null;\n"+
11706
			"class CompletionInsideExtends3TopLevel {\n" +
11894
            "	}\n"+
11707
			"}");
11895
            "}");
11708
	
11896
    
11709
	
11897
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11710
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11898
    String str = this.workingCopies[0].getSource();
11711
	String str = this.wc.getSource();
11899
    String completeBehind = "/*here*/Object ";
11712
	String completeBehind = "extends ";
11900
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11713
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11901
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11714
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11715
11902
11716
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
11903
    assertResults(
11717
		assertResults(
11904
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11718
				"",
11905
			"foo1[VARIABLE_DECLARATION]{foo1, null, Ljava.lang.Object;, foo1, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
11719
				requestor.getResults());
11906
			requestor.getResults());
11720
	} else {
11721
		assertResults(
11722
				"CompletionInsideExtends3[TYPE_REF]{CompletionInsideExtends3, test, Ltest.CompletionInsideExtends3;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
11723
				"CompletionInsideExtends3TopLevel[TYPE_REF]{CompletionInsideExtends3TopLevel, test, Ltest.CompletionInsideExtends3TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11724
				requestor.getResults());
11725
	}
11726
}
11907
}
11727
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
11908
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
11728
public void testCompletionInsideExtends4() throws JavaModelException {
11909
public void testCompletionVariableName25() throws JavaModelException {
11729
	this.wc = getWorkingCopy(
11910
	this.workingCopies = new ICompilationUnit[1];
11730
			"/Completion/src/test/CompletionInsideExtends4.java",
11911
	this.workingCopies[0] = getWorkingCopy(
11731
			"package test;\n" +
11912
            "/Completion/src/test/Test.java",
11732
			"public class CompletionInsideExtends4 {\n" +
11913
            "package test;\n"+
11733
			"  public class CompletionInsideExtends4Inner extends CompletionInsideExtends{\n" +
11914
            "public class Test {\n"+
11734
			"    public class CompletionInsideExtends4InnerInner {\n" +
11915
            "	void foo(){\n"+
11735
			"    }\n" +
11916
            "		/*here*/Object ;\n"+
11736
			"  }\n" +
11917
            "		#\n"+
11737
			"\n}" +
11918
            "		foo1 = null;\n"+
11738
			"class CompletionInsideExtends4TopLevel {\n" +
11919
            "		#\n"+
11739
			"}");
11920
            "		foo2 = null;\n"+
11740
	
11921
            "	}\n"+
11741
	
11922
            "}");
11742
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11923
    
11743
	String str = this.wc.getSource();
11924
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11744
	String completeBehind = "extends CompletionInsideExtends";
11925
    String str = this.workingCopies[0].getSource();
11745
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11926
    String completeBehind = "/*here*/Object ";
11746
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11927
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11928
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11747
11929
11748
	assertResults(
11930
    assertResults(
11749
			"CompletionInsideExtends4[TYPE_REF]{CompletionInsideExtends4, test, Ltest.CompletionInsideExtends4;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
11931
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11750
			"CompletionInsideExtends4TopLevel[TYPE_REF]{CompletionInsideExtends4TopLevel, test, Ltest.CompletionInsideExtends4TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11932
			"foo1[VARIABLE_DECLARATION]{foo1, null, Ljava.lang.Object;, foo1, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}\n"+
11933
    		"foo2[VARIABLE_DECLARATION]{foo2, null, Ljava.lang.Object;, foo2, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
11751
			requestor.getResults());
11934
			requestor.getResults());
11752
}
11935
}
11753
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
11936
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
11754
public void testCompletionInsideExtends5() throws JavaModelException {
11937
public void testCompletionVariableName26() throws JavaModelException {
11755
	this.wc = getWorkingCopy(
11938
	this.workingCopies = new ICompilationUnit[1];
11756
			"/Completion/src/test/CompletionInsideExtends5.java",
11939
	this.workingCopies[0] = getWorkingCopy(
11757
			"package test;\n" +
11940
            "/Completion/src/test/Test.java",
11758
			"public class CompletionInsideExtends5 {\n" +
11941
            "package test;\n"+
11759
			"  void foo() {\n" +
11942
            "public class Test {\n"+
11760
			"    public class CompletionInsideExtends5Inner extends {\n" +
11943
            "	void foo(){\n"+
11761
			"      public class CompletionInsideExtends5InnerInner {\n" +
11944
            "		/*here*/Object ;\n"+
11762
			"      }\n" +
11945
            "		#\n"+
11763
			"    }\n" +
11946
            "		foo1 = null;\n"+
11764
			"  }\n" +
11947
            "		#\n"+
11765
			"}\n" +
11948
            "		foo2 = null;\n"+
11766
			"class CompletionInsideExtends5TopLevel {\n" +
11949
            "		#\n"+
11767
			"}");
11950
            "	}\n"+
11768
	
11951
            "}");
11769
	
11952
    
11770
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11953
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11771
	String str = this.wc.getSource();
11954
    String str = this.workingCopies[0].getSource();
11772
	String completeBehind = "extends ";
11955
    String completeBehind = "/*here*/Object ";
11773
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11956
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11774
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11957
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11775
11958
11776
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
11959
    assertResults(
11777
		assertResults(
11960
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11778
				"",
11961
			"foo1[VARIABLE_DECLARATION]{foo1, null, Ljava.lang.Object;, foo1, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}\n"+
11779
				requestor.getResults());
11962
    		"foo2[VARIABLE_DECLARATION]{foo2, null, Ljava.lang.Object;, foo2, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
11780
	} else {
11963
			requestor.getResults());
11781
		assertResults(
11782
				"CompletionInsideExtends5[TYPE_REF]{CompletionInsideExtends5, test, Ltest.CompletionInsideExtends5;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
11783
				"CompletionInsideExtends5TopLevel[TYPE_REF]{CompletionInsideExtends5TopLevel, test, Ltest.CompletionInsideExtends5TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11784
				requestor.getResults());
11785
	}
11786
}
11964
}
11787
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
11965
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
11788
public void testCompletionInsideExtends6() throws JavaModelException {
11966
public void testCompletionVariableName27() throws JavaModelException {
11789
	this.wc = getWorkingCopy(
11967
	this.workingCopies = new ICompilationUnit[1];
11790
			"/Completion/src/test/CompletionInsideExtends6.java",
11968
	this.workingCopies[0] = getWorkingCopy(
11791
			"package test;\n" +
11969
            "/Completion/src/test/Test.java",
11792
			"public class CompletionInsideExtends6 {\n" +
11970
            "package test;\n"+
11793
			"  void foo() {\n" +
11971
            "public class Test {\n"+
11794
			"    public class CompletionInsideExtends6Inner extends CompletionInsideExtends {\n" +
11972
            "	void foo(){\n"+
11795
			"      public class CompletionInsideExtends6InnerInner {\n" +
11973
            "		/*here*/Object ;\n"+
11796
			"      }\n" +
11974
            "		Object foo0 = null;\n"+
11797
			"    }\n" +
11975
            "		foo0 = null;\n"+
11798
			"  }\n" +
11976
            "		#\n"+
11799
			"}\n" +
11977
            "		class X {\n"+
11800
			"class CompletionInsideExtends6TopLevel {\n" +
11978
            "		  Object foo1 = foo2;\n"+
11801
			"}");
11979
            "		  void bar() {\n"+
11802
	
11980
            "		    foo1 = null;\n"+
11803
	
11981
            "		    Object foo3 = foo4;\n"+
11804
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11982
            "		    foo3 = null;\n"+
11805
	String str = this.wc.getSource();
11983
            "		  }\n"+
11806
	String completeBehind = "extends CompletionInsideExtends";
11984
            "		}\n"+
11807
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11985
            "		foo5 = null;\n"+
11808
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11986
            "	}\n"+
11987
            "}");
11988
    
11989
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11990
    String str = this.workingCopies[0].getSource();
11991
    String completeBehind = "/*here*/Object ";
11992
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11993
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11809
11994
11810
	assertResults(
11995
    assertResults(
11811
			"CompletionInsideExtends6[TYPE_REF]{CompletionInsideExtends6, test, Ltest.CompletionInsideExtends6;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
11996
    		"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11812
			"CompletionInsideExtends6TopLevel[TYPE_REF]{CompletionInsideExtends6TopLevel, test, Ltest.CompletionInsideExtends6TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11997
    		"foo2[VARIABLE_DECLARATION]{foo2, null, Ljava.lang.Object;, foo2, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}\n"+
11998
    		"foo4[VARIABLE_DECLARATION]{foo4, null, Ljava.lang.Object;, foo4, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}\n"+
11999
			"foo5[VARIABLE_DECLARATION]{foo5, null, Ljava.lang.Object;, foo5, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
11813
			requestor.getResults());
12000
			requestor.getResults());
11814
}
12001
}
11815
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
12002
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
11816
public void testCompletionInsideExtends7() throws JavaModelException {
12003
public void testCompletionVariableName28() throws JavaModelException {
11817
	this.wc = getWorkingCopy(
12004
	this.workingCopies = new ICompilationUnit[1];
11818
			"/Completion/src/test/CompletionInsideExtends7.java",
12005
	this.workingCopies[0] = getWorkingCopy(
11819
			"package test;\n" +
12006
            "/Completion/src/test/Test.java",
11820
			"public interface CompletionInsideExtends7 extends  {\n" +
12007
            "package test;\n"+
11821
			"  public interface CompletionInsideExtends7Inner {}\n" +
12008
            "public class Test {\n"+
11822
			"}\n" +
12009
            "	void foo(){\n"+
11823
			"interface CompletionInsideExtends7TopLevel {\n" +
12010
            "		/*here*/Object ;\n"+
11824
			"}");
12011
            "		Object foo1 = null;\n"+
11825
	
12012
            "		foo1.foo2 = null;\n"+
11826
	
12013
            "		foo3.foo4 = null;\n"+
11827
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12014
            "	}\n"+
11828
	String str = this.wc.getSource();
12015
            "}");
11829
	String completeBehind = "extends ";
12016
    
11830
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12017
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11831
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12018
    String str = this.workingCopies[0].getSource();
12019
    String completeBehind = "/*here*/Object ";
12020
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12021
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11832
12022
11833
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
12023
    assertResults(
11834
		assertResults(
12024
    		"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11835
				"",
12025
    		"foo3[VARIABLE_DECLARATION]{foo3, null, Ljava.lang.Object;, foo3, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
11836
				requestor.getResults());
12026
			requestor.getResults());
11837
	} else {
11838
		assertResults(
11839
				"CompletionInsideExtends7TopLevel[TYPE_REF]{CompletionInsideExtends7TopLevel, test, Ltest.CompletionInsideExtends7TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11840
				requestor.getResults());
11841
	}
11842
}
12027
}
11843
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
12028
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
11844
public void testCompletionInsideExtends8() throws JavaModelException {
12029
public void testCompletionVariableName29() throws JavaModelException {
11845
	this.wc = getWorkingCopy(
12030
	this.workingCopies = new ICompilationUnit[1];
11846
			"/Completion/src/test/CompletionInsideExtends8.java",
12031
	this.workingCopies[0] = getWorkingCopy(
11847
			"package test;\n" +
12032
            "/Completion/src/test/Test.java",
11848
			"public interface CompletionInsideExtends8 extends CompletionInsideExtends {\n" +
12033
            "package test;\n"+
11849
			"  public interface CompletionInsideExtends8Inner {}\n" +
12034
            "public class Test {\n"+
11850
			"}\n" +
12035
            "	void foo(){\n"+
11851
			"interface CompletionInsideExtends8TopLevel {\n" +
12036
            "		/*here*/Object ;\n"+
11852
			"}");
12037
            "		class X {\n"+
11853
	
12038
            "			void bar1() {\n"+
11854
	
12039
            "				var1 = null;\n"+
11855
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12040
            "			}\n"+
11856
	String str = this.wc.getSource();
12041
            "			void bar2() {\n"+
11857
	String completeBehind = "extends CompletionInsideExtends";
12042
            "				Object var2 = null;\n"+
11858
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12043
            "				var2 = null;\n"+
11859
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12044
            "			}\n"+
12045
            "			void bar3() {\n"+
12046
            "				Object var3 = null;\n"+
12047
            "				{\n"+
12048
            "					var3 = null;\n"+
12049
            "					Object var4 = null;\n"+
12050
            "				}\n"+
12051
            "				var4 = null;\n"+
12052
            "			}\n"+
12053
            "		}\n"+
12054
            "	}\n"+
12055
            "}");
12056
    
12057
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12058
    String str = this.workingCopies[0].getSource();
12059
    String completeBehind = "/*here*/Object ";
12060
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12061
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11860
12062
11861
	assertResults(
12063
    assertResults(
11862
			"CompletionInsideExtends8TopLevel[TYPE_REF]{CompletionInsideExtends8TopLevel, test, Ltest.CompletionInsideExtends8TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12064
    		"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
12065
    		"var1[VARIABLE_DECLARATION]{var1, null, Ljava.lang.Object;, var1, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}\n"+
12066
			"var4[VARIABLE_DECLARATION]{var4, null, Ljava.lang.Object;, var4, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
11863
			requestor.getResults());
12067
			requestor.getResults());
11864
}
12068
}
11865
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
12069
public void testCompletionVariableName3() throws JavaModelException {
11866
public void testCompletionInsideExtends9() throws JavaModelException {
12070
	Hashtable options = JavaCore.getOptions();
11867
	this.wc = getWorkingCopy(
12071
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
11868
			"/Completion/src/test/CompletionInsideExtends9.java",
12072
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"p1,p2"); //$NON-NLS-1$
11869
			"package test;\n" +
12073
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
11870
			"public interface CompletionInsideExtends9 {\n" +
12074
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"s1,s2"); //$NON-NLS-1$
11871
			"  public interface CompletionInsideExtends9Inner extends {\n" +
11872
			"    public interface CompletionInsideExtends9InnerInner {\n" +
11873
			"    }\n" +
11874
			"  }\n" +
11875
			"}\n" +
11876
			"interface CompletionInsideExtends9TopLevel {\n" +
11877
			"}");
11878
	
11879
	
12075
	
11880
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12076
	JavaCore.setOptions(options);
11881
	String str = this.wc.getSource();
11882
	String completeBehind = "extends ";
11883
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11884
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11885
12077
11886
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
12078
	try {
11887
		assertResults(
12079
		CompletionTestsRequestor requestor = new CompletionTestsRequestor();
11888
				"",
12080
		ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableName3.java");
11889
				requestor.getResults());
11890
	} else {
11891
		assertResults(
11892
				"CompletionInsideExtends9[TYPE_REF]{CompletionInsideExtends9, test, Ltest.CompletionInsideExtends9;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
11893
				"CompletionInsideExtends9TopLevel[TYPE_REF]{CompletionInsideExtends9TopLevel, test, Ltest.CompletionInsideExtends9TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11894
				requestor.getResults());
11895
	}
11896
}
11897
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
11898
public void testCompletionInsideExtends10() throws JavaModelException {
11899
	this.wc = getWorkingCopy(
11900
			"/Completion/src/test/CompletionInsideExtends10.java",
11901
			"package test;\n" +
11902
			"public interface CompletionInsideExtends10 {\n" +
11903
			"  public interface CompletionInsideExtends10Inner extends CompletionInsideExtends{\n" +
11904
			"    public interface CompletionInsideExtends10InnerInner {\n" +
11905
			"    }\n" +
11906
			"  }\n" +
11907
			"}\n" +
11908
			"interface CompletionInsideExtends10TopLevel {\n" +
11909
			"}");
11910
	
12081
	
12082
		String str = cu.getSource();
12083
		String completeBehind = "OneName ";
12084
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12085
		cu.codeComplete(cursorLocation, requestor);
11911
	
12086
	
11912
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12087
		assertEquals(
11913
	String str = this.wc.getSource();
12088
			"element:name    completion:name    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
11914
	String completeBehind = "extends CompletionInsideExtends";
12089
			"element:names1    completion:names1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"\n"+
11915
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12090
			"element:names2    completion:names2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_SUFFIX + R_NON_RESTRICTED)+"\n"+
11916
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12091
			"element:oneName    completion:oneName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n"+
12092
			"element:oneNames1    completion:oneNames1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"\n"+
12093
			"element:oneNames2    completion:oneNames2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_SUFFIX + R_NON_RESTRICTED)+"\n"+
12094
			"element:p1Name    completion:p1Name    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NON_RESTRICTED)+"\n"+
12095
			"element:p1Names1    completion:p1Names1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"\n"+
12096
			"element:p1Names2    completion:p1Names2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NAME_SUFFIX + R_NON_RESTRICTED)+"\n"+
12097
			"element:p1OneName    completion:p1OneName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NON_RESTRICTED)+"\n"+
12098
			"element:p1OneNames1    completion:p1OneNames1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"\n"+
12099
			"element:p1OneNames2    completion:p1OneNames2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_PREFIX + R_NAME_SUFFIX + R_NON_RESTRICTED)+"\n"+
12100
			"element:p2Name    completion:p2Name    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_PREFIX + R_NON_RESTRICTED)+"\n"+
12101
			"element:p2Names1    completion:p2Names1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"\n"+
12102
			"element:p2Names2    completion:p2Names2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_PREFIX + R_NAME_SUFFIX + R_NON_RESTRICTED)+"\n"+
12103
			"element:p2OneName    completion:p2OneName    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_PREFIX + R_NON_RESTRICTED)+"\n"+
12104
			"element:p2OneNames1    completion:p2OneNames1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_PREFIX + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"\n"+
12105
			"element:p2OneNames2    completion:p2OneNames2    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_PREFIX + R_NAME_SUFFIX+ R_NON_RESTRICTED),
12106
			requestor.getResults());
12107
	} finally {
12108
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
12109
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
12110
		JavaCore.setOptions(options);
12111
	}
12112
}
12113
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
12114
public void testCompletionVariableName30() throws JavaModelException {
12115
	this.workingCopies = new ICompilationUnit[1];
12116
	this.workingCopies[0] = getWorkingCopy(
12117
            "/Completion/src/test/Test.java",
12118
            "package test;\n"+
12119
            "public class Test {\n"+
12120
            "	public Test(){\n"+
12121
            "		Object ;\n"+
12122
            "		foo = null;\n"+
12123
            "	}\n"+
12124
            "}");
12125
    
12126
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12127
    String str = this.workingCopies[0].getSource();
12128
    String completeBehind = "Object ";
12129
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12130
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11917
12131
11918
	assertResults(
12132
    assertResults(
11919
			"CompletionInsideExtends10.CompletionInsideExtends10Inner.CompletionInsideExtends10InnerInner[TYPE_REF]{test.CompletionInsideExtends10.CompletionInsideExtends10Inner.CompletionInsideExtends10InnerInner, test, Ltest.CompletionInsideExtends10$CompletionInsideExtends10Inner$CompletionInsideExtends10InnerInner;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_NON_RESTRICTED) + "}\n" +
12133
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11920
			"CompletionInsideExtends10[TYPE_REF]{CompletionInsideExtends10, test, Ltest.CompletionInsideExtends10;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12134
			"foo[VARIABLE_DECLARATION]{foo, null, Ljava.lang.Object;, foo, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
11921
			"CompletionInsideExtends10TopLevel[TYPE_REF]{CompletionInsideExtends10TopLevel, test, Ltest.CompletionInsideExtends10TopLevel;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CLASS + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
11922
			requestor.getResults());
12135
			requestor.getResults());
11923
}
12136
}
11924
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
12137
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
11925
public void testCompletionInsideExtends11() throws JavaModelException {
12138
public void testCompletionVariableName31() throws JavaModelException {
11926
	this.wc = getWorkingCopy(
12139
	this.workingCopies = new ICompilationUnit[1];
11927
			"/Completion/src/test/CompletionInsideExtends11.java",
12140
	this.workingCopies[0] = getWorkingCopy(
11928
			"package test;\n" +
12141
            "/Completion/src/test/Test.java",
11929
			"public class CompletionInsideExtends11 implements {\n" +
12142
            "package test;\n"+
11930
			"  public class CompletionInsideExtends11Inner {\n" +
12143
            "public class Test {\n"+
11931
			"  }\n" +
12144
            "	{\n"+
11932
			"}\n" +
12145
            "		Object ;\n"+
11933
			"class CompletionInsideExtends11TopLevel {\n" +
12146
            "		foo = null;\n"+
11934
			"}");
12147
            "	}\n"+
11935
	
12148
            "}");
11936
	
12149
    
11937
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12150
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11938
	String str = this.wc.getSource();
12151
    String str = this.workingCopies[0].getSource();
11939
	String completeBehind = "implements ";
12152
    String completeBehind = "Object ";
11940
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12153
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11941
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12154
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11942
12155
11943
	if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
12156
    assertResults(
11944
		assertResults(
12157
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11945
				"",
12158
			"foo[VARIABLE_DECLARATION]{foo, null, Ljava.lang.Object;, foo, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
11946
				requestor.getResults());
12159
			requestor.getResults());
11947
	} else {
11948
		assertResults(
11949
				"",
11950
				requestor.getResults());
11951
	}
11952
}
12160
}
11953
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=78151
12161
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
11954
public void testCompletionInsideExtends12() throws JavaModelException {
12162
public void testCompletionVariableName32() throws JavaModelException {
11955
	this.wc = getWorkingCopy(
12163
	this.workingCopies = new ICompilationUnit[1];
11956
			"/Completion/src/test/CompletionInsideExtends12.java",
12164
	this.workingCopies[0] = getWorkingCopy(
11957
			"package test;\n" +
12165
            "/Completion/src/test/Test.java",
11958
			"public class CompletionInsideExtends12 implements CompletionInsideExtends {\n" +
12166
            "package test;\n"+
11959
			"  public class CompletionInsideExtends12Inner {\n" +
12167
            "public class Test {\n"+
11960
			"  }\n" +
12168
            "	void bar(Object ) {\n"+
11961
			"}\n" +
12169
            "		foo = null;\n"+
11962
			"class CompletionInsideExtends12TopLevel {\n" +
12170
            "	}\n"+
11963
			"}");
12171
            "}");
11964
	
12172
    
11965
	
12173
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11966
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12174
    String str = this.workingCopies[0].getSource();
11967
	String str = this.wc.getSource();
12175
    String completeBehind = "Object ";
11968
	String completeBehind = "implements CompletionInsideExtends";
12176
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11969
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12177
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11970
	this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
11971
12178
11972
	assertResults(
12179
    assertResults(
11973
			"",
12180
			"object[VARIABLE_DECLARATION]{object, null, Ljava.lang.Object;, object, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
12181
			"foo[VARIABLE_DECLARATION]{foo, null, Ljava.lang.Object;, foo, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
11974
			requestor.getResults());
12182
			requestor.getResults());
11975
}
12183
}
11976
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=84690
12184
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=162743
11977
public void testCompletionArrayLength() throws JavaModelException {
12185
public void testCompletionVariableName33() throws JavaModelException {
11978
    this.wc = getWorkingCopy(
12186
	this.workingCopies = new ICompilationUnit[1];
11979
            "/Completion/src/test/CompletionArrayLength.java",
12187
	this.workingCopies[0] = getWorkingCopy(
11980
            "package test;\n" +
12188
            "/Completion/src/test/Test.java",
11981
            "public class CompletionArrayLength {\n" +
12189
            "package test;\n"+
11982
            "  public void foo() {\n" +
12190
            "public class Test {\n"+
11983
            "    long[] var;\n" +
12191
            "	void bar() {\n"+
11984
            "    var.leng\n" +
12192
            "		/**/int v\n"+
11985
            "  }" +
12193
            "		variable = null;\n"+
12194
            "		variable = null;\n"+
12195
            "		variable = null;\n"+
12196
            "	}\n"+
11986
            "}");
12197
            "}");
11987
    
12198
    
12199
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12200
    String str = this.workingCopies[0].getSource();
12201
    String completeBehind = "/**/int v";
12202
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12203
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12204
12205
    assertResults(
12206
			"vI[VARIABLE_DECLARATION]{vI, null, I, vI, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
12207
			"variable[VARIABLE_DECLARATION]{variable, null, I, variable, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
12208
			requestor.getResults());
12209
}
12210
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=162968
12211
public void testCompletionVariableName34() throws JavaModelException {
12212
	this.workingCopies = new ICompilationUnit[1];
12213
	this.workingCopies[0] = getWorkingCopy(
12214
            "/Completion/src/test/Test.java",
12215
            "package test;\n"+
12216
            "public class Test {\n"+
12217
            "	int vDefined;\n"+
12218
            "	void bar() {\n"+
12219
            "		/**/int v\n"+
12220
            "		System.out.println(vUnknown);\n"+
12221
            "		System.out.println(vUnknown);\n"+
12222
            "	}\n"+
12223
            "}");
11988
    
12224
    
11989
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12225
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
11990
    String str = this.wc.getSource();
12226
    String str = this.workingCopies[0].getSource();
11991
    String completeBehind = "leng";
12227
    String completeBehind = "/**/int v";
11992
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12228
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
11993
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12229
    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
11994
12230
11995
    assertResults(
12231
    assertResults(
11996
            "length[FIELD_REF]{length, [J, I, length, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
12232
			"vI[VARIABLE_DECLARATION]{vI, null, I, vI, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
11997
            requestor.getResults());
12233
			"vUnknown[VARIABLE_DECLARATION]{vUnknown, null, I, vUnknown, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_NAME_FIRST_PREFIX + R_NAME_LESS_NEW_CHARACTERS + R_CASE + R_NON_RESTRICTED)+"}",
12234
			requestor.getResults());
11998
}
12235
}
11999
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=84690
12236
public void testCompletionVariableName4() throws JavaModelException {
12000
public void testCompletionArrayClone() throws JavaModelException {
12237
	this.wc = getWorkingCopy(
12001
    this.wc = getWorkingCopy(
12238
            "/Completion/src/CompletionVariableName4.java",
12002
            "/Completion/src/test/CompletionArrayClone.java",
12239
            "class FooBar {\n"+
12003
            "package test;\n" +
12240
            "}\n"+
12004
            "public class CompletionArrayClone {\n" +
12241
            "public class CompletionVariableName4 {\n"+
12005
            "  public void foo() {\n" +
12242
            "	void foo(){\n"+
12006
            "    long[] var;\n" +
12243
            "		FooBar the\n"+
12007
            "    var.clon\n" +
12244
            "	}\n"+
12008
            "  }\n" +
12009
            "}");
12245
            "}");
12010
    
12246
    
12011
    
12247
    
12012
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12248
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12013
    String str = this.wc.getSource();
12249
    String str = this.wc.getSource();
12014
    String completeBehind = "clon";
12250
    String completeBehind = "the";
12015
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12251
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12016
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12252
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12017
12253
12018
    assertResults(
12254
    assertResults(
12019
            "clone[METHOD_REF]{clone(), [J, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}",
12255
    		"theBar[VARIABLE_DECLARATION]{theBar, null, LFooBar;, theBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
12020
            requestor.getResults());
12256
			"theFooBar[VARIABLE_DECLARATION]{theFooBar, null, LFooBar;, theFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
12257
			requestor.getResults());
12021
}
12258
}
12022
public void testCompletionAllMemberTypes() throws JavaModelException {
12259
public void testCompletionVariableName5() throws JavaModelException {
12023
    this.wc = getWorkingCopy(
12260
	this.wc = getWorkingCopy(
12024
            "/Completion/src/test/CompletionAllMemberTypes.java",
12261
            "/Completion/src/CompletionVariableName5.java",
12025
            "package test;\n" +
12262
            "class FooBar {\n"+
12026
            "public class CompletionAllMemberTypes {\n" +
12263
            "}\n"+
12027
            "  class Member1 {\n" +
12264
            "public class CompletionVariableName5 {\n"+
12028
            "    class Member2 {\n" +
12265
            "	void foo(){\n"+
12029
            "      class Member3 {\n" +
12266
            "		FooBar thefo\n"+
12030
            "      }\n" +
12267
            "	}\n"+
12031
            "    }\n" +
12032
            "    void foo(){\n" +
12033
            "      Member\n" +
12034
            "    }\n" +
12035
            "  \n}" +
12036
            "}");
12268
            "}");
12037
    
12269
    
12038
    
12270
    
12039
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12271
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12040
    String str = this.wc.getSource();
12272
    String str = this.wc.getSource();
12041
    String completeBehind = "Member";
12273
    String completeBehind = "thefo";
12042
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12274
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12043
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12275
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12044
12276
12045
	assertResults(
12277
    assertResults(
12046
            "CompletionAllMemberTypes.Member1.Member2.Member3[TYPE_REF]{test.CompletionAllMemberTypes.Member1.Member2.Member3, test, Ltest.CompletionAllMemberTypes$Member1$Member2$Member3;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12278
    		"thefoBar[VARIABLE_DECLARATION]{thefoBar, null, LFooBar;, thefoBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
12047
			"CompletionAllMemberTypes.Member1[TYPE_REF]{Member1, test, Ltest.CompletionAllMemberTypes$Member1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12279
			"theFooBar[VARIABLE_DECLARATION]{theFooBar, null, LFooBar;, theFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}",
12048
			"CompletionAllMemberTypes.Member1.Member2[TYPE_REF]{Member2, test, Ltest.CompletionAllMemberTypes$Member1$Member2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12280
			requestor.getResults());
12049
            requestor.getResults());
12050
}
12281
}
12051
public void testCompletionAllMemberTypes2() throws JavaModelException {
12282
public void testCompletionVariableName6() throws JavaModelException {
12052
    this.wc = getWorkingCopy(
12283
	this.wc = getWorkingCopy(
12053
            "/Completion/src/test/CompletionAllMemberTypes2.java",
12284
            "/Completion/src/CompletionVariableName6.java",
12054
            "package test;\n" +
12285
            "class FooBar {\n"+
12055
            "public class CompletionAllMemberTypes2 {\n" +
12286
            "}\n"+
12056
            "  class Member1 {\n" +
12287
            "public class CompletionVariableName6 {\n"+
12057
            "    class Member5 {\n" +
12288
            "	void foo(){\n"+
12058
            "      class Member6 {\n" +
12289
            "		FooBar theba\n"+
12059
            "      }\n" +
12290
            "	}\n"+
12060
            "    }\n" +
12061
            "    class Member2 {\n" +
12062
            "      class Member3 {\n" +
12063
            "        class Member4 {\n" +
12064
            "        }\n" +
12065
            "      }\n" +
12066
            "      void foo(){\n" +
12067
            "        Member\n" +
12068
            "      }\n" +
12069
            "    }\n" +
12070
            "  \n}" +
12071
            "}");
12291
            "}");
12072
    
12292
    
12073
    
12293
    
12074
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12294
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12075
    String str = this.wc.getSource();
12295
    String str = this.wc.getSource();
12076
    String completeBehind = "Member";
12296
    String completeBehind = "theba";
12077
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12297
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12078
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12298
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12079
12299
12080
	assertResults(
12300
    assertResults(
12081
            "CompletionAllMemberTypes2.Member1.Member2.Member3.Member4[TYPE_REF]{test.CompletionAllMemberTypes2.Member1.Member2.Member3.Member4, test, Ltest.CompletionAllMemberTypes2$Member1$Member2$Member3$Member4;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12301
    		"thebaFooBar[VARIABLE_DECLARATION]{thebaFooBar, null, LFooBar;, thebaFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
12082
			"CompletionAllMemberTypes2.Member1.Member5.Member6[TYPE_REF]{test.CompletionAllMemberTypes2.Member1.Member5.Member6, test, Ltest.CompletionAllMemberTypes2$Member1$Member5$Member6;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12302
			"theBar[VARIABLE_DECLARATION]{theBar, null, LFooBar;, theBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}",
12083
			"CompletionAllMemberTypes2.Member1[TYPE_REF]{Member1, test, Ltest.CompletionAllMemberTypes2$Member1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12303
			requestor.getResults());
12084
			"CompletionAllMemberTypes2.Member1.Member2[TYPE_REF]{Member2, test, Ltest.CompletionAllMemberTypes2$Member1$Member2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12085
			"CompletionAllMemberTypes2.Member1.Member2.Member3[TYPE_REF]{Member3, test, Ltest.CompletionAllMemberTypes2$Member1$Member2$Member3;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12086
			"CompletionAllMemberTypes2.Member1.Member5[TYPE_REF]{Member5, test, Ltest.CompletionAllMemberTypes2$Member1$Member5;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12087
            requestor.getResults());
12088
}
12304
}
12089
public void testCompletionAllMemberTypes3() throws JavaModelException {
12305
public void testCompletionVariableName7() throws JavaModelException {
12090
    this.wc = getWorkingCopy(
12306
	this.wc = getWorkingCopy(
12091
            "/Completion/src/test/CompletionAllMemberTypes2.java",
12307
            "/Completion/src/CompletionVariableName7.java",
12092
            "package test;\n" +
12308
            "class FooBar {\n"+
12093
            "public interface CompletionAllMemberTypes2 {\n" +
12309
            "}\n"+
12094
            "  interface Member1 {\n" +
12310
            "public class CompletionVariableName7 {\n"+
12095
            "    interface Member5 {\n" +
12311
            "	void foo(){\n"+
12096
            "      interface Member6 {\n" +
12312
            "		FooBar fo\n"+
12097
            "      }\n" +
12313
            "	}\n"+
12098
            "    }\n" +
12099
            "    interface Member2 {\n" +
12100
            "      interface Member3 {\n" +
12101
            "        interface Member4 {\n" +
12102
            "        }\n" +
12103
            "      }\n" +
12104
            "        Member\n" +
12105
            "    }\n" +
12106
            "  \n}" +
12107
            "}");
12314
            "}");
12108
    
12315
    
12109
    
12316
    
12110
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12317
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12111
    String str = this.wc.getSource();
12318
    String str = this.wc.getSource();
12112
    String completeBehind = "Member";
12319
    String completeBehind = "fo";
12113
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12320
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12114
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12321
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12115
12322
12116
	assertResults(
12323
    assertResults(
12117
            "Member[POTENTIAL_METHOD_DECLARATION]{Member, Ltest.CompletionAllMemberTypes2$Member1$Member2;, ()V, Member, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
12324
			"foBar[VARIABLE_DECLARATION]{foBar, null, LFooBar;, foBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
12118
			"CompletionAllMemberTypes2.Member1.Member2.Member3.Member4[TYPE_REF]{test.CompletionAllMemberTypes2.Member1.Member2.Member3.Member4, test, Ltest.CompletionAllMemberTypes2$Member1$Member2$Member3$Member4;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12325
			"fooBar[VARIABLE_DECLARATION]{fooBar, null, LFooBar;, fooBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}",
12119
			"CompletionAllMemberTypes2.Member1.Member5.Member6[TYPE_REF]{test.CompletionAllMemberTypes2.Member1.Member5.Member6, test, Ltest.CompletionAllMemberTypes2$Member1$Member5$Member6;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12326
			requestor.getResults());
12120
			"CompletionAllMemberTypes2.Member1[TYPE_REF]{Member1, test, Ltest.CompletionAllMemberTypes2$Member1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12121
			"CompletionAllMemberTypes2.Member1.Member2[TYPE_REF]{Member2, test, Ltest.CompletionAllMemberTypes2$Member1$Member2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12122
			"CompletionAllMemberTypes2.Member1.Member2.Member3[TYPE_REF]{Member3, test, Ltest.CompletionAllMemberTypes2$Member1$Member2$Member3;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12123
			"CompletionAllMemberTypes2.Member1.Member5[TYPE_REF]{Member5, test, Ltest.CompletionAllMemberTypes2$Member1$Member5;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12124
            requestor.getResults());
12125
}
12126
public void testCompletionAllMemberTypes4() throws JavaModelException {
12127
	ICompilationUnit anInterface = null;
12128
	try {
12129
		anInterface = getWorkingCopy(
12130
	            "/Completion/src/test/AnInterface.java",
12131
	            "package test;\n" +
12132
	            "public interface AnInterface {\n" +
12133
	            "  public interface Member1 {\n" +
12134
	            "    public interface Member5 {\n" +
12135
	            "      public interface Member6 {\n" +
12136
	            "      }\n" +
12137
	            "    }\n" +
12138
	            "    public interface Member2 {\n" +
12139
	            "      public interface Member3 {\n" +
12140
	            "        interface Member4 {\n" +
12141
	            "        }\n" +
12142
	            "      }\n" +
12143
	            "        Member\n" +
12144
	            "    }\n" +
12145
	            "  \n}" +
12146
	            "}");
12147
		
12148
	    this.wc = getWorkingCopy(
12149
	            "/Completion/src/test/CompletionAllMemberTypes2.java",
12150
	            "package test;\n" +
12151
	            "public class CompletionAllMemberTypes2 {\n" +
12152
	            "  class Member1 {\n" +
12153
	            "    class Member5 {\n" +
12154
	            "      class Member6 {\n" +
12155
	            "      }\n" +
12156
	            "    }\n" +
12157
	            "    class Member2 implements AnInterface {\n" +
12158
	            "      class Member3 {\n" +
12159
	            "        class Member4 {\n" +
12160
	            "        }\n" +
12161
	            "      }\n" +
12162
	            "      void foo(){\n" +
12163
	            "        Member\n" +
12164
	            "      }\n" +
12165
	            "    }\n" +
12166
	            "  \n}" +
12167
	            "}");
12168
	    
12169
	    
12170
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12171
	    String str = this.wc.getSource();
12172
	    String completeBehind = "Member";
12173
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12174
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12175
	
12176
    	assertResults(
12177
	            "AnInterface.Member1.Member2[TYPE_REF]{test.AnInterface.Member1.Member2, test, Ltest.AnInterface$Member1$Member2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12178
				"AnInterface.Member1.Member2.Member3[TYPE_REF]{test.AnInterface.Member1.Member2.Member3, test, Ltest.AnInterface$Member1$Member2$Member3;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12179
				"AnInterface.Member1.Member2.Member3.Member4[TYPE_REF]{test.AnInterface.Member1.Member2.Member3.Member4, test, Ltest.AnInterface$Member1$Member2$Member3$Member4;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12180
				"AnInterface.Member1.Member5[TYPE_REF]{test.AnInterface.Member1.Member5, test, Ltest.AnInterface$Member1$Member5;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12181
				"AnInterface.Member1.Member5.Member6[TYPE_REF]{test.AnInterface.Member1.Member5.Member6, test, Ltest.AnInterface$Member1$Member5$Member6;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12182
				"CompletionAllMemberTypes2.Member1.Member2.Member3.Member4[TYPE_REF]{test.CompletionAllMemberTypes2.Member1.Member2.Member3.Member4, test, Ltest.CompletionAllMemberTypes2$Member1$Member2$Member3$Member4;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12183
				"CompletionAllMemberTypes2.Member1.Member5.Member6[TYPE_REF]{test.CompletionAllMemberTypes2.Member1.Member5.Member6, test, Ltest.CompletionAllMemberTypes2$Member1$Member5$Member6;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12184
				"AnInterface.Member1[TYPE_REF]{Member1, test, Ltest.AnInterface$Member1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12185
				"CompletionAllMemberTypes2.Member1[TYPE_REF]{Member1, test, Ltest.CompletionAllMemberTypes2$Member1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12186
				"CompletionAllMemberTypes2.Member1.Member2[TYPE_REF]{Member2, test, Ltest.CompletionAllMemberTypes2$Member1$Member2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12187
				"CompletionAllMemberTypes2.Member1.Member2.Member3[TYPE_REF]{Member3, test, Ltest.CompletionAllMemberTypes2$Member1$Member2$Member3;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12188
				"CompletionAllMemberTypes2.Member1.Member5[TYPE_REF]{Member5, test, Ltest.CompletionAllMemberTypes2$Member1$Member5;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12189
	            requestor.getResults());
12190
	} finally {
12191
		if(anInterface != null) {
12192
			anInterface.discardWorkingCopy();
12193
		}
12194
	}
12195
}
12196
public void testCompletionAllMemberTypes5() throws JavaModelException {
12197
	ICompilationUnit aType = null;
12198
	Hashtable oldCurrentOptions = JavaCore.getOptions();
12199
	try {
12200
		Hashtable options = new Hashtable(oldCurrentOptions);
12201
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
12202
		JavaCore.setOptions(options);
12203
		
12204
		aType = getWorkingCopy(
12205
	            "/Completion/src/test/AType.java",
12206
	            "package test;\n" +
12207
	            "public class AType {\n" +
12208
	            "  public class Member1 {\n" +
12209
	            "    private class Member2 {\n" +
12210
	            "      public class Member3 {\n" +
12211
	            "        public class Member4 {\n" +
12212
	            "        }\n" +
12213
	            "      }\n" +
12214
	            "    }\n" +
12215
	            "  \n}" +
12216
	            "}");
12217
		
12218
	    this.wc = getWorkingCopy(
12219
	            "/Completion/src/test/CompletionAllMemberTypes5.java",
12220
	            "package test;\n" +
12221
	            "public class CompletionAllMemberTypes5 {\n" +
12222
	            "  void foo(){\n" +
12223
	            "    Member\n" +
12224
	            "  }\n" +
12225
	            "}");
12226
	    
12227
	    
12228
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12229
	    String str = this.wc.getSource();
12230
	    String completeBehind = "Member";
12231
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12232
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12233
	
12234
    	// AType.Member1.Member2.Member3 and AType.Member1.Member2.Member3.Member4 should not be proposed because they are not visible.
12235
    	// But visibility need modifiers of enclosing types to be computed. 
12236
    	assertResults(
12237
	            "AType.Member1[TYPE_REF]{test.AType.Member1, test, Ltest.AType$Member1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12238
				"AType.Member1.Member2.Member3[TYPE_REF]{test.AType.Member1.Member2.Member3, test, Ltest.AType$Member1$Member2$Member3;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12239
				"AType.Member1.Member2.Member3.Member4[TYPE_REF]{test.AType.Member1.Member2.Member3.Member4, test, Ltest.AType$Member1$Member2$Member3$Member4;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
12240
	            requestor.getResults());
12241
	} finally {
12242
		if(aType != null) {
12243
			aType.discardWorkingCopy();
12244
		}
12245
		JavaCore.setOptions(oldCurrentOptions);
12246
	}
12247
}
12327
}
12248
public void testCompletionAllMemberTypes6() throws JavaModelException {
12328
12249
	Hashtable oldCurrentOptions = JavaCore.getOptions();
12329
public void testCompletionVariableName8() throws JavaModelException {
12330
	Hashtable options = JavaCore.getOptions();
12331
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
12332
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pre"); //$NON-NLS-1$
12333
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
12334
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"suf"); //$NON-NLS-1$
12335
	
12336
	JavaCore.setOptions(options);
12337
12250
	try {
12338
	try {
12251
		Hashtable options = new Hashtable(oldCurrentOptions);
12339
		this.wc = getWorkingCopy(
12252
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
12340
	            "/Completion/src/CompletionVariableName8.java",
12253
		JavaCore.setOptions(options);
12341
	            "class FooBar {\n"+
12254
		
12342
	            "}\n"+
12255
	    this.wc = getWorkingCopy(
12343
	            "public class CompletionVariableName8 {\n"+
12256
	            "/Completion/src/test/CompletionAllMemberTypes6.java",
12344
	            "	void foo(){\n"+
12257
	            "package test;\n" +
12345
	            "		FooBar the\n"+
12258
	            "class AType {\n" +
12346
	            "	}\n"+
12259
	            "  public class Member1 {\n" +
12260
	            "    private class Member2 {\n" +
12261
	            "      public class Member3 {\n" +
12262
	            "      }\n" +
12263
	            "    }\n" +
12264
	            "  }\n" +
12265
	            "}\n" +
12266
	            "public class CompletionAllMemberTypes6 {\n" +
12267
	            "  void foo(){\n" +
12268
	            "    Member\n" +
12269
	            "  }\n" +
12270
	            "}");
12347
	            "}");
12271
	    
12348
	    
12272
	    
12349
	    
12273
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12350
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12274
	    String str = this.wc.getSource();
12351
	    String str = this.wc.getSource();
12275
	    String completeBehind = "Member";
12352
	    String completeBehind = "the";
12276
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12353
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12277
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12354
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12278
	
12355
	
12279
    	assertResults(
12356
	    assertResults(
12280
	            "AType.Member1[TYPE_REF]{test.AType.Member1, test, Ltest.AType$Member1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
12357
				"theBar[VARIABLE_DECLARATION]{theBar, null, LFooBar;, theBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
12281
	            requestor.getResults());
12358
				"theFooBar[VARIABLE_DECLARATION]{theFooBar, null, LFooBar;, theFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
12359
				"theBarsuf[VARIABLE_DECLARATION]{theBarsuf, null, LFooBar;, theBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}\n"+
12360
				"theFooBarsuf[VARIABLE_DECLARATION]{theFooBarsuf, null, LFooBar;, theFooBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_FIRST_SUFFIX + R_CASE + R_NON_RESTRICTED)+"}",
12361
				requestor.getResults());
12282
	} finally {
12362
	} finally {
12283
		JavaCore.setOptions(oldCurrentOptions);
12363
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
12364
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
12365
		JavaCore.setOptions(options);
12284
	}
12366
	}
12285
}
12367
}
12286
public void testCompletionAllMemberTypes7() throws JavaModelException {
12368
public void testCompletionVariableName9() throws JavaModelException {
12287
	Hashtable oldCurrentOptions = JavaCore.getOptions();
12369
	Hashtable options = JavaCore.getOptions();
12370
	Object argumentPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_PREFIXES);
12371
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pre"); //$NON-NLS-1$
12372
	Object localPrefixPreviousValue = options.get(JavaCore.CODEASSIST_LOCAL_SUFFIXES);
12373
	options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,"suf"); //$NON-NLS-1$
12374
	
12375
	JavaCore.setOptions(options);
12376
12288
	try {
12377
	try {
12289
		Hashtable options = new Hashtable(oldCurrentOptions);
12378
		this.wc = getWorkingCopy(
12290
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
12379
	            "/Completion/src/CompletionVariableName9.java",
12291
		JavaCore.setOptions(options);
12380
	            "class FooBar {\n"+
12292
		
12381
	            "}\n"+
12293
	    this.wc = getWorkingCopy(
12382
	            "public class CompletionVariableName9 {\n"+
12294
	            "/Completion/src/test/AType.java",
12383
	            "	void foo(){\n"+
12295
	            "package test;\n" +
12384
	            "		FooBar thefo\n"+
12296
	            "class AType {\n" +
12385
	            "	}\n"+
12297
	            "  public class Member1 {\n" +
12298
	            "    private class Member2 {\n" +
12299
	            "      public class Member3 {\n" +
12300
	            "      }\n" +
12301
	            "    }\n" +
12302
	            "  }\n" +
12303
	            "  void foo(){\n" +
12304
	            "    Member\n" +
12305
	            "  }\n" +
12306
	            "}");
12386
	            "}");
12307
	    
12387
	    
12308
	    
12388
	    
12309
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12389
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12310
	    String str = this.wc.getSource();
12390
	    String str = this.wc.getSource();
12311
	    String completeBehind = "Member";
12391
	    String completeBehind = "thefo";
12312
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12392
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12313
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12393
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12314
	
12394
	
12315
    	assertResults(
12395
	    assertResults(
12316
	            "AType.Member1.Member2[TYPE_REF]{test.AType.Member1.Member2, test, Ltest.AType$Member1$Member2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12396
				"thefoBar[VARIABLE_DECLARATION]{thefoBar, null, LFooBar;, thefoBar, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n"+
12317
				"AType.Member1.Member2.Member3[TYPE_REF]{test.AType.Member1.Member2.Member3, test, Ltest.AType$Member1$Member2$Member3;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12397
				"thefoBarsuf[VARIABLE_DECLARATION]{thefoBarsuf, null, LFooBar;, thefoBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}\n"+
12318
				"AType.Member1[TYPE_REF]{Member1, test, Ltest.AType$Member1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12398
				"theFooBar[VARIABLE_DECLARATION]{theFooBar, null, LFooBar;, theFooBar, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED)+"}\n"+
12319
	            requestor.getResults());
12399
				"theFooBarsuf[VARIABLE_DECLARATION]{theFooBarsuf, null, LFooBar;, theFooBarsuf, null, "+(R_DEFAULT + R_INTERESTING + R_NAME_LESS_NEW_CHARACTERS + R_NAME_FIRST_SUFFIX + R_NON_RESTRICTED)+"}",
12400
				requestor.getResults());
12320
	} finally {
12401
	} finally {
12321
		JavaCore.setOptions(oldCurrentOptions);
12402
		options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,argumentPrefixPreviousValue);
12403
		options.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES,localPrefixPreviousValue);
12404
		JavaCore.setOptions(options);
12322
	}
12405
	}
12323
}
12406
}
12324
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=96213
12407
public void testCompletionVariableNameOfArray1() throws JavaModelException {
12325
public void testBug96213() throws JavaModelException {
12408
	this.workingCopies = new ICompilationUnit[1];
12326
    this.wc = getWorkingCopy(
12409
	this.workingCopies[0] = getWorkingCopy(
12327
            "/Completion/src/test/Test.java",
12410
		"/Completion/src/CompletionVariableNameOfArray1.java",
12328
            "package test;\n" +
12411
		"public class CompletionVariableNameOfArray1 {\n"+
12329
            "public class Test{\n"+
12412
		"	Object[] ob\n"+
12330
            "  Test toto(Object o) {\n"+
12413
		"}\n");
12331
            "    return null;\n"+
12414
	
12332
            "  }\n"+
12415
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12333
            "  void titi(int removed) {\n"+
12416
	String str = this.workingCopies[0].getSource();
12334
            "  }\n"+
12417
	String completeBehind = "ob";
12335
            "  void foo() {\n"+
12418
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12336
            "    int removed = 0;\n"+
12419
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12337
            "    toto(Test.this).titi(removed);\n"+
12420
	
12338
            "  }\n"+
12421
	assertResults(
12339
            "}");
12422
		"objects[VARIABLE_DECLARATION]{objects, null, [Ljava.lang.Object;, objects, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED) + "}",
12340
    
12423
		requestor.getResults());
12341
    
12424
}
12342
    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12425
public void testCompletionVariableNameOfArray2() throws JavaModelException {
12343
    String str = this.wc.getSource();
12426
	this.workingCopies = new ICompilationUnit[1];
12344
    String completeBehind = "removed";
12427
	this.workingCopies[0] = getWorkingCopy(
12345
    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12428
		"/Completion/src/CompletionVariableNameOfArray2.java",
12346
    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12429
		"public class CompletionVariableNameOfArray2 {\n"+
12430
		"	Class[] cl\n"+
12431
		"}\n");
12432
	
12433
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12434
	String str = this.workingCopies[0].getSource();
12435
	String completeBehind = "cl";
12436
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12437
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12438
	
12439
	assertResults(
12440
		"classes[VARIABLE_DECLARATION]{classes, null, [Ljava.lang.Class;, classes, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED) + "}",
12441
		requestor.getResults());
12442
}
12443
public void testCompletionVariableNameOfArray3() throws JavaModelException {
12444
	this.workingCopies = new ICompilationUnit[1];
12445
	this.workingCopies[0] = getWorkingCopy(
12446
		"/Completion/src/CompletionVariableNameOfArray3.java",
12447
		"public class CompletionVariableNameOfArray3 {\n"+
12448
		"	Object[][] ob\n"+
12449
		"}\n");
12450
	
12451
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12452
	String str = this.workingCopies[0].getSource();
12453
	String completeBehind = "ob";
12454
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12455
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12456
	
12457
	assertResults(
12458
		"objects[VARIABLE_DECLARATION]{objects, null, [[Ljava.lang.Object;, objects, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED) + "}",
12459
		requestor.getResults());
12460
}
12461
public void testCompletionVariableNameOfArray4() throws JavaModelException {
12462
	this.workingCopies = new ICompilationUnit[1];
12463
	this.workingCopies[0] = getWorkingCopy(
12464
		"/Completion/src/CompletionVariableNameOfArray4.java",
12465
		"public class CompletionVariableNameOfArray4 {\n"+
12466
		"	Objectz[] ob\n"+
12467
		"}\n");
12468
	
12469
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12470
	String str = this.workingCopies[0].getSource();
12471
	String completeBehind = "ob";
12472
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12473
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12474
	
12475
	assertResults(
12476
		"",
12477
		requestor.getResults());
12478
}
12479
public void testCompletionVariableNameUnresolvedType() throws JavaModelException {
12480
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
12481
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVariableNameUnresolvedType.java");
12482
12483
	String str = cu.getSource();
12484
	String completeBehind = "ob";
12485
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12486
	cu.codeComplete(cursorLocation, requestor);
12487
12488
	assertEquals(
12489
		"should have no completion",
12490
		"",
12491
		requestor.getResults());
12492
}
12493
public void testCompletionVisibilityCheckDisabled() throws JavaModelException {
12494
	String visibilityCheckID = "org.eclipse.jdt.core.codeComplete.visibilityCheck";
12495
	Hashtable options = JavaCore.getOptions();
12496
	Object visibilityCheckPreviousValue = options.get(visibilityCheckID);
12497
	options.put(visibilityCheckID,"disabled");
12498
	JavaCore.setOptions(options);
12499
	
12500
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
12501
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVisibilityCheck.java");
12502
12503
	String str = cu.getSource();
12504
	String completeBehind = "x.p";
12505
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
12506
	cu.codeComplete(cursorLocation, requestor);
12507
	
12508
	options.put(visibilityCheckID,visibilityCheckPreviousValue);
12509
	JavaCore.setOptions(options);
12510
	assertEquals(
12511
		"should have three methods", 
12512
		"element:privateFoo    completion:privateFoo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED)+"\n" +
12513
		"element:protectedFoo    completion:protectedFoo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED)+"\n" +
12514
		"element:publicFoo    completion:publicFoo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
12515
		requestor.getResults());
12516
}
12517
public void testCompletionVisibilityCheckEnabled() throws JavaModelException {
12518
	String visibilityCheckID = "org.eclipse.jdt.core.codeComplete.visibilityCheck";
12519
	Hashtable options = JavaCore.getOptions();
12520
	Object visibilityCheckPreviousValue = options.get(visibilityCheckID);
12521
	options.put(visibilityCheckID,"enabled");
12522
	JavaCore.setOptions(options);
12523
	
12524
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
12525
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVisibilityCheck.java");
12526
12527
	String str = cu.getSource();
12528
	String completeBehind = "x.p";
12529
	int cursorLocation = str.indexOf(completeBehind) + completeBehind.length();
12530
	cu.codeComplete(cursorLocation, requestor);
12531
	
12532
	options.put(visibilityCheckID,visibilityCheckPreviousValue);
12533
	JavaCore.setOptions(options);
12534
	assertEquals(
12535
		"should have two methods", 
12536
		"element:protectedFoo    completion:protectedFoo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED)+"\n" +
12537
		"element:publicFoo    completion:publicFoo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC+ R_NON_RESTRICTED),
12538
		requestor.getResults());
12539
}
12540
/*
12541
* http://dev.eclipse.org/bugs/show_bug.cgi?id=25815
12542
*/
12543
public void testCompletionVoidMethod() throws JavaModelException {
12544
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
12545
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionVoidMethod.java");
12546
12547
	String str = cu.getSource();
12548
	String completeBehind = "foo";
12549
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12550
	cu.codeComplete(cursorLocation, requestor);
12551
12552
	assertEquals(
12553
		"element:foo    completion:foo()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
12554
		"element:foo1    completion:foo1()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
12555
		"element:foo3    completion:foo3()    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED+ R_NON_RESTRICTED),
12556
		requestor.getResults());
12557
}
12558
public void testCompletionWithBinaryFolder() throws JavaModelException {
12559
	CompletionTestsRequestor requestor = new CompletionTestsRequestor();
12560
	ICompilationUnit cu= getCompilationUnit("Completion", "src", "", "CompletionWithBinaryFolder.java");
12347
12561
12348
	assertResults(
12562
	String str = cu.getSource();
12349
            "removed[LOCAL_VARIABLE_REF]{removed, null, I, removed, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12563
	String completeBehind = "My";
12350
            requestor.getResults());
12564
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12565
	cu.codeComplete(cursorLocation, requestor);
12566
12567
	assertEquals(
12568
		"should have two completions",
12569
		"element:MyClass    completion:MyClass    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"\n" +
12570
		"element:mypackage    completion:mypackage    relevance:"+(R_DEFAULT + R_INTERESTING+ R_NON_RESTRICTED),
12571
		requestor.getResults());
12351
}
12572
}
12352
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=95167
12573
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=95167
12353
public void testCompletionWithProblem1() throws JavaModelException {
12574
public void testCompletionWithProblem1() throws JavaModelException {
Lines 12393-13389 Link Here
12393
		}
12614
		}
12394
	}
12615
	}
12395
}
12616
}
12396
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=95505
12617
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
12397
public void testCompletionExpectedTypeOnEmptyToken1() throws JavaModelException {
12618
public void testDeprecationCheck1() throws JavaModelException {
12398
	ICompilationUnit aType = null;
12619
	Hashtable options = JavaCore.getOptions();
12620
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
12621
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED); //$NON-NLS-1$
12622
	
12623
	JavaCore.setOptions(options);
12624
12399
	try {
12625
	try {
12626
		this.workingCopies = new ICompilationUnit[3];
12627
		this.workingCopies[0] = getWorkingCopy(
12628
			"/Completion/src/deprecation/Test.java",
12629
			"package deprecation;"+
12630
			"public class Test {\n"+
12631
			"  ZZZTy\n"+
12632
			"}");
12400
		
12633
		
12401
		aType = getWorkingCopy(
12634
		this.workingCopies[1] = getWorkingCopy(
12402
	            "/Completion/src/test/AType.java",
12635
			"/Completion/src/deprecation/ZZZType1.java",
12403
	            "package test;\n" +
12636
			"package deprecation;"+
12404
	            "public class AType{\n"+
12637
			"public class ZZZType1 {\n"+
12405
	            "}");
12638
			"}");
12406
		
12639
		
12407
	    this.wc = getWorkingCopy(
12640
		this.workingCopies[2] = getWorkingCopy(
12408
	            "/Completion/src/test/Test.java",
12641
			"/Completion/src/deprecation/ZZZType2.java",
12409
	            "package test;\n" +
12642
			"package deprecation;"+
12410
	            "public class Test{\n"+
12643
			"/** @deprecated */\n"+
12411
	            "  void foo() {\n"+
12644
			"public class ZZZType2 {\n"+
12412
	            "    AType a = new \n"+
12645
			"}");
12413
	            "  }\n"+
12646
	
12414
	            "}");
12647
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12415
	    
12648
		String str = this.workingCopies[0].getSource();
12416
	    
12649
		String completeBehind = "ZZZTy";
12417
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12650
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12418
	    String str = this.wc.getSource();
12651
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12419
	    String completeBehind = "AType a = new ";
12652
	
12420
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12653
		assertResults(
12421
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12654
				"ZZZTy[POTENTIAL_METHOD_DECLARATION]{ZZZTy, Ldeprecation.Test;, ()V, ZZZTy, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
12655
				"ZZZType1[TYPE_REF]{ZZZType1, deprecation, Ldeprecation.ZZZType1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12656
				"ZZZType2[TYPE_REF]{ZZZType2, deprecation, Ldeprecation.ZZZType2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12657
				requestor.getResults());
12658
	} finally {
12659
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
12660
		JavaCore.setOptions(options);
12661
	}
12662
}
12663
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
12664
public void testDeprecationCheck10() throws JavaModelException {
12665
	Hashtable options = JavaCore.getOptions();
12666
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
12667
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
12668
	
12669
	JavaCore.setOptions(options);
12670
12671
	try {
12672
12673
		this.workingCopies = new ICompilationUnit[1];
12674
		this.workingCopies[0] = getWorkingCopy(
12675
			"/Completion/src/deprecation/Test.java",
12676
			"package deprecation;"+
12677
			"public class Test {\n"+
12678
			"  public void bar1(){}\n"+
12679
			"  /** @deprecated */\n"+
12680
			"  public void bar2(){}\n"+
12681
			"  void foo() {"+
12682
			"    bar\n"+
12683
			"  }"+
12684
			"}");
12685
	
12686
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12687
		String str = this.workingCopies[0].getSource();
12688
		String completeBehind = "bar";
12689
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12690
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12691
	
12692
		assertResults(
12693
				"bar1[METHOD_REF]{bar1(), Ldeprecation.Test;, ()V, bar1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12694
				"bar2[METHOD_REF]{bar2(), Ldeprecation.Test;, ()V, bar2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12695
				requestor.getResults());
12696
	} finally {
12697
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
12698
		JavaCore.setOptions(options);
12699
	}
12700
}
12701
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
12702
public void testDeprecationCheck11() throws JavaModelException {
12703
	Hashtable options = JavaCore.getOptions();
12704
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
12705
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED); //$NON-NLS-1$
12706
	
12707
	JavaCore.setOptions(options);
12708
12709
	try {
12710
12711
		this.workingCopies = new ICompilationUnit[1];
12712
		this.workingCopies[0] = getWorkingCopy(
12713
			"/Completion/src/deprecation/Test.java",
12714
			"package deprecation;"+
12715
			"public class Test {\n"+
12716
			"  public int bar1;\n"+
12717
			"  /** @deprecated */\n"+
12718
			"  public int bar2;\n"+
12719
			"  void foo() {"+
12720
			"    bar\n"+
12721
			"  }"+
12722
			"}");
12723
	
12724
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12725
		String str = this.workingCopies[0].getSource();
12726
		String completeBehind = "bar";
12727
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12728
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12729
	
12730
		assertResults(
12731
				"bar1[FIELD_REF]{bar1, Ldeprecation.Test;, I, bar1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12732
				"bar2[FIELD_REF]{bar2, Ldeprecation.Test;, I, bar2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12733
				requestor.getResults());
12734
	} finally {
12735
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
12736
		JavaCore.setOptions(options);
12737
	}
12738
}
12739
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
12740
public void testDeprecationCheck12() throws JavaModelException {
12741
	Hashtable options = JavaCore.getOptions();
12742
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
12743
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
12744
	
12745
	JavaCore.setOptions(options);
12746
12747
	try {
12748
12749
		this.workingCopies = new ICompilationUnit[1];
12750
		this.workingCopies[0] = getWorkingCopy(
12751
			"/Completion/src/deprecation/Test.java",
12752
			"package deprecation;"+
12753
			"public class Test {\n"+
12754
			"  public int bar1;\n"+
12755
			"  /** @deprecated */\n"+
12756
			"  public int bar2;\n"+
12757
			"  void foo() {"+
12758
			"    bar\n"+
12759
			"  }"+
12760
			"}");
12761
	
12762
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12763
		String str = this.workingCopies[0].getSource();
12764
		String completeBehind = "bar";
12765
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12766
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12767
	
12768
		assertResults(
12769
				"bar1[FIELD_REF]{bar1, Ldeprecation.Test;, I, bar1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12770
				"bar2[FIELD_REF]{bar2, Ldeprecation.Test;, I, bar2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12771
				requestor.getResults());
12772
	} finally {
12773
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
12774
		JavaCore.setOptions(options);
12775
	}
12776
}
12777
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
12778
public void testDeprecationCheck13() throws JavaModelException {
12779
	Hashtable options = JavaCore.getOptions();
12780
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
12781
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED); //$NON-NLS-1$
12782
	
12783
	JavaCore.setOptions(options);
12784
12785
	try {
12786
12787
		this.workingCopies = new ICompilationUnit[1];
12788
		this.workingCopies[0] = getWorkingCopy(
12789
			"/Completion/src/deprecation/Test.java",
12790
			"package deprecation;"+
12791
			"public class Test {\n"+
12792
			"  class Inner1 {}\n"+
12793
			"  /** @deprecated */\n"+
12794
			"  class Inner2 {}\n"+
12795
			"  void foo() {"+
12796
			"    Inn\n"+
12797
			"  }"+
12798
			"}");
12799
	
12800
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12801
		String str = this.workingCopies[0].getSource();
12802
		String completeBehind = "Inn";
12803
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12804
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12422
	
12805
	
12423
	    assertResults(
12806
		assertResults(
12424
	            "expectedTypesSignatures={Ltest.AType;}\n"+
12807
				"Test.Inner1[TYPE_REF]{Inner1, deprecation, Ldeprecation.Test$Inner1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12425
	            "expectedTypesKeys={Ltest/AType;}",
12808
				"Test.Inner2[TYPE_REF]{Inner2, deprecation, Ldeprecation.Test$Inner2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12426
	            requestor.getContext());
12809
				requestor.getResults());
12427
	    if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
12428
			assertResults(
12429
		            "AType[TYPE_REF]{AType, test, Ltest.AType;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12430
		            requestor.getResults());
12431
	    } else {
12432
	    	assertResults(
12433
		            "Test[TYPE_REF]{Test, test, Ltest.Test;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12434
					"AType[TYPE_REF]{AType, test, Ltest.AType;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12435
		            requestor.getResults());
12436
	    }
12437
	} finally {
12810
	} finally {
12438
		if(aType != null) {
12811
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
12439
			aType.discardWorkingCopy();
12812
		JavaCore.setOptions(options);
12440
		}
12441
	}
12813
	}
12442
}
12814
}
12443
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=95505
12815
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
12444
public void testCompletionExpectedTypeOnEmptyToken3() throws JavaModelException {
12816
public void testDeprecationCheck14() throws JavaModelException {
12445
	ICompilationUnit aType = null;
12817
	Hashtable options = JavaCore.getOptions();
12818
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
12819
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
12820
	
12821
	JavaCore.setOptions(options);
12822
12446
	try {
12823
	try {
12447
		aType = getWorkingCopy(
12824
12448
	            "/Completion/src/test/AType.java",
12825
		this.workingCopies = new ICompilationUnit[2];
12449
	            "package test;\n" +
12826
		this.workingCopies[0] = getWorkingCopy(
12450
	            "public class AType{\n"+
12827
			"/Completion/src/deprecation/Test.java",
12451
	            "}");
12828
			"package deprecation;"+
12452
		
12829
			"public class Test {\n"+
12453
	    this.wc = getWorkingCopy(
12830
			"  class Inner1 {}\n"+
12454
	            "/Completion/src/test/Test.java",
12831
			"  /** @deprecated */\n"+
12455
	            "package test;\n" +
12832
			"  class Inner2 {}\n"+
12456
	            "public class Test{\n"+
12833
			"  void foo() {"+
12457
	            "  void foo() {\n"+
12834
			"    Inn\n"+
12458
	            "    AType a = \n"+
12835
			"  }"+
12459
	            "  }\n"+
12836
			"}");
12460
	            "}");
12461
	    
12462
	    
12463
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12464
	    requestor.setIgnored(CompletionProposal.METHOD_REF, true);
12465
	    requestor.setIgnored(CompletionProposal.FIELD_REF, true);
12466
	    requestor.setIgnored(CompletionProposal.LOCAL_VARIABLE_REF, true);
12467
	    
12468
	    String str = this.wc.getSource();
12469
	    String completeBehind = "AType a = ";
12470
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12471
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12472
	
12837
	
12473
	    assertResults(
12838
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12474
	            "expectedTypesSignatures={Ltest.AType;}\n"+
12839
		String str = this.workingCopies[0].getSource();
12475
	            "expectedTypesKeys={Ltest/AType;}",
12840
		String completeBehind = "Inn";
12476
	            requestor.getContext());
12841
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12477
	    if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
12842
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12478
			assertResults(
12843
	
12479
		            "",
12844
		assertResults(
12480
		            requestor.getResults());
12845
				"Test.Inner1[TYPE_REF]{Inner1, deprecation, Ldeprecation.Test$Inner1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12481
	    } else {
12846
				"Test.Inner2[TYPE_REF]{Inner2, deprecation, Ldeprecation.Test$Inner2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12482
	    	assertResults(
12847
				requestor.getResults());
12483
		            "Test[TYPE_REF]{Test, test, Ltest.Test;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12484
					"AType[TYPE_REF]{AType, test, Ltest.AType;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12485
		            requestor.getResults());
12486
	    }
12487
	} finally {
12848
	} finally {
12488
		if(aType != null) {
12849
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
12489
			aType.discardWorkingCopy();
12850
		JavaCore.setOptions(options);
12490
		}
12491
	}
12851
	}
12492
}
12852
}
12493
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=95505
12853
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
12494
public void testCompletionExpectedTypeOnEmptyToken4() throws JavaModelException {
12854
public void testDeprecationCheck15() throws JavaModelException {
12495
	ICompilationUnit aType = null;
12855
	Hashtable options = JavaCore.getOptions();
12856
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
12857
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
12858
	
12859
	JavaCore.setOptions(options);
12860
12496
	try {
12861
	try {
12497
		aType = getWorkingCopy(
12862
12498
	            "/Completion/src/test/AInterface.java",
12863
		this.workingCopies = new ICompilationUnit[2];
12499
	            "package test;\n" +
12864
		this.workingCopies[0] = getWorkingCopy(
12500
	            "public interface AInterface{\n"+
12865
			"/Completion/src/deprecation/Test.java",
12501
	            "}");
12866
			"package deprecation;"+
12867
			"public class Test {\n"+
12868
			"  void foo() {"+
12869
			"    ZZZType1.foo\n"+
12870
			"  }"+
12871
			"}");
12502
		
12872
		
12503
	    this.wc = getWorkingCopy(
12873
		this.workingCopies[1] = getWorkingCopy(
12504
	            "/Completion/src/test/Test.java",
12874
			"/Completion/src/deprecation/ZZZType1.java",
12505
	            "package test;\n" +
12875
			"package deprecation;"+
12506
	            "public class Test{\n"+
12876
			"/** @deprecated */\n"+
12507
	            "  void foo() {\n"+
12877
			"public class ZZZType1 {\n"+
12508
	            "    AInterface a = new \n"+
12878
			"  public static int foo1;\n"+
12509
	            "  }\n"+
12879
			"  public static int foo2;\n"+
12510
	            "}");
12880
			"}");
12511
	    
12512
	    
12513
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12514
	    
12515
	    String str = this.wc.getSource();
12516
	    String completeBehind = "AInterface a = new ";
12517
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12518
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12519
	
12881
	
12520
	    assertResults(
12882
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12521
	            "expectedTypesSignatures={Ltest.AInterface;}\n"+
12883
		String str = this.workingCopies[0].getSource();
12522
	            "expectedTypesKeys={Ltest/AInterface;}",
12884
		String completeBehind = "ZZZType1.foo";
12523
	            requestor.getContext());
12885
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12524
	    
12886
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12525
	    if(CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
12887
	
12526
			assertResults(
12888
		assertResults(
12527
		            "AInterface[TYPE_REF]{AInterface, test, Ltest.AInterface;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12889
				"",
12528
		            requestor.getResults());
12890
				requestor.getResults());
12529
	    } else {
12530
	    	assertResults(
12531
		            "Test[TYPE_REF]{Test, test, Ltest.Test;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12532
					"AInterface[TYPE_REF]{AInterface, test, Ltest.AInterface;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12533
		            requestor.getResults());
12534
	    }
12535
	} finally {
12891
	} finally {
12536
		if(aType != null) {
12892
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
12537
			aType.discardWorkingCopy();
12893
		JavaCore.setOptions(options);
12538
		}
12539
	}
12894
	}
12540
}
12895
}
12541
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=99811
12896
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
12542
public void testBug99811() throws JavaModelException {
12897
public void testDeprecationCheck16() throws JavaModelException {
12543
	ICompilationUnit aType = null;
12898
	Hashtable options = JavaCore.getOptions();
12544
    try {
12899
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
12545
    	this.wc = getWorkingCopy(
12900
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
12546
	            "/Completion/src/test/A.java",
12547
	            "public abstract class A implements I {}");
12548
    	
12549
	    aType = getWorkingCopy(
12550
	            "/Completion/src/test/I.java",
12551
	            "public interface I {\n"+
12552
	            "  public class M extends A {}\n"+
12553
	            "}");
12554
	
12901
	
12555
	    CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12902
	JavaCore.setOptions(options);
12556
	    String str = this.wc.getSource();
12903
12557
	    String completeBehind = "A";
12904
	try {
12558
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12905
12559
	    this.wc.codeComplete(cursorLocation, requestor, this.wcOwner);
12906
		this.workingCopies = new ICompilationUnit[1];
12907
		this.workingCopies[0] = getWorkingCopy(
12908
			"/Completion/src/deprecation/Test.java",
12909
			"package deprecation;"+
12910
			"/** @deprecated */\n"+
12911
			"public class ZZZType1 {\n"+
12912
			"}"+
12913
			"public class Test {\n"+
12914
			"  void foo() {"+
12915
			"    ZZZTy\n"+
12916
			"  }"+
12917
			"}");
12560
	
12918
	
12561
		assertResults("", requestor.getResults());
12919
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12920
		String str = this.workingCopies[0].getSource();
12921
		String completeBehind = "ZZZTy";
12922
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12923
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12924
	
12925
		assertResults(
12926
				"ZZZType1[TYPE_REF]{ZZZType1, deprecation, Ldeprecation.ZZZType1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12927
				requestor.getResults());
12562
	} finally {
12928
	} finally {
12563
		if(aType != null) {
12929
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
12564
			aType.discardWorkingCopy();
12930
		JavaCore.setOptions(options);
12565
		}
12566
	}
12931
	}
12567
}
12932
}
12568
public void testCompletionImportedType1() throws JavaModelException {
12933
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127628
12569
    this.workingCopies = new ICompilationUnit[2];
12934
public void testDeprecationCheck17() throws JavaModelException {
12570
    this.workingCopies[0] = getWorkingCopy(
12935
	Hashtable options = JavaCore.getOptions();
12571
		"/Completion/src/test/imported/ZZZZ.java",
12936
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
12572
		"package test.imported;"+
12937
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
12573
		"public class ZZZZ {\n"+
12938
	
12574
		"  \n"+
12939
	JavaCore.setOptions(options);
12575
		"}");
12576
		
12577
	this.workingCopies[1] = getWorkingCopy(
12578
			"/Completion/src/test/CompletionImportedType1.java",
12579
			"package test;"+
12580
			"public class CompletionImportedType1 {"+
12581
			"  ZZZ\n"+
12582
			"}");
12583
12940
12584
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12941
	try {
12585
	String str = this.workingCopies[1].getSource();
12586
	String completeBehind = "ZZZ";
12587
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12588
	this.workingCopies[1].codeComplete(cursorLocation, requestor, this.wcOwner);
12589
12942
12590
	assertResults(
12943
		this.workingCopies = new ICompilationUnit[1];
12591
			"ZZZ[POTENTIAL_METHOD_DECLARATION]{ZZZ, Ltest.CompletionImportedType1;, ()V, ZZZ, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
12944
		this.workingCopies[0] = getWorkingCopy(
12592
			"ZZZZ[TYPE_REF]{test.imported.ZZZZ, test.imported, Ltest.imported.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
12945
			"/Completion/src/deprecation/Test.java",
12593
			requestor.getResults());
12946
			"package deprecation;"+
12594
}
12947
			"public class Test {\n"+
12595
public void testCompletionImportedType2() throws JavaModelException {
12948
			"  Bug127628Ty\n"+
12596
	this.workingCopies = new ICompilationUnit[4];
12949
			"}");
12597
	this.workingCopies[0] = getWorkingCopy(
12598
		"/Completion/src/test/imported1/ZZZZ.java",
12599
		"package test.imported1;"+
12600
		"public class ZZZZ {\n"+
12601
		"  \n"+
12602
		"}");
12603
	this.workingCopies[1] = getWorkingCopy(
12604
		"/Completion/src/test/imported2/ZZZZ.java",
12605
		"package test.imported2;"+
12606
		"public class ZZZZ {\n"+
12607
		"  \n"+
12608
		"}");
12609
	this.workingCopies[2] = getWorkingCopy(
12610
		"/Completion/src/test/imported3/ZZZZ.java",
12611
		"package test.imported3;"+
12612
		"public class ZZZZ {\n"+
12613
		"  \n"+
12614
		"}");
12615
	
12950
	
12616
	this.workingCopies[3] = getWorkingCopy(
12951
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12617
		"/Completion/src/test/CompletionImportedType2.java",
12952
		String str = this.workingCopies[0].getSource();
12618
		"package test;"+
12953
		String completeBehind = "Bug127628Ty";
12619
		"import test.imported1.*;"+
12954
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12620
		"import test.imported2.*;"+
12955
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12621
		"import test.imported3.*;"+
12622
		"public class CompletionImportedType2 {"+
12623
		"  ZZZ\n"+
12624
		"}");
12625
	
12956
	
12626
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12957
		assertResults(
12627
	String str = this.workingCopies[3].getSource();
12958
				"Bug127628Ty[POTENTIAL_METHOD_DECLARATION]{Bug127628Ty, Ldeprecation.Test;, ()V, Bug127628Ty, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
12628
	String completeBehind = "ZZZ";
12959
				"Bug127628Type1.Bug127628TypeInner1[TYPE_REF]{deprecation.Bug127628Type1.Bug127628TypeInner1, deprecation, Ldeprecation.Bug127628Type1$Bug127628TypeInner1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12629
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12960
				"Bug127628Type2.Bug127628TypeInner2[TYPE_REF]{deprecation.Bug127628Type2.Bug127628TypeInner2, deprecation, Ldeprecation.Bug127628Type2$Bug127628TypeInner2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12630
	this.workingCopies[3].codeComplete(cursorLocation, requestor, this.wcOwner);
12961
				"Bug127628Type1[TYPE_REF]{Bug127628Type1, deprecation, Ldeprecation.Bug127628Type1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12631
12962
				requestor.getResults());
12632
	assertResults(
12963
	} finally {
12633
			"ZZZ[POTENTIAL_METHOD_DECLARATION]{ZZZ, Ltest.CompletionImportedType2;, ()V, ZZZ, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
12964
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
12634
			"ZZZZ[TYPE_REF]{test.imported1.ZZZZ, test.imported1, Ltest.imported1.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12965
		JavaCore.setOptions(options);
12635
			"ZZZZ[TYPE_REF]{test.imported2.ZZZZ, test.imported2, Ltest.imported2.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12966
	}
12636
			"ZZZZ[TYPE_REF]{test.imported3.ZZZZ, test.imported3, Ltest.imported3.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
12637
			requestor.getResults());
12638
}
12967
}
12639
public void testCompletionImportedType3() throws JavaModelException {
12968
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
12640
	this.workingCopies = new ICompilationUnit[4];
12969
public void testDeprecationCheck2() throws JavaModelException {
12641
	this.workingCopies[0] = getWorkingCopy(
12970
	Hashtable options = JavaCore.getOptions();
12642
		"/Completion/src/test/imported1/ZZZZ.java",
12971
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
12643
		"package test.imported1;"+
12972
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
12644
		"public class ZZZZ {\n"+
12645
		"  \n"+
12646
		"}");
12647
	this.workingCopies[1] = getWorkingCopy(
12648
		"/Completion/src/test/imported2/ZZZZ.java",
12649
		"package test.imported2;"+
12650
		"public class ZZZZ {\n"+
12651
		"  \n"+
12652
		"}");
12653
	this.workingCopies[2] = getWorkingCopy(
12654
		"/Completion/src/test/imported3/ZZZZ.java",
12655
		"package test.imported3;"+
12656
		"public class ZZZZ {\n"+
12657
		"  \n"+
12658
		"}");
12659
	
12973
	
12660
	this.workingCopies[3] = getWorkingCopy(
12974
	JavaCore.setOptions(options);
12661
		"/Completion/src/test/CompletionImportedType3.java",
12975
12662
		"package test;"+
12976
	try {
12663
		"import test.imported2.*;"+
12977
		this.workingCopies = new ICompilationUnit[3];
12664
		"public class CompletionImportedType3 {"+
12978
		this.workingCopies[0] = getWorkingCopy(
12665
		"  ZZZ\n"+
12979
			"/Completion/src/deprecation/Test.java",
12980
			"package deprecation;"+
12981
			"public class Test {\n"+
12982
			"  ZZZTy\n"+
12983
			"}");
12984
		
12985
		this.workingCopies[1] = getWorkingCopy(
12986
			"/Completion/src/deprecation/ZZZType1.java",
12987
			"package deprecation;"+
12988
			"public class ZZZType1 {\n"+
12989
			"}");
12990
		
12991
		this.workingCopies[2] = getWorkingCopy(
12992
			"/Completion/src/deprecation/ZZZType2.java",
12993
			"package deprecation;"+
12994
			"/** @deprecated */\n"+
12995
			"public class ZZZType2 {\n"+
12666
			"}");
12996
			"}");
12667
	
12997
	
12668
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12998
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12669
	String str = this.workingCopies[3].getSource();
12999
		String str = this.workingCopies[0].getSource();
12670
	String completeBehind = "ZZZ";
13000
		String completeBehind = "ZZZTy";
12671
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13001
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12672
	this.workingCopies[3].codeComplete(cursorLocation, requestor, this.wcOwner);
13002
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12673
13003
	
12674
	assertResults(
13004
		assertResults(
12675
			"ZZZ[POTENTIAL_METHOD_DECLARATION]{ZZZ, Ltest.CompletionImportedType3;, ()V, ZZZ, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
13005
				"ZZZTy[POTENTIAL_METHOD_DECLARATION]{ZZZTy, Ldeprecation.Test;, ()V, ZZZTy, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
12676
			"ZZZZ[TYPE_REF]{test.imported1.ZZZZ, test.imported1, Ltest.imported1.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
13006
				"ZZZType1[TYPE_REF]{ZZZType1, deprecation, Ldeprecation.ZZZType1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12677
			"ZZZZ[TYPE_REF]{test.imported3.ZZZZ, test.imported3, Ltest.imported3.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
13007
				requestor.getResults());
12678
			"ZZZZ[TYPE_REF]{ZZZZ, test.imported2, Ltest.imported2.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13008
	} finally {
12679
			requestor.getResults());
13009
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
13010
		JavaCore.setOptions(options);
13011
	}
12680
}
13012
}
12681
public void testCompletionImportedType4() throws JavaModelException {
13013
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
12682
	this.workingCopies = new ICompilationUnit[3];
13014
public void testDeprecationCheck3() throws JavaModelException {
12683
	this.workingCopies[0] = getWorkingCopy(
13015
	Hashtable options = JavaCore.getOptions();
12684
		"/Completion/src/test/imported1/ZZZZ.java",
13016
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
12685
		"package test.imported1;"+
13017
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED); //$NON-NLS-1$
12686
		"public class ZZZZ {\n"+
12687
		"  \n"+
12688
		"}");
12689
	this.workingCopies[1] = getWorkingCopy(
12690
		"/Completion/src/test/imported2/ZZZZ.java",
12691
		"package test.imported2;"+
12692
		"public class ZZZZ {\n"+
12693
		"  \n"+
12694
		"}");
12695
		
12696
	this.workingCopies[2] = getWorkingCopy(
12697
		"/Completion/src/test/CompletionImportedType4.java",
12698
		"package test;"+
12699
		"import test.imported1.*;"+
12700
		"public class CompletionImportedType4 {"+
12701
		"  ZZZ\n"+
12702
		"}");
12703
	
13018
	
12704
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13019
	JavaCore.setOptions(options);
12705
	String str = this.workingCopies[2].getSource();
12706
	String completeBehind = "ZZZ";
12707
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12708
	this.workingCopies[2].codeComplete(cursorLocation, requestor, this.wcOwner);
12709
13020
12710
	assertResults(
13021
	try {
12711
			"ZZZ[POTENTIAL_METHOD_DECLARATION]{ZZZ, Ltest.CompletionImportedType4;, ()V, ZZZ, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
13022
	
12712
			"ZZZZ[TYPE_REF]{test.imported2.ZZZZ, test.imported2, Ltest.imported2.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
13023
		this.workingCopies = new ICompilationUnit[2];
12713
			"ZZZZ[TYPE_REF]{ZZZZ, test.imported1, Ltest.imported1.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13024
		this.workingCopies[0] = getWorkingCopy(
12714
			requestor.getResults());
13025
			"/Completion/src/deprecation/Test.java",
12715
}
13026
			"package deprecation;"+
12716
public void testCompletionImportedType5() throws JavaModelException {
13027
			"public class Test {\n"+
12717
	this.workingCopies = new ICompilationUnit[3];
13028
			"  void foo() {"+
12718
	this.workingCopies[0] = getWorkingCopy(
13029
			"    ZZZType1.fo\n"+
12719
		"/Completion/src/test/imported1/ZZZZ.java",
13030
			"  }"+
12720
		"package test.imported1;"+
13031
			"}");
12721
		"public class ZZZZ {\n"+
12722
		"  \n"+
12723
		"}");
12724
	this.workingCopies[1] = getWorkingCopy(
12725
		"/Completion/src/test/imported2/ZZZZ.java",
12726
		"package test.imported2;"+
12727
		"public class ZZZZ {\n"+
12728
		"  \n"+
12729
		"}");
12730
		
13032
		
12731
	this.workingCopies[2] = getWorkingCopy(
13033
		this.workingCopies[1] = getWorkingCopy(
12732
		"/Completion/src/test/CompletionImportedType5.java",
13034
			"/Completion/src/deprecation/ZZZType1.java",
12733
		"package test;"+
13035
			"package deprecation;"+
12734
		"import test.imported2.*;"+
13036
			"public class ZZZType1 {\n"+
12735
		"public class CompletionImportedType5 {"+
13037
			"  public static void foo1(){}\n"+
12736
		"  ZZZ\n"+
13038
			"  /** @deprecated */\n"+
12737
		"}");
13039
			"  public static void foo2(){}\n"+
12738
13040
			"}");
12739
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13041
	
12740
	String str = this.workingCopies[2].getSource();
13042
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12741
	String completeBehind = "ZZZ";
13043
		String str = this.workingCopies[0].getSource();
12742
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13044
		String completeBehind = "ZZZType1.fo";
12743
	this.workingCopies[2].codeComplete(cursorLocation, requestor, this.wcOwner);
13045
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12744
13046
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12745
	assertResults(
13047
	
12746
			"ZZZ[POTENTIAL_METHOD_DECLARATION]{ZZZ, Ltest.CompletionImportedType5;, ()V, ZZZ, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
13048
		assertResults(
12747
			"ZZZZ[TYPE_REF]{test.imported1.ZZZZ, test.imported1, Ltest.imported1.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
13049
				"foo1[METHOD_REF]{foo1(), Ldeprecation.ZZZType1;, ()V, foo1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n" +
12748
			"ZZZZ[TYPE_REF]{ZZZZ, test.imported2, Ltest.imported2.ZZZZ;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13050
				"foo2[METHOD_REF]{foo2(), Ldeprecation.ZZZType1;, ()V, foo2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}",
12749
			requestor.getResults());
13051
				requestor.getResults());
13052
	} finally {
13053
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
13054
		JavaCore.setOptions(options);
13055
	}
12750
}
13056
}
12751
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
13057
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
12752
public void testCamelCaseType1() throws JavaModelException {
13058
public void testDeprecationCheck4() throws JavaModelException {
12753
	this.oldOptions = JavaCore.getOptions();
13059
	Hashtable options = JavaCore.getOptions();
13060
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
13061
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
13062
	
13063
	JavaCore.setOptions(options);
13064
12754
	try {
13065
	try {
12755
		Hashtable options = new Hashtable(oldOptions);
13066
12756
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
13067
		this.workingCopies = new ICompilationUnit[2];
12757
		JavaCore.setOptions(options);
12758
		
12759
		this.workingCopies = new ICompilationUnit[3];
12760
		this.workingCopies[0] = getWorkingCopy(
13068
		this.workingCopies[0] = getWorkingCopy(
12761
			"/Completion/src/camelcase/Test.java",
13069
			"/Completion/src/deprecation/Test.java",
12762
			"package camelcase;"+
13070
			"package deprecation;"+
12763
			"public class Test {\n"+
13071
			"public class Test {\n"+
12764
			"  FF\n"+
13072
			"  void foo() {"+
12765
			"}");
13073
			"    ZZZType1.fo\n"+
12766
	
13074
			"  }"+
12767
		this.workingCopies[1] = getWorkingCopy(
12768
			"/Completion/src/camelcase/FoFoFo.java",
12769
			"package camelcase;"+
12770
			"public class FoFoFo {\n"+
12771
			"}");
13075
			"}");
12772
		
13076
		
12773
		this.workingCopies[2] = getWorkingCopy(
13077
		this.workingCopies[1] = getWorkingCopy(
12774
			"/Completion/src/camelcase/FFFTest.java",
13078
			"/Completion/src/deprecation/ZZZType1.java",
12775
			"package camelcase;"+
13079
			"package deprecation;"+
12776
			"public class FFFTest {\n"+
13080
			"public class ZZZType1 {\n"+
13081
			"  public static void foo1(){}\n"+
13082
			"  /** @deprecated */\n"+
13083
			"  public static void foo2(){}\n"+
12777
			"}");
13084
			"}");
12778
	
13085
	
12779
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13086
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12780
		String str = this.workingCopies[0].getSource();
13087
		String str = this.workingCopies[0].getSource();
12781
		String completeBehind = "FF";
13088
		String completeBehind = "ZZZType1.fo";
12782
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13089
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12783
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13090
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12784
	
13091
	
12785
		assertResults(
13092
		assertResults(
12786
				"FF[POTENTIAL_METHOD_DECLARATION]{FF, Lcamelcase.Test;, ()V, FF, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
13093
				"foo1[METHOD_REF]{foo1(), Ldeprecation.ZZZType1;, ()V, foo1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}",
12787
				"FoFoFo[TYPE_REF]{FoFoFo, camelcase, Lcamelcase.FoFoFo;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12788
				"FFFTest[TYPE_REF]{FFFTest, camelcase, Lcamelcase.FFFTest;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12789
				requestor.getResults());
13094
				requestor.getResults());
12790
	} finally {
13095
	} finally {
12791
		JavaCore.setOptions(oldOptions);
13096
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
13097
		JavaCore.setOptions(options);
12792
	}
13098
	}
12793
}
13099
}
12794
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
13100
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
12795
public void testCamelCaseType2() throws JavaModelException {
13101
public void testDeprecationCheck5() throws JavaModelException {
12796
	this.oldOptions = JavaCore.getOptions();
13102
	Hashtable options = JavaCore.getOptions();
13103
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
13104
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED); //$NON-NLS-1$
13105
	
13106
	JavaCore.setOptions(options);
13107
12797
	try {
13108
	try {
12798
		Hashtable options = new Hashtable(oldOptions);
13109
12799
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
13110
		this.workingCopies = new ICompilationUnit[2];
12800
		JavaCore.setOptions(options);
12801
		
12802
		this.workingCopies = new ICompilationUnit[3];
12803
		this.workingCopies[0] = getWorkingCopy(
13111
		this.workingCopies[0] = getWorkingCopy(
12804
			"/Completion/src/camelcase/Test.java",
13112
			"/Completion/src/deprecation/Test.java",
12805
			"package camelcase;"+
13113
			"package deprecation;"+
12806
			"public class Test {\n"+
13114
			"public class Test {\n"+
12807
			"  camelcase.FF\n"+
13115
			"  ZZZType1.Inn\n"+
12808
			"}");
12809
	
12810
		this.workingCopies[1] = getWorkingCopy(
12811
			"/Completion/src/camelcase/FoFoFo.java",
12812
			"package camelcase;"+
12813
			"public class FoFoFo {\n"+
12814
			"}");
13116
			"}");
12815
		
13117
		
12816
		this.workingCopies[2] = getWorkingCopy(
13118
		this.workingCopies[1] = getWorkingCopy(
12817
			"/Completion/src/camelcase/FFFTest.java",
13119
			"/Completion/src/deprecation/ZZZType1.java",
12818
			"package camelcase;"+
13120
			"package deprecation;"+
12819
			"public class FFFTest {\n"+
13121
			"public class ZZZType1 {\n"+
13122
			"  public class Inner1 {}\n"+
13123
			"  /** @deprecated */\n"+
13124
			"  public class Inner2 {}\n"+
12820
			"}");
13125
			"}");
12821
	
13126
	
12822
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13127
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12823
		String str = this.workingCopies[0].getSource();
13128
		String str = this.workingCopies[0].getSource();
12824
		String completeBehind = "FF";
13129
		String completeBehind = "ZZZType1.Inn";
12825
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13130
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12826
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13131
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12827
	
13132
	
12828
		assertResults(
13133
		assertResults(
12829
				"FoFoFo[TYPE_REF]{FoFoFo, camelcase, Lcamelcase.FoFoFo;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_NON_RESTRICTED) + "}\n" +
13134
				"ZZZType1.Inner1[TYPE_REF]{Inner1, deprecation, Ldeprecation.ZZZType1$Inner1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12830
				"FFFTest[TYPE_REF]{FFFTest, camelcase, Lcamelcase.FFFTest;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
13135
				"ZZZType1.Inner2[TYPE_REF]{Inner2, deprecation, Ldeprecation.ZZZType1$Inner2;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
12831
				requestor.getResults());
13136
				requestor.getResults());
12832
	} finally {
13137
	} finally {
12833
		JavaCore.setOptions(oldOptions);
13138
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
13139
		JavaCore.setOptions(options);
12834
	}
13140
	}
12835
}
13141
}
12836
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
13142
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
12837
public void testCamelCaseType3() throws JavaModelException {
13143
public void testDeprecationCheck6() throws JavaModelException {
12838
	this.oldOptions = JavaCore.getOptions();
13144
	Hashtable options = JavaCore.getOptions();
13145
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
13146
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
13147
	
13148
	JavaCore.setOptions(options);
13149
12839
	try {
13150
	try {
12840
		Hashtable options = new Hashtable(oldOptions);
13151
12841
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
13152
		this.workingCopies = new ICompilationUnit[2];
12842
		JavaCore.setOptions(options);
12843
			
12844
		this.workingCopies = new ICompilationUnit[1];
12845
		this.workingCopies[0] = getWorkingCopy(
13153
		this.workingCopies[0] = getWorkingCopy(
12846
			"/Completion/src/camelcase/Test.java",
13154
			"/Completion/src/deprecation/Test.java",
12847
			"package camelcase;"+
13155
			"package deprecation;"+
12848
			"public class Test {\n"+
13156
			"public class Test {\n"+
12849
			"  /**/FF\n"+
13157
			"  ZZZType1.Inn\n"+
12850
			"}\n"+
13158
			"}");
12851
			"class FoFoFo {\n"+
13159
		
12852
			"}\n"+
13160
		this.workingCopies[1] = getWorkingCopy(
12853
			"class FFFTest {\n"+
13161
			"/Completion/src/deprecation/ZZZType1.java",
13162
			"package deprecation;"+
13163
			"public class ZZZType1 {\n"+
13164
			"  public class Inner1 {}\n"+
13165
			"  /** @deprecated */\n"+
13166
			"  public class Inner2 {}\n"+
12854
			"}");
13167
			"}");
12855
	
13168
	
12856
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13169
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12857
		String str = this.workingCopies[0].getSource();
13170
		String str = this.workingCopies[0].getSource();
12858
		String completeBehind = "/**/FF";
13171
		String completeBehind = "ZZZType1.Inn";
12859
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13172
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12860
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13173
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12861
	
13174
	
12862
		assertResults(
13175
		assertResults(
12863
				"FF[POTENTIAL_METHOD_DECLARATION]{FF, Lcamelcase.Test;, ()V, FF, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
13176
				"ZZZType1.Inner1[TYPE_REF]{Inner1, deprecation, Ldeprecation.ZZZType1$Inner1;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
12864
				"FoFoFo[TYPE_REF]{FoFoFo, camelcase, Lcamelcase.FoFoFo;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12865
				"FFFTest[TYPE_REF]{FFFTest, camelcase, Lcamelcase.FFFTest;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12866
				requestor.getResults());
13177
				requestor.getResults());
12867
	} finally {
13178
	} finally {
12868
		JavaCore.setOptions(oldOptions);
13179
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
13180
		JavaCore.setOptions(options);
12869
	}
13181
	}
12870
}
13182
}
12871
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
13183
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
12872
public void testCamelCaseType4() throws JavaModelException {
13184
public void testDeprecationCheck7() throws JavaModelException {
12873
	this.oldOptions = JavaCore.getOptions();
13185
	Hashtable options = JavaCore.getOptions();
13186
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
13187
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED); //$NON-NLS-1$
13188
	
13189
	JavaCore.setOptions(options);
13190
12874
	try {
13191
	try {
12875
		Hashtable options = new Hashtable(oldOptions);
13192
12876
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
13193
		this.workingCopies = new ICompilationUnit[2];
12877
		JavaCore.setOptions(options);
12878
		
12879
		this.workingCopies = new ICompilationUnit[3];
12880
		this.workingCopies[0] = getWorkingCopy(
13194
		this.workingCopies[0] = getWorkingCopy(
12881
			"/Completion/src/camelcase/Test.java",
13195
			"/Completion/src/deprecation/Test.java",
12882
			"package camelcase;"+
13196
			"package deprecation;"+
12883
			"public class Test {\n"+
13197
			"public class Test {\n"+
12884
			"  FF\n"+
13198
			"  void foo() {"+
13199
			"    ZZZType1.fo\n"+
13200
			"  }"+
12885
			"}");
13201
			"}");
12886
	
13202
		
12887
		this.workingCopies[1] = getWorkingCopy(
13203
		this.workingCopies[1] = getWorkingCopy(
12888
			"/Completion/src/camelcase/Member1.java",
13204
			"/Completion/src/deprecation/ZZZType1.java",
12889
			"package camelcase;"+
13205
			"package deprecation;"+
12890
			"public class Member1 {\n"+
13206
			"public class ZZZType1 {\n"+
12891
			"  public class FoFoFo {\n"+
13207
			"  public static int foo1;\n"+
12892
			"  }\n"+
13208
			"  /** @deprecated */\n"+
13209
			"  public static int foo2;\n"+
13210
			"}");
13211
	
13212
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13213
		String str = this.workingCopies[0].getSource();
13214
		String completeBehind = "ZZZType1.fo";
13215
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13216
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13217
	
13218
		assertResults(
13219
				"foo1[FIELD_REF]{foo1, Ldeprecation.ZZZType1;, I, foo1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n" +
13220
				"foo2[FIELD_REF]{foo2, Ldeprecation.ZZZType1;, I, foo2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}",
13221
				requestor.getResults());
13222
	} finally {
13223
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
13224
		JavaCore.setOptions(options);
13225
	}
13226
}
13227
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
13228
public void testDeprecationCheck8() throws JavaModelException {
13229
	Hashtable options = JavaCore.getOptions();
13230
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
13231
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.ENABLED); //$NON-NLS-1$
13232
	
13233
	JavaCore.setOptions(options);
13234
13235
	try {
13236
13237
		this.workingCopies = new ICompilationUnit[2];
13238
		this.workingCopies[0] = getWorkingCopy(
13239
			"/Completion/src/deprecation/Test.java",
13240
			"package deprecation;"+
13241
			"public class Test {\n"+
13242
			"  void foo() {"+
13243
			"    ZZZType1.fo\n"+
13244
			"  }"+
12893
			"}");
13245
			"}");
12894
		
13246
		
12895
		this.workingCopies[2] = getWorkingCopy(
13247
		this.workingCopies[1] = getWorkingCopy(
12896
			"/Completion/src/camelcase/Member2.java",
13248
			"/Completion/src/deprecation/ZZZType1.java",
12897
			"package camelcase;"+
13249
			"package deprecation;"+
12898
			"public class Member2 {\n"+
13250
			"public class ZZZType1 {\n"+
12899
			"  public class FFFTest {\n"+
13251
			"  public static int foo1;\n"+
12900
			"  }\n"+
13252
			"  /** @deprecated */\n"+
13253
			"  public static int foo2;\n"+
12901
			"}");
13254
			"}");
12902
	
13255
	
12903
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13256
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12904
		String str = this.workingCopies[0].getSource();
13257
		String str = this.workingCopies[0].getSource();
12905
		String completeBehind = "FF";
13258
		String completeBehind = "ZZZType1.fo";
12906
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13259
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12907
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13260
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12908
	
13261
	
12909
		assertResults(
13262
		assertResults(
12910
				"FF[POTENTIAL_METHOD_DECLARATION]{FF, Lcamelcase.Test;, ()V, FF, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
13263
				"foo1[FIELD_REF]{foo1, Ldeprecation.ZZZType1;, I, foo1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}",
12911
				"Member1.FoFoFo[TYPE_REF]{camelcase.Member1.FoFoFo, camelcase, Lcamelcase.Member1$FoFoFo;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_NON_RESTRICTED) + "}\n" +
12912
				"Member2.FFFTest[TYPE_REF]{camelcase.Member2.FFFTest, camelcase, Lcamelcase.Member2$FFFTest;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
12913
				requestor.getResults());
13264
				requestor.getResults());
12914
	} finally {
13265
	} finally {
12915
		JavaCore.setOptions(oldOptions);
13266
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
13267
		JavaCore.setOptions(options);
12916
	}
13268
	}
12917
}
13269
}
12918
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
13270
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=127296
12919
public void testCamelCaseType5() throws JavaModelException {
13271
public void testDeprecationCheck9() throws JavaModelException {
12920
	this.oldOptions = JavaCore.getOptions();
13272
	Hashtable options = JavaCore.getOptions();
13273
	Object optionValue = options.get(JavaCore.CODEASSIST_DEPRECATION_CHECK);
13274
	options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED); //$NON-NLS-1$
13275
	
13276
	JavaCore.setOptions(options);
13277
12921
	try {
13278
	try {
12922
		Hashtable options = new Hashtable(oldOptions);
13279
12923
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
12924
		JavaCore.setOptions(options);
12925
		
12926
		this.workingCopies = new ICompilationUnit[1];
13280
		this.workingCopies = new ICompilationUnit[1];
12927
		this.workingCopies[0] = getWorkingCopy(
13281
		this.workingCopies[0] = getWorkingCopy(
12928
			"/Completion/src/camelcase/Test.java",
13282
			"/Completion/src/deprecation/Test.java",
12929
			"package camelcase;"+
13283
			"package deprecation;"+
12930
			"public class Test {\n"+
13284
			"public class Test {\n"+
12931
			"  public class FoFoFo {\n"+
13285
			"  public void bar1(){}\n"+
12932
			"    public class FFFTest {\n"+
13286
			"  /** @deprecated */\n"+
12933
			"      FF\n"+
13287
			"  public void bar2(){}\n"+
12934
			"    }\n"+
13288
			"  void foo() {"+
12935
			"  }\n"+
13289
			"    bar\n"+
13290
			"  }"+
12936
			"}");
13291
			"}");
12937
	
13292
	
12938
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13293
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12939
		String str = this.workingCopies[0].getSource();
13294
		String str = this.workingCopies[0].getSource();
12940
		String completeBehind = "FF";
13295
		String completeBehind = "bar";
12941
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13296
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12942
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13297
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12943
	
13298
	
12944
		assertResults(
13299
		assertResults(
12945
				"FF[POTENTIAL_METHOD_DECLARATION]{FF, Lcamelcase.Test$FoFoFo$FFFTest;, ()V, FF, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
13300
				"bar1[METHOD_REF]{bar1(), Ldeprecation.Test;, ()V, bar1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
12946
				"Test.FoFoFo[TYPE_REF]{FoFoFo, camelcase, Lcamelcase.Test$FoFoFo;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
13301
				"bar2[METHOD_REF]{bar2(), Ldeprecation.Test;, ()V, bar2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12947
				"Test.FoFoFo.FFFTest[TYPE_REF]{FFFTest, camelcase, Lcamelcase.Test$FoFoFo$FFFTest;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12948
				requestor.getResults());
13302
				requestor.getResults());
12949
	} finally {
13303
	} finally {
12950
		JavaCore.setOptions(oldOptions);
13304
		options.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, optionValue);
13305
		JavaCore.setOptions(options);
12951
	}
13306
	}
12952
}
13307
}
12953
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
13308
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=144858
12954
public void testCamelCaseMethod1() throws JavaModelException {
13309
public void testDuplicateLocals1() throws JavaModelException {
12955
	this.oldOptions = JavaCore.getOptions();
13310
	this.workingCopies = new ICompilationUnit[2];
12956
	try {
13311
	this.workingCopies[0] = getWorkingCopy(
12957
		Hashtable options = new Hashtable(oldOptions);
13312
		"/Completion/src/test/Test.java",
12958
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
13313
		"package test;"+
12959
		JavaCore.setOptions(options);
13314
		"public class Test {\n" + 
12960
		
13315
		"	void foo() {\n" + 
12961
	this.workingCopies = new ICompilationUnit[1];
13316
		"		int x = 0;\n" + 
12962
		this.workingCopies[0] = getWorkingCopy(
13317
		"		TestString x = null;\n" + 
12963
			"/Completion/src/camelcase/Test.java",
13318
		"		x.bar;\n" + 
12964
			"package camelcase;"+
13319
		"	}\n" + 
12965
			"public class Test {\n"+
13320
		"}");
12966
			"  void oneTwoThree(){}\n"+
13321
	
12967
			"  void oTTMethod(){}\n"+
13322
	this.workingCopies[1] = getWorkingCopy(
12968
			"  void foo() {\n"+
13323
		"/Completion/src/test/TestString.java",
12969
			"    oTT\n"+
13324
		"package test;"+
12970
			"  }\n"+
13325
		"public class TestString {\n" + 
12971
			"}");
13326
		"	public void bar() {\n" + 
12972
	
13327
		"	}\n" + 
12973
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13328
		"}");
12974
		String str = this.workingCopies[0].getSource();
13329
12975
		String completeBehind = "oTT";
13330
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12976
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13331
	String str = this.workingCopies[0].getSource();
12977
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13332
	String completeBehind = "bar";
12978
	
13333
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12979
		assertResults(
13334
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12980
				"oneTwoThree[METHOD_REF]{oneTwoThree(), Lcamelcase.Test;, ()V, oneTwoThree, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
13335
12981
				"oTTMethod[METHOD_REF]{oTTMethod(), Lcamelcase.Test;, ()V, oTTMethod, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13336
	assertResults(
12982
				requestor.getResults());
13337
			"bar[METHOD_REF]{bar(), Ltest.TestString;, ()V, bar, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
12983
	} finally {
13338
			requestor.getResults());
12984
		JavaCore.setOptions(oldOptions);
13339
}
13340
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=144858
13341
public void testDuplicateLocals2() throws JavaModelException {
13342
	this.workingCopies = new ICompilationUnit[2];
13343
	this.workingCopies[0] = getWorkingCopy(
13344
		"/Completion/src/test/Test.java",
13345
		"package test;"+
13346
		"public class Test {\n" + 
13347
		"        public static void main(String[] args) {\n" + 
13348
		"                int x = 2;\n" + 
13349
		"                try {\n" + 
13350
		"                \n" + 
13351
		"                } catch(TestException x) {\n" + 
13352
		"                        x.bar\n" + 
13353
		"                } catch(Exception e) {\n" + 
13354
		"                }\n" + 
13355
		"        }\n" + 
13356
		"}");
13357
	
13358
	this.workingCopies[1] = getWorkingCopy(
13359
		"/Completion/src/test/TestException.java",
13360
		"package test;"+
13361
		"public class TestException extends Exception {\n" + 
13362
		"	public void bar() {\n" + 
13363
		"	}\n" + 
13364
		"}");
13365
13366
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13367
	String str = this.workingCopies[0].getSource();
13368
	String completeBehind = "bar";
13369
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13370
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13371
13372
	assertResults(
13373
			"bar[METHOD_REF]{bar(), Ltest.TestException;, ()V, bar, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
13374
			requestor.getResults());
13375
}
13376
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=144858
13377
public void testDuplicateLocals3() throws JavaModelException {
13378
	this.workingCopies = new ICompilationUnit[2];
13379
	this.workingCopies[0] = getWorkingCopy(
13380
		"/Completion/src/test/Test.java",
13381
		"package test;"+
13382
		"public class Test {\n" + 
13383
		"        public static void main(String[] args) {\n" + 
13384
		"                int x = x = 0;\n" + 
13385
		"                if (true) {\n" + 
13386
		"                        TestString x = x.bar\n" + 
13387
		"                }\n" + 
13388
		"        }\n" + 
13389
		"}");
13390
	
13391
	this.workingCopies[1] = getWorkingCopy(
13392
		"/Completion/src/test/TestString.java",
13393
		"package test;"+
13394
		"public class TestString {\n" + 
13395
		"	public void bar() {\n" + 
13396
		"	}\n" + 
13397
		"}");
13398
13399
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13400
	String str = this.workingCopies[0].getSource();
13401
	String completeBehind = "bar";
13402
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13403
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13404
13405
	assertResults(
13406
			"bar[METHOD_REF]{bar(), Ltest.TestString;, ()V, bar, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
13407
			requestor.getResults());
13408
}
13409
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=144858
13410
public void testDuplicateLocals4() throws JavaModelException {
13411
	this.workingCopies = new ICompilationUnit[2];
13412
	this.workingCopies[0] = getWorkingCopy(
13413
		"/Completion/src/test/Test.java",
13414
		"package test;"+
13415
		"public class Test {\n" + 
13416
		"        public static void main(String[] args) {\n" + 
13417
		"                for (int i = 0; i < 10; i++) {\n" + 
13418
		"                        for (TestString i = null; i.bar < 5;)  {\n" + 
13419
		"                                // do something\n" + 
13420
		"                        }\n" + 
13421
		"                }\n" + 
13422
		"        }\n" + 
13423
		"}");
13424
	
13425
	this.workingCopies[1] = getWorkingCopy(
13426
		"/Completion/src/test/TestString.java",
13427
		"package test;"+
13428
		"public class TestString {\n" + 
13429
		"	public void bar() {\n" + 
13430
		"	}\n" + 
13431
		"}");
13432
13433
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13434
	String str = this.workingCopies[0].getSource();
13435
	String completeBehind = "bar";
13436
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13437
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13438
13439
	assertResults(
13440
			"bar[METHOD_REF]{bar(), Ltest.TestString;, ()V, bar, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
13441
			requestor.getResults());
13442
}
13443
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=144858
13444
public void testDuplicateLocals5() throws JavaModelException {
13445
	this.workingCopies = new ICompilationUnit[2];
13446
	this.workingCopies[0] = getWorkingCopy(
13447
		"/Completion/src/test/Test.java",
13448
		"package test;"+
13449
		"public class Test {\n" + 
13450
		"        public static void main(String[] args) {\n" + 
13451
		"                for (int i = 0; i < 10; i++) {\n" + 
13452
		"                        for (TestString i = null; ;)  {\n" + 
13453
		"                                i.bar // do something\n" + 
13454
		"                        }\n" + 
13455
		"                }\n" + 
13456
		"        }\n" + 
13457
		"}");
13458
	
13459
	this.workingCopies[1] = getWorkingCopy(
13460
		"/Completion/src/test/TestString.java",
13461
		"package test;"+
13462
		"public class TestString {\n" + 
13463
		"	public void bar() {\n" + 
13464
		"	}\n" + 
13465
		"}");
13466
13467
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13468
	String str = this.workingCopies[0].getSource();
13469
	String completeBehind = "bar";
13470
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13471
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13472
13473
	assertResults(
13474
			"bar[METHOD_REF]{bar(), Ltest.TestString;, ()V, bar, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
13475
			requestor.getResults());
13476
}
13477
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=165662
13478
public void testDuplicateLocalsType1() throws JavaModelException {
13479
	this.workingCopies = new ICompilationUnit[1];
13480
	this.workingCopies[0] = getWorkingCopy(
13481
		"/Completion/src/test/Test.java",
13482
		"package test;"+
13483
		"public class Test {\n" + 
13484
		"  void foo() {\n" + 
13485
		"     class Local {\n" + 
13486
		"        void foo() {}\n" + 
13487
		"     }\n" + 
13488
		"     {\n" + 
13489
		"        class Local {\n" + 
13490
		"                Local(int i) {\n" + 
13491
		"                        this.init(i);\n" + 
13492
		"                }\n" + 
13493
		"				 void init(int i) {}\n" +
13494
		"                public void bar() {}\n" + 
13495
		"        }\n" + 
13496
		"        Local l = new Local(0);\n" + 
13497
		"        l.bar\n" + 
13498
		"     }\n" + 
13499
		"  }\n" + 
13500
		"}");
13501
13502
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13503
	String str = this.workingCopies[0].getSource();
13504
	String completeBehind = "bar";
13505
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13506
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13507
13508
	assertResults(
13509
			"bar[METHOD_REF]{bar(), LLocal;, ()V, bar, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
13510
			requestor.getResults());
13511
}
13512
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=165662
13513
public void testDuplicateLocalsType2() throws JavaModelException {
13514
	this.workingCopies = new ICompilationUnit[1];
13515
	this.workingCopies[0] = getWorkingCopy(
13516
		"/Completion/src/test/Test.java",
13517
		"package test;"+
13518
		"public class Test {\n" + 
13519
		"        void foo() {\n" + 
13520
		"                class Local {\n" + 
13521
		"                        void foo() {\n" + 
13522
		"                        }\n" + 
13523
		"                }\n" + 
13524
		"                {\n" + 
13525
		"                        class Local {\n" + 
13526
		"                               Local(int i) {\n" + 
13527
		"                                       this.init(i);\n" + 
13528
		"                                       this.bar();\n" + 
13529
		"                               }\n" + 
13530
		"				 				void init(int i) {}\n" +
13531
		"                        		void bar() {\n" + 
13532
		"                        		}\n" + 
13533
		"                        }\n" + 
13534
		"                        Local l = new Local(0);\n" + 
13535
		"                }\n" + 
13536
		"                Local l = new Local();\n" + 
13537
		"                l.foo\n" + 
13538
		"        }\n" + 
13539
		"}");
13540
13541
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13542
	String str = this.workingCopies[0].getSource();
13543
	String completeBehind = "foo";
13544
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13545
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13546
13547
	assertResults(
13548
			"foo[METHOD_REF]{foo(), LLocal;, ()V, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_STATIC + R_NON_RESTRICTED) + "}",
13549
			requestor.getResults());
13550
}
13551
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=139937
13552
public void testEvaluationContextCompletion() throws JavaModelException {
13553
	class EvaluationContextCompletionRequestor extends CompletionRequestor {
13554
		public boolean acceptContext;
13555
		public void accept(CompletionProposal proposal) {
13556
			// Do nothing
13557
		}
13558
		public void acceptContext(CompletionContext context) {
13559
			this.acceptContext = context != null;
13560
		}
12985
	}
13561
	}
13562
	String start = "";
13563
	IJavaProject javaProject = getJavaProject("Completion");
13564
	IEvaluationContext context = javaProject.newEvaluationContext();
13565
    EvaluationContextCompletionRequestor rc = new EvaluationContextCompletionRequestor();
13566
	context.codeComplete(start, start.length(), rc);
13567
	
13568
	assertTrue("acceptContext() method isn't call", rc.acceptContext);
12986
}
13569
}
12987
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
13570
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140123
12988
public void testCamelCaseField1() throws JavaModelException {
13571
public void testEvaluationContextCompletion2() throws JavaModelException {
12989
	this.oldOptions = JavaCore.getOptions();
13572
	class EvaluationContextCompletionRequestor extends CompletionRequestor {
12990
	try {
13573
		public boolean acceptContext;
12991
		Hashtable options = new Hashtable(oldOptions);
13574
		public boolean beginReporting;
12992
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
13575
		public boolean endReporting;
12993
		JavaCore.setOptions(options);
12994
		
13576
		
12995
		this.workingCopies = new ICompilationUnit[1];
13577
		public void accept(CompletionProposal proposal) {
12996
		this.workingCopies[0] = getWorkingCopy(
13578
			// Do nothing
12997
			"/Completion/src/camelcase/Test.java",
13579
		}
12998
			"package camelcase;"+
13580
		public void acceptContext(CompletionContext context) {
12999
			"public class Test {\n"+
13581
			this.acceptContext = context != null;
13000
			"  int oneTwoThree;\n"+
13582
		}
13001
			"  int oTTField;\n"+
13583
		
13002
			"  void foo() {\n"+
13584
		public void beginReporting() {
13003
			"    oTT\n"+
13585
			this.beginReporting = true;
13004
			"  }\n"+
13586
			super.beginReporting();
13005
			"}");
13587
		}
13006
	
13588
		
13007
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13589
		public void endReporting() {
13008
		String str = this.workingCopies[0].getSource();
13590
			this.endReporting =  true;
13009
		String completeBehind = "oTT";
13591
			super.endReporting();
13010
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13592
		}
13011
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13012
	
13013
		assertResults(
13014
				"oneTwoThree[FIELD_REF]{oneTwoThree, Lcamelcase.Test;, I, oneTwoThree, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
13015
				"oTTField[FIELD_REF]{oTTField, Lcamelcase.Test;, I, oTTField, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13016
				requestor.getResults());
13017
	} finally {
13018
		JavaCore.setOptions(oldOptions);
13019
	}
13593
	}
13594
	String start = "";
13595
	IJavaProject javaProject = getJavaProject("Completion");
13596
	IEvaluationContext context = javaProject.newEvaluationContext();
13597
    EvaluationContextCompletionRequestor rc = new EvaluationContextCompletionRequestor();
13598
	context.codeComplete(start, start.length(), rc);
13599
	
13600
	assertTrue("acceptContext() method isn't call", rc.acceptContext);
13601
	assertTrue("beginReporting() method isn't call", rc.beginReporting);
13602
	assertTrue("endReporting() method isn't call", rc.endReporting);
13020
}
13603
}
13021
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
13604
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140123
13022
public void testCamelCaseLocalVariable1() throws JavaModelException {
13605
public void testEvaluationContextCompletion3() throws JavaModelException {
13023
	this.oldOptions = JavaCore.getOptions();
13606
	this.workingCopies = new ICompilationUnit[1];
13024
	try {
13607
	this.workingCopies[0] = getWorkingCopy(
13025
		Hashtable options = new Hashtable(oldOptions);
13608
		"/Completion/src/test/TestEvaluationContextCompletion3.java",
13026
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
13609
		"package test;"+
13027
		JavaCore.setOptions(options);
13610
		"public class TestEvaluationContextCompletion3 {\n"+
13028
		
13611
		"}");
13029
		this.workingCopies = new ICompilationUnit[1];
13030
		this.workingCopies[0] = getWorkingCopy(
13031
			"/Completion/src/camelcase/Test.java",
13032
			"package camelcase;"+
13033
			"public class Test {\n"+
13034
			"  void foo() {\n"+
13035
			"    int oneTwoThree;\n"+
13036
			"    int oTTLocal;\n"+
13037
			"    oTT\n"+
13038
			"  }\n"+
13039
			"}");
13040
	
13612
	
13041
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13613
	String start = "TestEvaluationContextCompletion3";
13042
		String str = this.workingCopies[0].getSource();
13614
	IJavaProject javaProject = getJavaProject("Completion");
13043
		String completeBehind = "oTT";
13615
	IEvaluationContext context = javaProject.newEvaluationContext();
13044
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13045
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13046
	
13616
	
13047
		assertResults(
13617
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, false);
13048
				"oneTwoThree[LOCAL_VARIABLE_REF]{oneTwoThree, null, I, oneTwoThree, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
13618
	context.codeComplete(start, start.length(), requestor, this.wcOwner);
13049
				"oTTLocal[LOCAL_VARIABLE_REF]{oTTLocal, null, I, oTTLocal, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13050
				requestor.getResults());
13051
	} finally {
13052
		JavaCore.setOptions(oldOptions);
13053
	}
13054
}
13055
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102572
13056
public void testCamelCaseMethodDeclaration1() throws JavaModelException {
13057
	this.oldOptions = JavaCore.getOptions();
13058
	try {
13059
		Hashtable options = new Hashtable(oldOptions);
13060
		options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
13061
		JavaCore.setOptions(options);
13062
		
13063
		this.workingCopies = new ICompilationUnit[2];
13064
		this.workingCopies[0] = getWorkingCopy(
13065
			"/Completion/src/camelcase/Test.java",
13066
			"package camelcase;"+
13067
			"public class Test extends SuperClass {\n"+
13068
			"  oTT\n"+
13069
			"}");
13070
		
13071
		this.workingCopies[1] = getWorkingCopy(
13072
			"/Completion/src/camelcase/SuperClass.java",
13073
			"package camelcase;"+
13074
			"public class SuperClass {\n"+
13075
			"  public void oneTwoThree(){}\n"+
13076
			"  public void oTTMethod(){}\n"+
13077
			"}");
13078
	
13619
	
13079
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13620
	int startOffset = 0;
13080
		String str = this.workingCopies[0].getSource();
13621
	int endOffset = start.length();
13081
		String completeBehind = "oTT";
13082
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13083
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13084
	
13622
	
13085
		assertResults(
13623
	assertResults(
13086
				"oTT[POTENTIAL_METHOD_DECLARATION]{oTT, Lcamelcase.Test;, ()V, oTT, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
13624
			"completion offset="+endOffset+"\n"+
13087
				"oneTwoThree[METHOD_DECLARATION]{public void oneTwoThree(), Lcamelcase.SuperClass;, ()V, oneTwoThree, null, " + (R_DEFAULT + R_INTERESTING + R_CAMEL_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
13625
			"completion range=["+startOffset+", "+(endOffset-1)+"]\n"+
13088
				"oTTMethod[METHOD_DECLARATION]{public void oTTMethod(), Lcamelcase.SuperClass;, ()V, oTTMethod, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13626
			"completion token=\"TestEvaluationContextCompletion3\"\n"+
13089
				requestor.getResults());
13627
			"completion token kind=TOKEN_KIND_NAME\n"+
13090
	} finally {
13628
			"expectedTypesSignatures=null\n"+
13091
		JavaCore.setOptions(oldOptions);
13629
			"expectedTypesKeys=null",
13092
	}
13630
            requestor.getContext());
13631
    
13632
	assertResults(
13633
			"TestEvaluationContextCompletion3[TYPE_REF]{test.TestEvaluationContextCompletion3, test, Ltest.TestEvaluationContextCompletion3;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
13634
			requestor.getResults());
13093
}
13635
}
13094
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=22072
13636
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=140123
13095
public void testLabel1() throws JavaModelException {
13637
public void testEvaluationContextCompletion4() throws JavaModelException {
13096
	this.workingCopies = new ICompilationUnit[1];
13638
	this.workingCopies = new ICompilationUnit[1];
13097
	this.workingCopies[0] = getWorkingCopy(
13639
	this.workingCopies[0] = getWorkingCopy(
13098
		"/Completion/src/label/Test.java",
13640
		"/Completion/src/test/TestEvaluationContextCompletion4.java",
13099
		"package label;"+
13641
		"package test;"+
13100
		"public class Test {\n"+
13642
		"public class TestEvaluationContextCompletion4 {\n"+
13101
		"  void foo() {\n"+
13102
		"    label1 : for(;;) foo();\n"+
13103
		"    label2 : for(;;)\n"+
13104
		"      label3 : for(;;) {\n"+
13105
		"        label4 : for(;;) {\n"+
13106
		"          break lab\n"+
13107
		"        }\n"+
13108
		"      }\n"+
13109
		"  }\n"+
13110
		"}");
13643
		"}");
13111
13644
	
13112
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13645
	String start = "TestEvaluationContextCompletion4";
13113
	String str = this.workingCopies[0].getSource();
13646
	IJavaProject javaProject = getJavaProject("Completion");
13114
	String completeBehind = "lab";
13647
	IEvaluationContext context = javaProject.newEvaluationContext();
13115
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13648
	
13116
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13649
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, false);
13117
13650
	requestor.setIgnored(CompletionProposal.TYPE_REF, true);
13651
	context.codeComplete(start, start.length(), requestor, this.wcOwner);
13652
	
13653
	int startOffset = 0;
13654
	int endOffset = start.length();
13655
	
13118
	assertResults(
13656
	assertResults(
13119
			"label2[LABEL_REF]{label2, null, null, label2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
13657
			"completion offset="+endOffset+"\n"+
13120
			"label3[LABEL_REF]{label3, null, null, label3, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
13658
			"completion range=["+startOffset+", "+(endOffset-1)+"]\n"+
13121
			"label4[LABEL_REF]{label4, null, null, label4, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
13659
			"completion token=\"TestEvaluationContextCompletion4\"\n"+
13660
			"completion token kind=TOKEN_KIND_NAME\n"+
13661
			"expectedTypesSignatures=null\n"+
13662
			"expectedTypesKeys=null",
13663
            requestor.getContext());
13664
    
13665
	assertResults(
13666
			"",
13122
			requestor.getResults());
13667
			requestor.getResults());
13123
}
13668
}
13124
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=22072
13669
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=141518
13125
public void testLabel2() throws JavaModelException {
13670
public void testEvaluationContextCompletion5() throws JavaModelException {
13126
	this.workingCopies = new ICompilationUnit[1];
13671
	this.workingCopies = new ICompilationUnit[1];
13127
	this.workingCopies[0] = getWorkingCopy(
13672
	this.workingCopies[0] = getWorkingCopy(
13128
		"/Completion/src/label/Test.java",
13673
		"/Completion/src/test/TestEvaluationContextCompletion5.java",
13129
		"package label;"+
13674
		"package test;"+
13130
		"public class Test {\n"+
13675
		"public class TestEvaluationContextCompletion5 {\n"+
13131
		"  void foo() {\n"+
13132
		"    #\n"+
13133
		"    label1 : for(;;) foo();\n"+
13134
		"    label2 : for(;;)\n"+
13135
		"      label3 : for(;;) {\n"+
13136
		"        label4 : for(;;) {\n"+
13137
		"          break lab\n"+
13138
		"        }\n"+
13139
		"      }\n"+
13140
		"  }\n"+
13141
		"}");
13676
		"}");
13142
13677
	
13143
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13678
	String start = "someVariable.to";
13144
	String str = this.workingCopies[0].getSource();
13679
	IJavaProject javaProject = getJavaProject("Completion");
13145
	String completeBehind = "lab";
13680
	IEvaluationContext context = javaProject.newEvaluationContext();
13146
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13681
	
13147
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13682
	context.newVariable( "Object", "someVariable", null );
13148
13683
	
13684
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, false);
13685
	context.codeComplete(start, start.length(), requestor, this.wcOwner);
13686
	
13687
	int startOffset = start.length() - 2;
13688
	int endOffset = startOffset + 2 ;
13689
	
13149
	assertResults(
13690
	assertResults(
13150
			"label2[LABEL_REF]{label2, null, null, label2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
13691
			"completion offset="+endOffset+"\n"+
13151
			"label3[LABEL_REF]{label3, null, null, label3, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
13692
			"completion range=["+startOffset+", "+(endOffset-1)+"]\n"+
13152
			"label4[LABEL_REF]{label4, null, null, label4, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
13693
			"completion token=\"to\"\n"+
13694
			"completion token kind=TOKEN_KIND_NAME\n"+
13695
			"expectedTypesSignatures=null\n"+
13696
			"expectedTypesKeys=null",
13697
            requestor.getContext());
13698
    
13699
	assertResults(
13700
			"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED)+"}",
13153
			requestor.getResults());
13701
			requestor.getResults());
13154
}
13702
}
13155
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=22072
13703
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13156
public void testLabel3() throws JavaModelException {
13704
public void testFavoriteImports001() throws JavaModelException {
13157
	this.workingCopies = new ICompilationUnit[1];
13705
	this.workingCopies = new ICompilationUnit[2];
13158
	this.workingCopies[0] = getWorkingCopy(
13706
	this.workingCopies[0] = getWorkingCopy(
13159
		"/Completion/src/label/Test.java",
13707
			"/Completion/src3/test/Test.java",
13160
		"package label;"+
13708
			"package test;\n" +
13161
		"public class Test {\n"+
13709
			"public class Test {\n" +
13162
		"  void foo() {\n"+
13710
			"    public void method() {\n" +
13163
		"    label1 : for(;;) foo();\n"+
13711
			"        foo\n" +
13164
		"    label2 : for(;;)\n"+
13712
			"    }\n" +
13165
		"      label3 : for(;;) {\n"+
13713
			"}");
13166
		"        label4 : for(;;) {\n"+
13714
	
13167
		"          break lab\n"+
13715
	this.workingCopies[1] = getWorkingCopy(
13168
		"  }\n"+
13716
			"/Completion/src3/test/p/ZZZ.java",
13169
		"}");
13717
			"package test.p;\n" +
13170
13718
			"public class ZZZ {\n" +
13171
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13719
			"    public static int foo;\n" +
13720
			"}");
13721
	
13722
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13723
	requestor.allowAllRequiredProposals();
13724
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13725
	
13172
	String str = this.workingCopies[0].getSource();
13726
	String str = this.workingCopies[0].getSource();
13173
	String completeBehind = "lab";
13727
	String completeBehind = "foo";
13174
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13728
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13175
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13729
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13176
13730
	
13731
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13732
	int start1 = str.lastIndexOf("foo") + "".length();
13733
	int end1 = start1 + "foo".length();
13734
	int start2 = str.lastIndexOf("public class");
13735
	int end2 = start2 + "".length();
13177
	assertResults(
13736
	assertResults(
13178
			"label2[LABEL_REF]{label2, null, null, label2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
13737
			"foo[FIELD_REF]{ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13179
			"label3[LABEL_REF]{label3, null, null, label3, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
13738
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13180
			"label4[LABEL_REF]{label4, null, null, label4, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
13181
			requestor.getResults());
13739
			requestor.getResults());
13182
}
13740
}
13183
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=22072
13741
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13184
public void testLabel4() throws JavaModelException {
13742
public void testFavoriteImports002() throws JavaModelException {
13185
	this.workingCopies = new ICompilationUnit[1];
13743
	this.workingCopies = new ICompilationUnit[2];
13186
	this.workingCopies[0] = getWorkingCopy(
13744
	this.workingCopies[0] = getWorkingCopy(
13187
		"/Completion/src/label/Test.java",
13745
			"/Completion/src3/test/Test.java",
13188
		"package label;"+
13746
			"package test;\n" +
13189
		"public class Test {\n"+
13747
			"public class Test {\n" +
13190
		"  void foo() {\n"+
13748
			"    public void method() {\n" +
13191
		"    #\n"+
13749
			"        foo\n" +
13192
		"    label1 : for(;;) foo();\n"+
13750
			"    }\n" +
13193
		"    label2 : for(;;)\n"+
13751
			"}");
13194
		"      label3 : for(;;) {\n"+
13752
	
13195
		"        label4 : for(;;) {\n"+
13753
	this.workingCopies[1] = getWorkingCopy(
13196
		"          break lab\n"+
13754
			"/Completion/src3/test/p/ZZZ.java",
13197
		"  }\n"+
13755
			"package test.p;\n" +
13198
		"}");
13756
			"public class ZZZ {\n" +
13199
13757
			"    public static int foo(){}\n" +
13200
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13758
			"}");
13759
	
13760
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13761
	requestor.allowAllRequiredProposals();
13762
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13763
	
13201
	String str = this.workingCopies[0].getSource();
13764
	String str = this.workingCopies[0].getSource();
13202
	String completeBehind = "lab";
13765
	String completeBehind = "foo";
13203
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13766
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13204
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13767
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13205
13768
13769
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13770
	int start1 = str.lastIndexOf("foo") + "".length();
13771
	int end1 = start1 + "foo".length();
13772
	int start2 = str.lastIndexOf("public class");
13773
	int end2 = start2 + "".length();
13206
	assertResults(
13774
	assertResults(
13207
			"label2[LABEL_REF]{label2, null, null, label2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
13775
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13208
			"label3[LABEL_REF]{label3, null, null, label3, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
13776
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13209
			"label4[LABEL_REF]{label4, null, null, label4, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
13210
			requestor.getResults());
13777
			requestor.getResults());
13211
}
13778
}
13212
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=22072
13779
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13213
public void testLabel5() throws JavaModelException {
13780
public void testFavoriteImports003() throws JavaModelException {
13214
	this.workingCopies = new ICompilationUnit[1];
13781
	this.workingCopies = new ICompilationUnit[2];
13215
	this.workingCopies[0] = getWorkingCopy(
13782
	this.workingCopies[0] = getWorkingCopy(
13216
		"/Completion/src/label/Test.java",
13783
			"/Completion/src3/test/Test.java",
13217
		"package label;"+
13784
			"package test;\n" +
13218
		"public class Test {\n" + 
13785
			"public class Test {\n" +
13219
		"  void foo() {\n" + 
13786
			"    public void method() {\n" +
13220
		"    #\n" + 
13787
			"        foo\n" +
13221
 		"    label1 : for(;;) {\n" + 
13788
			"    }\n" +
13222
 		"      class X {\n" + 
13789
			"}");
13223
 		"        void foo() {\n" + 
13790
	
13224
 		"          label2 : for(;;) foo();\n" + 
13791
	this.workingCopies[1] = getWorkingCopy(
13225
 		"        }\n" + 
13792
			"/Completion/src3/test/p/ZZZ.java",
13226
 		"      }\n" + 
13793
			"package test.p;\n" +
13227
 		"      continue lab\n" + 
13794
			"public class ZZZ {\n" +
13228
 		"    }\n" + 
13795
			"    public static int foo;\n" +
13229
		"  }\n" + 
13796
			"}");
13230
		"}\n");
13797
	
13231
13798
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13232
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13799
	requestor.allowAllRequiredProposals();
13800
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"});
13801
	
13233
	String str = this.workingCopies[0].getSource();
13802
	String str = this.workingCopies[0].getSource();
13234
	String completeBehind = "lab";
13803
	String completeBehind = "foo";
13235
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13804
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13236
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13805
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13237
13806
13238
	assertResults(
13807
	assertResults(
13239
			"label1[LABEL_REF]{label1, null, null, label1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
13808
			"",
13240
			requestor.getResults());
13809
			requestor.getResults());
13241
}
13810
}
13242
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=22072
13811
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13243
public void testLabel6() throws JavaModelException {
13812
public void testFavoriteImports004() throws JavaModelException {
13244
	this.workingCopies = new ICompilationUnit[1];
13813
	this.workingCopies = new ICompilationUnit[2];
13245
	this.workingCopies[0] = getWorkingCopy(
13814
	this.workingCopies[0] = getWorkingCopy(
13246
		"/Completion/src/label/Test.java",
13815
			"/Completion/src3/test/Test.java",
13247
		"package label;"+
13816
			"package test;\n" +
13248
		"public class Test {\n" + 
13817
			"public class Test {\n" +
13249
		"  void foo() {\n" + 
13818
			"    public void method() {\n" +
13250
		"    #\n" + 
13819
			"        foo\n" +
13251
 		"    label1 : for(;;) {\n" + 
13820
			"    }\n" +
13252
 		"      class X {\n" + 
13821
			"}");
13253
 		"        void foo() {\n" + 
13822
	
13254
 		"          label2 : for(;;) {\n" + 
13823
	this.workingCopies[1] = getWorkingCopy(
13255
 		"            continue lab\n" + 
13824
			"/Completion/src3/test/p/ZZZ.java",
13256
 		"          }\n" + 
13825
			"package test.p;\n" +
13257
 		"        }\n" + 
13826
			"public class ZZZ {\n" +
13258
 		"      }\n" + 
13827
			"    public static int foo(){}\n" +
13259
 		"    }\n" + 
13828
			"}");
13260
		"  }\n" + 
13829
	
13261
		"}\n");
13830
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13262
13831
	requestor.allowAllRequiredProposals();
13263
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13832
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"});
13833
	
13264
	String str = this.workingCopies[0].getSource();
13834
	String str = this.workingCopies[0].getSource();
13265
	String completeBehind = "lab";
13835
	String completeBehind = "foo";
13266
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13836
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13267
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13837
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13268
13838
13269
	assertResults(
13839
	assertResults(
13270
			"label2[LABEL_REF]{label2, null, null, label2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
13840
			"",
13271
			requestor.getResults());
13841
			requestor.getResults());
13272
}
13842
}
13273
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=22072
13843
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13274
public void testStaticMembers1() throws JavaModelException {
13844
public void testFavoriteImports005() throws JavaModelException {
13275
	this.workingCopies = new ICompilationUnit[3];
13845
	this.workingCopies = new ICompilationUnit[2];
13276
	this.workingCopies[0] = getWorkingCopy(
13846
	this.workingCopies[0] = getWorkingCopy(
13277
		"/Completion/src/test/Test.java",
13847
			"/Completion/src3/test/Test.java",
13278
		"package test;"+
13848
			"package test;\n" +
13279
		"public class Test {\n" + 
13849
			"public class Test {\n" +
13280
		"  void foo() {\n" + 
13850
			"    public void method() {\n" +
13281
 		"    StaticMembers.\n" + 
13851
			"        foo\n" +
13282
		"  }\n" + 
13852
			"    }\n" +
13283
		"}\n");
13853
			"}");
13284
	
13854
	
13285
	this.workingCopies[1] = getWorkingCopy(
13855
	this.workingCopies[1] = getWorkingCopy(
13286
		"/Completion/src/test/StaticMembers.java",
13856
			"/Completion/src3/test/p/ZZZ.java",
13287
		"package test;"+
13857
			"package test.p;\n" +
13288
		"public class StaticMembers extends SuperStaticMembers {\n" + 
13858
			"public class ZZZ {\n" +
13289
		"  public static int staticField;\n" + 
13859
			"    public static int foo;\n" +
13290
 		"  public static int staticMethod() {}\n" + 
13860
			"}");
13291
		"  public class Clazz {}\n" + 
13861
	
13292
		"  public static class StaticClazz {}\n" + 
13862
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13293
		"}\n");
13863
	requestor.allowAllRequiredProposals();
13864
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13294
	
13865
	
13295
	this.workingCopies[2] = getWorkingCopy(
13296
			"/Completion/src/test/SuperStaticMembers.java",
13297
			"package test;"+
13298
			"public class SuperStaticMembers {\n" + 
13299
			"  public static int superStaticField;\n" + 
13300
	 		"  public static int supeStaticMethod() {}\n" + 
13301
			"  public class SuperClazz {}\n" + 
13302
			"  public static class SuperStaticClazz {}\n" + 
13303
			"}\n");
13304
13305
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13306
	String str = this.workingCopies[0].getSource();
13866
	String str = this.workingCopies[0].getSource();
13307
	String completeBehind = "StaticMembers.";
13867
	String completeBehind = "foo";
13308
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13868
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13309
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13869
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13310
13870
13871
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13872
	int start1 = str.lastIndexOf("foo") + "".length();
13873
	int end1 = start1 + "foo".length();
13874
	int start2 = str.lastIndexOf("public class");
13875
	int end2 = start2 + "".length();
13311
	assertResults(
13876
	assertResults(
13312
			"supeStaticMethod[METHOD_REF]{supeStaticMethod(), Ltest.SuperStaticMembers;, ()I, supeStaticMethod, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
13877
			"foo[FIELD_REF]{ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13313
			"superStaticField[FIELD_REF]{superStaticField, Ltest.SuperStaticMembers;, I, superStaticField, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
13878
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13314
			"StaticMembers.Clazz[TYPE_REF]{Clazz, test, Ltest.StaticMembers$Clazz;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n" +
13315
			"StaticMembers.StaticClazz[TYPE_REF]{StaticClazz, test, Ltest.StaticMembers$StaticClazz;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n" +
13316
			"class[FIELD_REF]{class, null, Ljava.lang.Class;, class, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n" +
13317
			"staticField[FIELD_REF]{staticField, Ltest.StaticMembers;, I, staticField, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n" +
13318
			"staticMethod[METHOD_REF]{staticMethod(), Ltest.StaticMembers;, ()I, staticMethod, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n" +
13319
			"this[KEYWORD]{this, null, null, this, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}",
13320
			requestor.getResults());
13879
			requestor.getResults());
13321
}
13880
}
13322
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=164311
13881
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13323
public void testBug164311() throws JavaModelException {
13882
public void testFavoriteImports006() throws JavaModelException {
13324
	this.workingCopies = new ICompilationUnit[1];
13883
	this.workingCopies = new ICompilationUnit[2];
13325
	this.workingCopies[0] = getWorkingCopy(
13884
	this.workingCopies[0] = getWorkingCopy(
13326
		"/Completion/src/test/Test.java",
13885
			"/Completion/src3/test/Test.java",
13327
		"package test;"+
13886
			"package test;\n" +
13328
		"public class Test {\n" + 
13887
			"public class Test {\n" +
13329
		"    public int zzzzzz;\n" + 
13888
			"    public void method() {\n" +
13330
		"    public void method1() {\n" + 
13889
			"        foo\n" +
13331
		"        label : if (0> (10));\n" + 
13890
			"    }\n" +
13332
		"        zzz\n" + 
13891
			"}");
13333
		"    }\n" + 
13892
	
13334
		"}\n");
13893
	this.workingCopies[1] = getWorkingCopy(
13335
13894
			"/Completion/src3/test/p/ZZZ.java",
13336
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13895
			"package test.p;\n" +
13896
			"public class ZZZ {\n" +
13897
			"    public static int foo(){}\n" +
13898
			"}");
13899
	
13900
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13901
	requestor.allowAllRequiredProposals();
13902
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13903
	
13337
	String str = this.workingCopies[0].getSource();
13904
	String str = this.workingCopies[0].getSource();
13338
	String completeBehind = "zzz";
13905
	String completeBehind = "foo";
13339
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13906
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13340
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13907
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13341
13908
13909
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13910
	int start1 = str.lastIndexOf("foo") + "".length();
13911
	int end1 = start1 + "foo".length();
13912
	int start2 = str.lastIndexOf("public class");
13913
	int end2 = start2 + "".length();
13342
	assertResults(
13914
	assertResults(
13343
			"zzzzzz[FIELD_REF]{zzzzzz, Ltest.Test;, I, zzzzzz, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13915
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13916
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13344
			requestor.getResults());
13917
			requestor.getResults());
13345
}
13918
}
13346
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=164311
13919
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13347
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=167750
13920
public void testFavoriteImports007() throws JavaModelException {
13348
public void testBug164311_2() throws JavaModelException {
13921
	this.workingCopies = new ICompilationUnit[2];
13349
	this.workingCopies = new ICompilationUnit[1];
13350
	this.workingCopies[0] = getWorkingCopy(
13922
	this.workingCopies[0] = getWorkingCopy(
13351
		"/Completion/src/test/Test.java",
13923
			"/Completion/src3/test/Test.java",
13352
		"package test;\n"+
13924
			"package test;\n" +
13353
		"public class X {\n"+
13925
			"import test.p.ZZZ.*;\n" +
13354
		"    public void zork() { \n"+
13926
			"public class Test {\n" +
13355
		"    } \n"+
13927
			"    public void method() {\n" +
13356
		"    public void foo() { \n"+
13928
			"        foo\n" +
13357
		"        this.foo(new Object(){\n"+
13929
			"    }\n" +
13358
		"            public void bar() {\n"+
13930
			"}");
13359
		"                if (zzz>(Integer)vvv.foo(i)) {\n"+
13931
	
13360
		"                    return;\n"+
13932
	this.workingCopies[1] = getWorkingCopy(
13361
		"                }\n"+
13933
			"/Completion/src3/test/p/ZZZ.java",
13362
		"                if (true) {\n"+
13934
			"package test.p;\n" +
13363
		"                    return;\n"+
13935
			"public class ZZZ {\n" +
13364
		"                }\n"+
13936
			"    public static int foo(){}\n" +
13365
		"                zor\n"+
13937
			"}");
13366
		"            }        \n"+    
13938
	
13367
		"        });\n"+
13939
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13368
		"    }\n"+
13940
	requestor.allowAllRequiredProposals();
13369
		"}\n");
13941
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13370
13942
	
13371
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13372
	String str = this.workingCopies[0].getSource();
13943
	String str = this.workingCopies[0].getSource();
13373
	String completeBehind = "zor";
13944
	String completeBehind = "foo";
13374
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13945
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13375
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13946
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13376
13947
13948
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13949
	int start1 = str.lastIndexOf("foo") + "".length();
13950
	int end1 = start1 + "foo".length();
13951
	int start2 = str.lastIndexOf("public class");
13952
	int end2 = start2 + "".length();
13377
	assertResults(
13953
	assertResults(
13378
			"zork[METHOD_REF]{zork(), Ltest.X;, ()V, zork, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13954
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13955
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13379
			requestor.getResults());
13956
			requestor.getResults());
13380
}
13957
}
13381
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13958
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13382
public void testFavoriteImports001() throws JavaModelException {
13959
public void testFavoriteImports009() throws JavaModelException {
13383
	this.workingCopies = new ICompilationUnit[2];
13960
	this.workingCopies = new ICompilationUnit[2];
13384
	this.workingCopies[0] = getWorkingCopy(
13961
	this.workingCopies[0] = getWorkingCopy(
13385
			"/Completion/src3/test/Test.java",
13962
			"/Completion/src3/test/Test.java",
13386
			"package test;\n" +
13963
			"package test;\n" +
13964
			"import test.p.ZZZ.*;\n" +
13387
			"public class Test {\n" +
13965
			"public class Test {\n" +
13388
			"    public void method() {\n" +
13966
			"    public void method() {\n" +
13389
			"        foo\n" +
13967
			"        foo\n" +
Lines 13394-13427 Link Here
13394
			"/Completion/src3/test/p/ZZZ.java",
13972
			"/Completion/src3/test/p/ZZZ.java",
13395
			"package test.p;\n" +
13973
			"package test.p;\n" +
13396
			"public class ZZZ {\n" +
13974
			"public class ZZZ {\n" +
13397
			"    public static int foo;\n" +
13975
			"    public static int foo(){}\n" +
13398
			"}");
13976
			"}");
13399
	
13977
	
13400
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13978
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13401
	requestor.allowAllRequiredProposals();
13979
	requestor.allowAllRequiredProposals();
13402
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13980
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13403
	
13981
	
13404
	String str = this.workingCopies[0].getSource();
13982
	String str = this.workingCopies[0].getSource();
13405
	String completeBehind = "foo";
13983
	String completeBehind = "foo";
13406
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13984
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13407
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13985
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13408
	
13986
13409
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13987
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13410
	int start1 = str.lastIndexOf("foo") + "".length();
13988
	int start1 = str.lastIndexOf("foo") + "".length();
13411
	int end1 = start1 + "foo".length();
13989
	int end1 = start1 + "foo".length();
13412
	int start2 = str.lastIndexOf("public class");
13990
	int start2 = str.lastIndexOf("public class");
13413
	int end2 = start2 + "".length();
13991
	int end2 = start2 + "".length();
13414
	assertResults(
13992
	assertResults(
13415
			"foo[FIELD_REF]{ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13993
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13416
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13994
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13417
			requestor.getResults());
13995
			requestor.getResults());
13418
}
13996
}
13419
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13997
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13420
public void testFavoriteImports002() throws JavaModelException {
13998
public void testFavoriteImports011() throws JavaModelException {
13421
	this.workingCopies = new ICompilationUnit[2];
13999
	this.workingCopies = new ICompilationUnit[2];
13422
	this.workingCopies[0] = getWorkingCopy(
14000
	this.workingCopies[0] = getWorkingCopy(
13423
			"/Completion/src3/test/Test.java",
14001
			"/Completion/src3/test/Test.java",
13424
			"package test;\n" +
14002
			"package test;\n" +
14003
			"import test.p.ZZZ.foo;\n" +
13425
			"public class Test {\n" +
14004
			"public class Test {\n" +
13426
			"    public void method() {\n" +
14005
			"    public void method() {\n" +
13427
			"        foo\n" +
14006
			"        foo\n" +
Lines 13455-13465 Link Here
13455
			requestor.getResults());
14034
			requestor.getResults());
13456
}
14035
}
13457
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14036
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13458
public void testFavoriteImports003() throws JavaModelException {
14037
public void testFavoriteImports013() throws JavaModelException {
13459
	this.workingCopies = new ICompilationUnit[2];
14038
	this.workingCopies = new ICompilationUnit[2];
13460
	this.workingCopies[0] = getWorkingCopy(
14039
	this.workingCopies[0] = getWorkingCopy(
13461
			"/Completion/src3/test/Test.java",
14040
			"/Completion/src3/test/Test.java",
13462
			"package test;\n" +
14041
			"package test;\n" +
14042
			"import test.p.ZZZ.foo;\n" +
13463
			"public class Test {\n" +
14043
			"public class Test {\n" +
13464
			"    public void method() {\n" +
14044
			"    public void method() {\n" +
13465
			"        foo\n" +
14045
			"        foo\n" +
Lines 13470-13499 Link Here
13470
			"/Completion/src3/test/p/ZZZ.java",
14050
			"/Completion/src3/test/p/ZZZ.java",
13471
			"package test.p;\n" +
14051
			"package test.p;\n" +
13472
			"public class ZZZ {\n" +
14052
			"public class ZZZ {\n" +
13473
			"    public static int foo;\n" +
14053
			"    public static int foo(){}\n" +
13474
			"}");
14054
			"}");
13475
	
14055
	
13476
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14056
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13477
	requestor.allowAllRequiredProposals();
14057
	requestor.allowAllRequiredProposals();
13478
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"});
14058
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13479
	
14059
	
13480
	String str = this.workingCopies[0].getSource();
14060
	String str = this.workingCopies[0].getSource();
13481
	String completeBehind = "foo";
14061
	String completeBehind = "foo";
13482
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14062
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13483
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14063
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13484
14064
14065
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
14066
	int start1 = str.lastIndexOf("foo") + "".length();
14067
	int end1 = start1 + "foo".length();
14068
	int start2 = str.lastIndexOf("public class");
14069
	int end2 = start2 + "".length();
13485
	assertResults(
14070
	assertResults(
13486
			"",
14071
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14072
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13487
			requestor.getResults());
14073
			requestor.getResults());
13488
}
14074
}
13489
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14075
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13490
public void testFavoriteImports004() throws JavaModelException {
14076
public void testFavoriteImports016() throws JavaModelException {
14077
	this.workingCopies = new ICompilationUnit[2];
14078
	this.workingCopies[0] = getWorkingCopy(
14079
			"/Completion/src3/test/Test.java",
14080
			"package test;\n" +
14081
			"public class Test {\n" +
14082
			"    public class foo {\n" +
14083
			"        public void method() {\n" +
14084
			"            foo\n" +
14085
			"        }\n" +
14086
			"    }\n" +
14087
			"}");
14088
	
14089
	this.workingCopies[1] = getWorkingCopy(
14090
			"/Completion/src3/test/p/ZZZ.java",
14091
			"package test.p;\n" +
14092
			"public class ZZZ {\n" +
14093
			"    public static int foo(){}\n" +
14094
			"}");
14095
	
14096
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14097
	requestor.allowAllRequiredProposals();
14098
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
14099
	
14100
	String str = this.workingCopies[0].getSource();
14101
	String completeBehind = "foo";
14102
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14103
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14104
	
14105
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
14106
	int start1 = str.lastIndexOf("foo") + "".length();
14107
	int end1 = start1 + "foo".length();
14108
	int start2 = str.lastIndexOf("public class Test");
14109
	int end2 = start2 + "".length();
14110
	assertResults(
14111
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14112
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+
14113
			"Test.foo[TYPE_REF]{foo, test, Ltest.Test$foo;, null, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
14114
			requestor.getResults());
14115
}
14116
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14117
public void testFavoriteImports017() throws JavaModelException {
13491
	this.workingCopies = new ICompilationUnit[2];
14118
	this.workingCopies = new ICompilationUnit[2];
13492
	this.workingCopies[0] = getWorkingCopy(
14119
	this.workingCopies[0] = getWorkingCopy(
13493
			"/Completion/src3/test/Test.java",
14120
			"/Completion/src3/test/Test.java",
13494
			"package test;\n" +
14121
			"package test;\n" +
13495
			"public class Test {\n" +
14122
			"public class Test {\n" +
13496
			"    public void method() {\n" +
14123
			"    public void foo() {\n" +
13497
			"        foo\n" +
14124
			"        foo\n" +
13498
			"    }\n" +
14125
			"    }\n" +
13499
			"}");
14126
			"}");
Lines 13507-13530 Link Here
13507
	
14134
	
13508
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14135
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13509
	requestor.allowAllRequiredProposals();
14136
	requestor.allowAllRequiredProposals();
13510
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"});
14137
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13511
	
14138
	
13512
	String str = this.workingCopies[0].getSource();
14139
	String str = this.workingCopies[0].getSource();
13513
	String completeBehind = "foo";
14140
	String completeBehind = "foo";
13514
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14141
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13515
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14142
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13516
14143
14144
	int start1 = str.lastIndexOf("foo") + "".length();
14145
	int end1 = start1 + "foo".length();
13517
	assertResults(
14146
	assertResults(
13518
			"",
14147
			"foo[METHOD_REF]{foo(), Ltest.Test;, ()V, foo, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13519
			requestor.getResults());
14148
			requestor.getResults());
13520
}
14149
}
13521
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14150
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13522
public void testFavoriteImports005() throws JavaModelException {
14151
public void testFavoriteImports018() throws JavaModelException {
13523
	this.workingCopies = new ICompilationUnit[2];
14152
	this.workingCopies = new ICompilationUnit[2];
13524
	this.workingCopies[0] = getWorkingCopy(
14153
	this.workingCopies[0] = getWorkingCopy(
13525
			"/Completion/src3/test/Test.java",
14154
			"/Completion/src3/test/Test.java",
13526
			"package test;\n" +
14155
			"package test;\n" +
13527
			"public class Test {\n" +
14156
			"public class Test {\n" +
14157
			"    public int foo;\n" +
13528
			"    public void method() {\n" +
14158
			"    public void method() {\n" +
13529
			"        foo\n" +
14159
			"        foo\n" +
13530
			"    }\n" +
14160
			"    }\n" +
Lines 13534-13545 Link Here
13534
			"/Completion/src3/test/p/ZZZ.java",
14164
			"/Completion/src3/test/p/ZZZ.java",
13535
			"package test.p;\n" +
14165
			"package test.p;\n" +
13536
			"public class ZZZ {\n" +
14166
			"public class ZZZ {\n" +
13537
			"    public static int foo;\n" +
14167
			"    public static int foo(){}\n" +
13538
			"}");
14168
			"}");
13539
	
14169
	
13540
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14170
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13541
	requestor.allowAllRequiredProposals();
14171
	requestor.allowAllRequiredProposals();
13542
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
14172
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13543
	
14173
	
13544
	String str = this.workingCopies[0].getSource();
14174
	String str = this.workingCopies[0].getSource();
13545
	String completeBehind = "foo";
14175
	String completeBehind = "foo";
Lines 13549-13569 Link Here
13549
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
14179
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13550
	int start1 = str.lastIndexOf("foo") + "".length();
14180
	int start1 = str.lastIndexOf("foo") + "".length();
13551
	int end1 = start1 + "foo".length();
14181
	int end1 = start1 + "foo".length();
13552
	int start2 = str.lastIndexOf("public class");
14182
	int start2 = str.lastIndexOf("public class Test");
13553
	int end2 = start2 + "".length();
14183
	int end2 = start2 + "".length();
13554
	assertResults(
14184
	assertResults(
13555
			"foo[FIELD_REF]{ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14185
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13556
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
14186
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+
14187
			"foo[FIELD_REF]{foo, Ltest.Test;, I, foo, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13557
			requestor.getResults());
14188
			requestor.getResults());
13558
}
14189
}
13559
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14190
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13560
public void testFavoriteImports006() throws JavaModelException {
14191
public void testFavoriteImports019() throws JavaModelException {
13561
	this.workingCopies = new ICompilationUnit[2];
14192
	this.workingCopies = new ICompilationUnit[2];
13562
	this.workingCopies[0] = getWorkingCopy(
14193
	this.workingCopies[0] = getWorkingCopy(
13563
			"/Completion/src3/test/Test.java",
14194
			"/Completion/src3/test/Test.java",
13564
			"package test;\n" +
14195
			"package test;\n" +
13565
			"public class Test {\n" +
14196
			"public class Test {\n" +
13566
			"    public void method() {\n" +
14197
			"    public void method() {\n" +
14198
			"        int foo = 0;\n" +
13567
			"        foo\n" +
14199
			"        foo\n" +
13568
			"    }\n" +
14200
			"    }\n" +
13569
			"}");
14201
			"}");
Lines 13577-13583 Link Here
13577
	
14209
	
13578
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14210
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13579
	requestor.allowAllRequiredProposals();
14211
	requestor.allowAllRequiredProposals();
13580
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
14212
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13581
	
14213
	
13582
	String str = this.workingCopies[0].getSource();
14214
	String str = this.workingCopies[0].getSource();
13583
	String completeBehind = "foo";
14215
	String completeBehind = "foo";
Lines 13587-13606 Link Here
13587
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
14219
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13588
	int start1 = str.lastIndexOf("foo") + "".length();
14220
	int start1 = str.lastIndexOf("foo") + "".length();
13589
	int end1 = start1 + "foo".length();
14221
	int end1 = start1 + "foo".length();
13590
	int start2 = str.lastIndexOf("public class");
14222
	int start2 = str.lastIndexOf("public class Test");
13591
	int end2 = start2 + "".length();
14223
	int end2 = start2 + "".length();
13592
	assertResults(
14224
	assertResults(
13593
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14225
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13594
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
14226
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+
14227
			"foo[LOCAL_VARIABLE_REF]{foo, null, I, foo, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13595
			requestor.getResults());
14228
			requestor.getResults());
13596
}
14229
}
13597
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14230
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13598
public void testFavoriteImports007() throws JavaModelException {
14231
public void testFavoriteImports020() throws JavaModelException {
13599
	this.workingCopies = new ICompilationUnit[2];
14232
	this.workingCopies = new ICompilationUnit[2];
13600
	this.workingCopies[0] = getWorkingCopy(
14233
	this.workingCopies[0] = getWorkingCopy(
13601
			"/Completion/src3/test/Test.java",
14234
			"/Completion/src3/test/Test.java",
13602
			"package test;\n" +
14235
			"package test;\n" +
13603
			"import test.p.ZZZ.*;\n" +
13604
			"public class Test {\n" +
14236
			"public class Test {\n" +
13605
			"    public void method() {\n" +
14237
			"    public void method() {\n" +
13606
			"        foo\n" +
14238
			"        foo\n" +
Lines 13612-13617 Link Here
13612
			"package test.p;\n" +
14244
			"package test.p;\n" +
13613
			"public class ZZZ {\n" +
14245
			"public class ZZZ {\n" +
13614
			"    public static int foo(){}\n" +
14246
			"    public static int foo(){}\n" +
14247
			"    public static int foo(int i){}\n" +
13615
			"}");
14248
			"}");
13616
	
14249
	
13617
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14250
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
Lines 13626-13648 Link Here
13626
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
14259
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13627
	int start1 = str.lastIndexOf("foo") + "".length();
14260
	int start1 = str.lastIndexOf("foo") + "".length();
13628
	int end1 = start1 + "foo".length();
14261
	int end1 = start1 + "foo".length();
13629
	int start2 = str.lastIndexOf("public class");
14262
	int start2 = str.lastIndexOf("public class Test");
13630
	int end2 = start2 + "".length();
14263
	int end2 = start2 + "".length();
13631
	assertResults(
14264
	assertResults(
13632
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14265
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14266
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+
14267
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, (I)I, foo, (i), ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13633
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
14268
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13634
			requestor.getResults());
14269
			requestor.getResults());
13635
}
14270
}
13636
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14271
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13637
public void testFavoriteImports009() throws JavaModelException {
14272
public void testFavoriteImports022() throws JavaModelException {
13638
	this.workingCopies = new ICompilationUnit[2];
14273
	this.workingCopies = new ICompilationUnit[2];
13639
	this.workingCopies[0] = getWorkingCopy(
14274
	this.workingCopies[0] = getWorkingCopy(
13640
			"/Completion/src3/test/Test.java",
14275
			"/Completion/src3/test/Test.java",
13641
			"package test;\n" +
14276
			"package test;\n" +
13642
			"import test.p.ZZZ.*;\n" +
13643
			"public class Test {\n" +
14277
			"public class Test {\n" +
13644
			"    public void method() {\n" +
14278
			"    public void method() {\n" +
13645
			"        foo\n" +
14279
			"        foo();\n" +
13646
			"    }\n" +
14280
			"    }\n" +
13647
			"}");
14281
			"}");
13648
	
14282
	
Lines 13655-13684 Link Here
13655
	
14289
	
13656
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14290
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13657
	requestor.allowAllRequiredProposals();
14291
	requestor.allowAllRequiredProposals();
13658
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
14292
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13659
	
14293
	
13660
	String str = this.workingCopies[0].getSource();
14294
	String str = this.workingCopies[0].getSource();
13661
	String completeBehind = "foo";
14295
	String completeBehind = "foo(";
13662
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14296
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13663
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14297
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13664
14298
13665
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13666
	int start1 = str.lastIndexOf("foo") + "".length();
13667
	int end1 = start1 + "foo".length();
13668
	int start2 = str.lastIndexOf("public class");
13669
	int end2 = start2 + "".length();
13670
	assertResults(
14299
	assertResults(
13671
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14300
			"",
13672
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13673
			requestor.getResults());
14301
			requestor.getResults());
13674
}
14302
}
13675
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14303
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13676
public void testFavoriteImports011() throws JavaModelException {
14304
public void testFavoriteImports023() throws JavaModelException {
13677
	this.workingCopies = new ICompilationUnit[2];
14305
	this.workingCopies = new ICompilationUnit[2];
13678
	this.workingCopies[0] = getWorkingCopy(
14306
	this.workingCopies[0] = getWorkingCopy(
13679
			"/Completion/src3/test/Test.java",
14307
			"/Completion/src3/test/Test.java",
13680
			"package test;\n" +
14308
			"package test;\n" +
13681
			"import test.p.ZZZ.foo;\n" +
14309
			"/** */\n" +
13682
			"public class Test {\n" +
14310
			"public class Test {\n" +
13683
			"    public void method() {\n" +
14311
			"    public void method() {\n" +
13684
			"        foo\n" +
14312
			"        foo\n" +
Lines 13689-13695 Link Here
13689
			"/Completion/src3/test/p/ZZZ.java",
14317
			"/Completion/src3/test/p/ZZZ.java",
13690
			"package test.p;\n" +
14318
			"package test.p;\n" +
13691
			"public class ZZZ {\n" +
14319
			"public class ZZZ {\n" +
13692
			"    public static int foo(){}\n" +
14320
			"    public static int foo;\n" +
13693
			"}");
14321
			"}");
13694
	
14322
	
13695
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14323
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
Lines 13704-13723 Link Here
13704
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
14332
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13705
	int start1 = str.lastIndexOf("foo") + "".length();
14333
	int start1 = str.lastIndexOf("foo") + "".length();
13706
	int end1 = start1 + "foo".length();
14334
	int end1 = start1 + "foo".length();
13707
	int start2 = str.lastIndexOf("public class");
14335
	int start2 = str.lastIndexOf("/** */");
13708
	int end2 = start2 + "".length();
14336
	int end2 = start2 + "".length();
13709
	assertResults(
14337
	assertResults(
13710
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14338
			"foo[FIELD_REF]{ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13711
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
14339
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13712
			requestor.getResults());
14340
			requestor.getResults());
13713
}
14341
}
13714
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14342
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13715
public void testFavoriteImports013() throws JavaModelException {
14343
public void testFavoriteImports024() throws JavaModelException {
13716
	this.workingCopies = new ICompilationUnit[2];
14344
	this.workingCopies = new ICompilationUnit[2];
13717
	this.workingCopies[0] = getWorkingCopy(
14345
	this.workingCopies[0] = getWorkingCopy(
13718
			"/Completion/src3/test/Test.java",
14346
			"/Completion/src3/test/Test.java",
13719
			"package test;\n" +
14347
			"package test;\n" +
13720
			"import test.p.ZZZ.foo;\n" +
13721
			"public class Test {\n" +
14348
			"public class Test {\n" +
13722
			"    public void method() {\n" +
14349
			"    public void method() {\n" +
13723
			"        foo\n" +
14350
			"        foo\n" +
Lines 13728-13766 Link Here
13728
			"/Completion/src3/test/p/ZZZ.java",
14355
			"/Completion/src3/test/p/ZZZ.java",
13729
			"package test.p;\n" +
14356
			"package test.p;\n" +
13730
			"public class ZZZ {\n" +
14357
			"public class ZZZ {\n" +
13731
			"    public static int foo(){}\n" +
14358
			"    public int foo;\n" +
13732
			"}");
14359
			"}");
13733
	
14360
	
13734
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14361
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13735
	requestor.allowAllRequiredProposals();
14362
	requestor.allowAllRequiredProposals();
13736
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
14363
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13737
	
14364
	
13738
	String str = this.workingCopies[0].getSource();
14365
	String str = this.workingCopies[0].getSource();
13739
	String completeBehind = "foo";
14366
	String completeBehind = "foo";
13740
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14367
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13741
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14368
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13742
14369
13743
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13744
	int start1 = str.lastIndexOf("foo") + "".length();
13745
	int end1 = start1 + "foo".length();
13746
	int start2 = str.lastIndexOf("public class");
13747
	int end2 = start2 + "".length();
13748
	assertResults(
14370
	assertResults(
13749
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14371
			"",
13750
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13751
			requestor.getResults());
14372
			requestor.getResults());
13752
}
14373
}
13753
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14374
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13754
public void testFavoriteImports016() throws JavaModelException {
14375
public void testFavoriteImports025() throws JavaModelException {
13755
	this.workingCopies = new ICompilationUnit[2];
14376
	this.workingCopies = new ICompilationUnit[2];
13756
	this.workingCopies[0] = getWorkingCopy(
14377
	this.workingCopies[0] = getWorkingCopy(
13757
			"/Completion/src3/test/Test.java",
14378
			"/Completion/src3/test/Test.java",
13758
			"package test;\n" +
14379
			"package test;\n" +
13759
			"public class Test {\n" +
14380
			"public class Test {\n" +
13760
			"    public class foo {\n" +
14381
			"    public void method() {\n" +
13761
			"        public void method() {\n" +
14382
			"        foo\n" +
13762
			"            foo\n" +
13763
			"        }\n" +
13764
			"    }\n" +
14383
			"    }\n" +
13765
			"}");
14384
			"}");
13766
	
14385
	
Lines 13768-13804 Link Here
13768
			"/Completion/src3/test/p/ZZZ.java",
14387
			"/Completion/src3/test/p/ZZZ.java",
13769
			"package test.p;\n" +
14388
			"package test.p;\n" +
13770
			"public class ZZZ {\n" +
14389
			"public class ZZZ {\n" +
13771
			"    public static int foo(){}\n" +
14390
			"    public int foo;\n" +
13772
			"}");
14391
			"}");
13773
	
14392
	
13774
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14393
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13775
	requestor.allowAllRequiredProposals();
14394
	requestor.allowAllRequiredProposals();
13776
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
14395
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13777
	
14396
	
13778
	String str = this.workingCopies[0].getSource();
14397
	String str = this.workingCopies[0].getSource();
13779
	String completeBehind = "foo";
14398
	String completeBehind = "foo";
13780
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14399
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13781
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14400
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13782
	
14401
13783
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13784
	int start1 = str.lastIndexOf("foo") + "".length();
13785
	int end1 = start1 + "foo".length();
13786
	int start2 = str.lastIndexOf("public class Test");
13787
	int end2 = start2 + "".length();
13788
	assertResults(
14402
	assertResults(
13789
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14403
			"",
13790
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+
13791
			"Test.foo[TYPE_REF]{foo, test, Ltest.Test$foo;, null, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13792
			requestor.getResults());
14404
			requestor.getResults());
13793
}
14405
}
13794
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14406
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13795
public void testFavoriteImports017() throws JavaModelException {
14407
public void testFavoriteImports026() throws JavaModelException {
13796
	this.workingCopies = new ICompilationUnit[2];
14408
	this.workingCopies = new ICompilationUnit[2];
13797
	this.workingCopies[0] = getWorkingCopy(
14409
	this.workingCopies[0] = getWorkingCopy(
13798
			"/Completion/src3/test/Test.java",
14410
			"/Completion/src3/test/Test.java",
13799
			"package test;\n" +
14411
			"package test;\n" +
13800
			"public class Test {\n" +
14412
			"public class Test {\n" +
13801
			"    public void foo() {\n" +
14413
			"    public void method() {\n" +
13802
			"        foo\n" +
14414
			"        foo\n" +
13803
			"    }\n" +
14415
			"    }\n" +
13804
			"}");
14416
			"}");
Lines 13807-13813 Link Here
13807
			"/Completion/src3/test/p/ZZZ.java",
14419
			"/Completion/src3/test/p/ZZZ.java",
13808
			"package test.p;\n" +
14420
			"package test.p;\n" +
13809
			"public class ZZZ {\n" +
14421
			"public class ZZZ {\n" +
13810
			"    public static int foo(){}\n" +
14422
			"    public int foo(){return 0;};\n" +
13811
			"}");
14423
			"}");
13812
	
14424
	
13813
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14425
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
Lines 13819-13838 Link Here
13819
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14431
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13820
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14432
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13821
14433
13822
	int start1 = str.lastIndexOf("foo") + "".length();
13823
	int end1 = start1 + "foo".length();
13824
	assertResults(
14434
	assertResults(
13825
			"foo[METHOD_REF]{foo(), Ltest.Test;, ()V, foo, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
14435
			"",
13826
			requestor.getResults());
14436
			requestor.getResults());
13827
}
14437
}
13828
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14438
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13829
public void testFavoriteImports018() throws JavaModelException {
14439
public void testFavoriteImports027() throws JavaModelException {
13830
	this.workingCopies = new ICompilationUnit[2];
14440
	this.workingCopies = new ICompilationUnit[2];
13831
	this.workingCopies[0] = getWorkingCopy(
14441
	this.workingCopies[0] = getWorkingCopy(
13832
			"/Completion/src3/test/Test.java",
14442
			"/Completion/src3/test/Test.java",
13833
			"package test;\n" +
14443
			"package test;\n" +
13834
			"public class Test {\n" +
14444
			"public class Test {\n" +
13835
			"    public int foo;\n" +
13836
			"    public void method() {\n" +
14445
			"    public void method() {\n" +
13837
			"        foo\n" +
14446
			"        foo\n" +
13838
			"    }\n" +
14447
			"    }\n" +
Lines 13842-13879 Link Here
13842
			"/Completion/src3/test/p/ZZZ.java",
14451
			"/Completion/src3/test/p/ZZZ.java",
13843
			"package test.p;\n" +
14452
			"package test.p;\n" +
13844
			"public class ZZZ {\n" +
14453
			"public class ZZZ {\n" +
13845
			"    public static int foo(){}\n" +
14454
			"    public int foo(){return 0;};\n" +
13846
			"}");
14455
			"}");
13847
	
14456
	
13848
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14457
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13849
	requestor.allowAllRequiredProposals();
14458
	requestor.allowAllRequiredProposals();
13850
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
14459
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13851
	
14460
	
13852
	String str = this.workingCopies[0].getSource();
14461
	String str = this.workingCopies[0].getSource();
13853
	String completeBehind = "foo";
14462
	String completeBehind = "foo";
13854
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14463
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13855
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14464
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13856
14465
13857
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13858
	int start1 = str.lastIndexOf("foo") + "".length();
13859
	int end1 = start1 + "foo".length();
13860
	int start2 = str.lastIndexOf("public class Test");
13861
	int end2 = start2 + "".length();
13862
	assertResults(
14466
	assertResults(
13863
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14467
			"",
13864
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+
13865
			"foo[FIELD_REF]{foo, Ltest.Test;, I, foo, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13866
			requestor.getResults());
14468
			requestor.getResults());
13867
}
14469
}
13868
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14470
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13869
public void testFavoriteImports019() throws JavaModelException {
14471
public void testFavoriteImports028() throws JavaModelException {
13870
	this.workingCopies = new ICompilationUnit[2];
14472
	this.workingCopies = new ICompilationUnit[2];
13871
	this.workingCopies[0] = getWorkingCopy(
14473
	this.workingCopies[0] = getWorkingCopy(
13872
			"/Completion/src3/test/Test.java",
14474
			"/Completion/src3/test/Test.java",
13873
			"package test;\n" +
14475
			"package test;\n" +
14476
			"import test.p.ZZZ;\n" +
13874
			"public class Test {\n" +
14477
			"public class Test {\n" +
13875
			"    public void method() {\n" +
14478
			"    public void method() {\n" +
13876
			"        int foo = 0;\n" +
13877
			"        foo\n" +
14479
			"        foo\n" +
13878
			"    }\n" +
14480
			"    }\n" +
13879
			"}");
14481
			"}");
Lines 13882-14279 Link Here
13882
			"/Completion/src3/test/p/ZZZ.java",
14484
			"/Completion/src3/test/p/ZZZ.java",
13883
			"package test.p;\n" +
14485
			"package test.p;\n" +
13884
			"public class ZZZ {\n" +
14486
			"public class ZZZ {\n" +
13885
			"    public static int foo(){}\n" +
14487
			"    public static int foo(){return 0;};\n" +
13886
			"}");
14488
			"}");
13887
	
14489
	
13888
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14490
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13889
	requestor.allowAllRequiredProposals();
14491
	requestor.allowAllRequiredProposals();
13890
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
14492
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13891
	
14493
	
13892
	String str = this.workingCopies[0].getSource();
14494
	String str = this.workingCopies[0].getSource();
13893
	String completeBehind = "foo";
14495
	String completeBehind = "foo";
13894
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14496
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13895
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14497
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13896
14498
13897
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13898
	int start1 = str.lastIndexOf("foo") + "".length();
14499
	int start1 = str.lastIndexOf("foo") + "".length();
13899
	int end1 = start1 + "foo".length();
14500
	int end1 = start1 + "foo".length();
13900
	int start2 = str.lastIndexOf("public class Test");
13901
	int end2 = start2 + "".length();
13902
	assertResults(
14501
	assertResults(
13903
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14502
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}",
13904
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+
13905
			"foo[LOCAL_VARIABLE_REF]{foo, null, I, foo, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13906
			requestor.getResults());
14503
			requestor.getResults());
13907
}
14504
}
13908
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14505
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13909
public void testFavoriteImports020() throws JavaModelException {
14506
public void testFavoriteImports030() throws JavaModelException {
13910
	this.workingCopies = new ICompilationUnit[2];
14507
	this.oldOptions = JavaCore.getOptions();
13911
	this.workingCopies[0] = getWorkingCopy(
13912
			"/Completion/src3/test/Test.java",
13913
			"package test;\n" +
13914
			"public class Test {\n" +
13915
			"    public void method() {\n" +
13916
			"        foo\n" +
13917
			"    }\n" +
13918
			"}");
13919
	
14508
	
13920
	this.workingCopies[1] = getWorkingCopy(
14509
	try {
13921
			"/Completion/src3/test/p/ZZZ.java",
14510
		Hashtable options = new Hashtable(this.oldOptions);
13922
			"package test.p;\n" +
14511
		options.put(JavaCore.CODEASSIST_SUGGEST_STATIC_IMPORTS, JavaCore.DISABLED);
13923
			"public class ZZZ {\n" +
14512
		JavaCore.setOptions(options);
13924
			"    public static int foo(){}\n" +
14513
		
13925
			"    public static int foo(int i){}\n" +
14514
		this.workingCopies = new ICompilationUnit[2];
13926
			"}");
14515
		this.workingCopies[0] = getWorkingCopy(
14516
				"/Completion/src3/test/Test.java",
14517
				"package test;\n" +
14518
				"public class Test {\n" +
14519
				"    public void method() {\n" +
14520
				"        foo\n" +
14521
				"    }\n" +
14522
				"}");
14523
		
14524
		this.workingCopies[1] = getWorkingCopy(
14525
				"/Completion/src3/test/p/ZZZ.java",
14526
				"package test.p;\n" +
14527
				"public class ZZZ {\n" +
14528
				"    public static int foo(){}\n" +
14529
				"}");
14530
		
14531
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14532
		requestor.allowAllRequiredProposals();
14533
		requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
14534
		
14535
		String str = this.workingCopies[0].getSource();
14536
		String completeBehind = "foo";
14537
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14538
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14539
		
14540
		int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
14541
		int start1 = str.lastIndexOf("foo") + "".length();
14542
		int end1 = start1 + "foo".length();
14543
		int start2 = str.lastIndexOf("public class");
14544
		int end2 = start2 + "".length();
14545
		assertResults(
14546
				"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14547
				"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
14548
				requestor.getResults());
14549
	} finally {
14550
		JavaCore.setOptions(oldOptions);
14551
	}
14552
}
14553
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14554
public void testFavoriteImports031() throws JavaModelException {
14555
	this.oldOptions = JavaCore.getOptions();
13927
	
14556
	
13928
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14557
	try {
13929
	requestor.allowAllRequiredProposals();
14558
		Hashtable options = new Hashtable(this.oldOptions);
13930
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
14559
		options.put(JavaCore.CODEASSIST_SUGGEST_STATIC_IMPORTS, JavaCore.ENABLED);
14560
		JavaCore.setOptions(options);
14561
		
14562
		this.workingCopies = new ICompilationUnit[2];
14563
		this.workingCopies[0] = getWorkingCopy(
14564
				"/Completion/src3/test/Test.java",
14565
				"package test;\n" +
14566
				"public class Test {\n" +
14567
				"    public void method() {\n" +
14568
				"        foo\n" +
14569
				"    }\n" +
14570
				"}");
14571
		
14572
		this.workingCopies[1] = getWorkingCopy(
14573
				"/Completion/src3/test/p/ZZZ.java",
14574
				"package test.p;\n" +
14575
				"public class ZZZ {\n" +
14576
				"    public static int foo(){}\n" +
14577
				"}");
14578
		
14579
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14580
		requestor.allowAllRequiredProposals();
14581
		requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
14582
		
14583
		String str = this.workingCopies[0].getSource();
14584
		String completeBehind = "foo";
14585
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14586
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14587
		
14588
		int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
14589
		int start1 = str.lastIndexOf("foo") + "".length();
14590
		int end1 = start1 + "foo".length();
14591
		int start2 = str.lastIndexOf("public class");
14592
		int end2 = start2 + "".length();
14593
		assertResults(
14594
				"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14595
				"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
14596
				requestor.getResults());
14597
	} finally {
14598
		JavaCore.setOptions(oldOptions);
14599
	}
14600
}
14601
public void testInconsistentHierarchy1() throws CoreException, IOException {
14602
	this.workingCopies = new ICompilationUnit[1];
14603
	this.workingCopies[0] = getWorkingCopy(
14604
		"/Completion/src/p/Test.java",
14605
		"package p;"+
14606
		"public class Test extends Unknown {\n" + 
14607
		"  void foo() {\n" + 
14608
		"    this.has\n" + 
14609
		"  }\n" + 
14610
		"}\n");
13931
	
14611
	
14612
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13932
	String str = this.workingCopies[0].getSource();
14613
	String str = this.workingCopies[0].getSource();
13933
	String completeBehind = "foo";
14614
	String completeBehind = "this.has";
13934
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14615
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13935
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14616
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13936
14617
	
13937
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13938
	int start1 = str.lastIndexOf("foo") + "".length();
13939
	int end1 = start1 + "foo".length();
13940
	int start2 = str.lastIndexOf("public class Test");
13941
	int end2 = start2 + "".length();
13942
	assertResults(
14618
	assertResults(
13943
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14619
		"hashCode[METHOD_REF]{hashCode(), Ljava.lang.Object;, ()I, hashCode, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}",
13944
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+
14620
		requestor.getResults());
13945
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, (I)I, foo, (i), ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13946
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13947
			requestor.getResults());
13948
}
14621
}
13949
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14622
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=22072
13950
public void testFavoriteImports022() throws JavaModelException {
14623
public void testLabel1() throws JavaModelException {
13951
	this.workingCopies = new ICompilationUnit[2];
14624
	this.workingCopies = new ICompilationUnit[1];
13952
	this.workingCopies[0] = getWorkingCopy(
14625
	this.workingCopies[0] = getWorkingCopy(
13953
			"/Completion/src3/test/Test.java",
14626
		"/Completion/src/label/Test.java",
13954
			"package test;\n" +
14627
		"package label;"+
13955
			"public class Test {\n" +
14628
		"public class Test {\n"+
13956
			"    public void method() {\n" +
14629
		"  void foo() {\n"+
13957
			"        foo();\n" +
14630
		"    label1 : for(;;) foo();\n"+
13958
			"    }\n" +
14631
		"    label2 : for(;;)\n"+
13959
			"}");
14632
		"      label3 : for(;;) {\n"+
13960
	
14633
		"        label4 : for(;;) {\n"+
13961
	this.workingCopies[1] = getWorkingCopy(
14634
		"          break lab\n"+
13962
			"/Completion/src3/test/p/ZZZ.java",
14635
		"        }\n"+
13963
			"package test.p;\n" +
14636
		"      }\n"+
13964
			"public class ZZZ {\n" +
14637
		"  }\n"+
13965
			"    public static int foo(){}\n" +
14638
		"}");
13966
			"}");
14639
13967
	
14640
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13968
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13969
	requestor.allowAllRequiredProposals();
13970
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13971
	
13972
	String str = this.workingCopies[0].getSource();
14641
	String str = this.workingCopies[0].getSource();
13973
	String completeBehind = "foo(";
14642
	String completeBehind = "lab";
13974
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14643
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13975
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14644
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13976
14645
13977
	assertResults(
14646
	assertResults(
13978
			"",
14647
			"label2[LABEL_REF]{label2, null, null, label2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
14648
			"label3[LABEL_REF]{label3, null, null, label3, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
14649
			"label4[LABEL_REF]{label4, null, null, label4, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
13979
			requestor.getResults());
14650
			requestor.getResults());
13980
}
14651
}
13981
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14652
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=22072
13982
public void testFavoriteImports023() throws JavaModelException {
14653
public void testLabel2() throws JavaModelException {
13983
	this.workingCopies = new ICompilationUnit[2];
14654
	this.workingCopies = new ICompilationUnit[1];
13984
	this.workingCopies[0] = getWorkingCopy(
14655
	this.workingCopies[0] = getWorkingCopy(
13985
			"/Completion/src3/test/Test.java",
14656
		"/Completion/src/label/Test.java",
13986
			"package test;\n" +
14657
		"package label;"+
13987
			"/** */\n" +
14658
		"public class Test {\n"+
13988
			"public class Test {\n" +
14659
		"  void foo() {\n"+
13989
			"    public void method() {\n" +
14660
		"    #\n"+
13990
			"        foo\n" +
14661
		"    label1 : for(;;) foo();\n"+
13991
			"    }\n" +
14662
		"    label2 : for(;;)\n"+
13992
			"}");
14663
		"      label3 : for(;;) {\n"+
13993
	
14664
		"        label4 : for(;;) {\n"+
13994
	this.workingCopies[1] = getWorkingCopy(
14665
		"          break lab\n"+
13995
			"/Completion/src3/test/p/ZZZ.java",
14666
		"        }\n"+
13996
			"package test.p;\n" +
14667
		"      }\n"+
13997
			"public class ZZZ {\n" +
14668
		"  }\n"+
13998
			"    public static int foo;\n" +
14669
		"}");
13999
			"}");
14670
14000
	
14671
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
14001
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14002
	requestor.allowAllRequiredProposals();
14003
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
14004
	
14005
	String str = this.workingCopies[0].getSource();
14672
	String str = this.workingCopies[0].getSource();
14006
	String completeBehind = "foo";
14673
	String completeBehind = "lab";
14007
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14674
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14008
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14675
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14009
14676
14010
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
14011
	int start1 = str.lastIndexOf("foo") + "".length();
14012
	int end1 = start1 + "foo".length();
14013
	int start2 = str.lastIndexOf("/** */");
14014
	int end2 = start2 + "".length();
14015
	assertResults(
14677
	assertResults(
14016
			"foo[FIELD_REF]{ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14678
			"label2[LABEL_REF]{label2, null, null, label2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
14017
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
14679
			"label3[LABEL_REF]{label3, null, null, label3, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
14680
			"label4[LABEL_REF]{label4, null, null, label4, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
14018
			requestor.getResults());
14681
			requestor.getResults());
14019
}
14682
}
14020
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14683
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=22072
14021
public void testFavoriteImports024() throws JavaModelException {
14684
public void testLabel3() throws JavaModelException {
14022
	this.workingCopies = new ICompilationUnit[2];
14685
	this.workingCopies = new ICompilationUnit[1];
14023
	this.workingCopies[0] = getWorkingCopy(
14686
	this.workingCopies[0] = getWorkingCopy(
14024
			"/Completion/src3/test/Test.java",
14687
		"/Completion/src/label/Test.java",
14025
			"package test;\n" +
14688
		"package label;"+
14026
			"public class Test {\n" +
14689
		"public class Test {\n"+
14027
			"    public void method() {\n" +
14690
		"  void foo() {\n"+
14028
			"        foo\n" +
14691
		"    label1 : for(;;) foo();\n"+
14029
			"    }\n" +
14692
		"    label2 : for(;;)\n"+
14030
			"}");
14693
		"      label3 : for(;;) {\n"+
14031
	
14694
		"        label4 : for(;;) {\n"+
14032
	this.workingCopies[1] = getWorkingCopy(
14695
		"          break lab\n"+
14033
			"/Completion/src3/test/p/ZZZ.java",
14696
		"  }\n"+
14034
			"package test.p;\n" +
14697
		"}");
14035
			"public class ZZZ {\n" +
14698
14036
			"    public int foo;\n" +
14699
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
14037
			"}");
14038
	
14039
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14040
	requestor.allowAllRequiredProposals();
14041
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
14042
	
14043
	String str = this.workingCopies[0].getSource();
14700
	String str = this.workingCopies[0].getSource();
14044
	String completeBehind = "foo";
14701
	String completeBehind = "lab";
14045
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14702
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14046
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14703
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14047
14704
14048
	assertResults(
14705
	assertResults(
14049
			"",
14706
			"label2[LABEL_REF]{label2, null, null, label2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
14707
			"label3[LABEL_REF]{label3, null, null, label3, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
14708
			"label4[LABEL_REF]{label4, null, null, label4, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
14050
			requestor.getResults());
14709
			requestor.getResults());
14051
}
14710
}
14052
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14711
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=22072
14053
public void testFavoriteImports025() throws JavaModelException {
14712
public void testLabel4() throws JavaModelException {
14054
	this.workingCopies = new ICompilationUnit[2];
14713
	this.workingCopies = new ICompilationUnit[1];
14055
	this.workingCopies[0] = getWorkingCopy(
14714
	this.workingCopies[0] = getWorkingCopy(
14056
			"/Completion/src3/test/Test.java",
14715
		"/Completion/src/label/Test.java",
14057
			"package test;\n" +
14716
		"package label;"+
14058
			"public class Test {\n" +
14717
		"public class Test {\n"+
14059
			"    public void method() {\n" +
14718
		"  void foo() {\n"+
14060
			"        foo\n" +
14719
		"    #\n"+
14061
			"    }\n" +
14720
		"    label1 : for(;;) foo();\n"+
14062
			"}");
14721
		"    label2 : for(;;)\n"+
14063
	
14722
		"      label3 : for(;;) {\n"+
14064
	this.workingCopies[1] = getWorkingCopy(
14723
		"        label4 : for(;;) {\n"+
14065
			"/Completion/src3/test/p/ZZZ.java",
14724
		"          break lab\n"+
14066
			"package test.p;\n" +
14725
		"  }\n"+
14067
			"public class ZZZ {\n" +
14726
		"}");
14068
			"    public int foo;\n" +
14727
14069
			"}");
14728
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
14070
	
14071
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14072
	requestor.allowAllRequiredProposals();
14073
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
14074
	
14075
	String str = this.workingCopies[0].getSource();
14729
	String str = this.workingCopies[0].getSource();
14076
	String completeBehind = "foo";
14730
	String completeBehind = "lab";
14077
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14731
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14078
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14732
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14079
14733
14080
	assertResults(
14734
	assertResults(
14081
			"",
14735
			"label2[LABEL_REF]{label2, null, null, label2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
14736
			"label3[LABEL_REF]{label3, null, null, label3, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
14737
			"label4[LABEL_REF]{label4, null, null, label4, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
14082
			requestor.getResults());
14738
			requestor.getResults());
14083
}
14739
}
14084
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14740
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=22072
14085
public void testFavoriteImports026() throws JavaModelException {
14741
public void testLabel5() throws JavaModelException {
14086
	this.workingCopies = new ICompilationUnit[2];
14742
	this.workingCopies = new ICompilationUnit[1];
14087
	this.workingCopies[0] = getWorkingCopy(
14743
	this.workingCopies[0] = getWorkingCopy(
14088
			"/Completion/src3/test/Test.java",
14744
		"/Completion/src/label/Test.java",
14089
			"package test;\n" +
14745
		"package label;"+
14090
			"public class Test {\n" +
14746
		"public class Test {\n" + 
14091
			"    public void method() {\n" +
14747
		"  void foo() {\n" + 
14092
			"        foo\n" +
14748
		"    #\n" + 
14093
			"    }\n" +
14749
 		"    label1 : for(;;) {\n" + 
14094
			"}");
14750
 		"      class X {\n" + 
14095
	
14751
 		"        void foo() {\n" + 
14096
	this.workingCopies[1] = getWorkingCopy(
14752
 		"          label2 : for(;;) foo();\n" + 
14097
			"/Completion/src3/test/p/ZZZ.java",
14753
 		"        }\n" + 
14098
			"package test.p;\n" +
14754
 		"      }\n" + 
14099
			"public class ZZZ {\n" +
14755
 		"      continue lab\n" + 
14100
			"    public int foo(){return 0;};\n" +
14756
 		"    }\n" + 
14101
			"}");
14757
		"  }\n" + 
14102
	
14758
		"}\n");
14103
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14104
	requestor.allowAllRequiredProposals();
14105
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
14106
	
14107
	String str = this.workingCopies[0].getSource();
14108
	String completeBehind = "foo";
14109
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14110
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14111
14759
14112
	assertResults(
14760
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
14113
			"",
14114
			requestor.getResults());
14115
}
14116
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14117
public void testFavoriteImports027() throws JavaModelException {
14118
	this.workingCopies = new ICompilationUnit[2];
14119
	this.workingCopies[0] = getWorkingCopy(
14120
			"/Completion/src3/test/Test.java",
14121
			"package test;\n" +
14122
			"public class Test {\n" +
14123
			"    public void method() {\n" +
14124
			"        foo\n" +
14125
			"    }\n" +
14126
			"}");
14127
	
14128
	this.workingCopies[1] = getWorkingCopy(
14129
			"/Completion/src3/test/p/ZZZ.java",
14130
			"package test.p;\n" +
14131
			"public class ZZZ {\n" +
14132
			"    public int foo(){return 0;};\n" +
14133
			"}");
14134
	
14135
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14136
	requestor.allowAllRequiredProposals();
14137
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
14138
	
14139
	String str = this.workingCopies[0].getSource();
14761
	String str = this.workingCopies[0].getSource();
14140
	String completeBehind = "foo";
14762
	String completeBehind = "lab";
14141
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14763
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14142
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14764
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14143
14765
14144
	assertResults(
14766
	assertResults(
14145
			"",
14767
			"label1[LABEL_REF]{label1, null, null, label1, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
14146
			requestor.getResults());
14768
			requestor.getResults());
14147
}
14769
}
14148
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14770
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=22072
14149
public void testFavoriteImports028() throws JavaModelException {
14771
public void testLabel6() throws JavaModelException {
14150
	this.workingCopies = new ICompilationUnit[2];
14772
	this.workingCopies = new ICompilationUnit[1];
14151
	this.workingCopies[0] = getWorkingCopy(
14773
	this.workingCopies[0] = getWorkingCopy(
14152
			"/Completion/src3/test/Test.java",
14774
		"/Completion/src/label/Test.java",
14153
			"package test;\n" +
14775
		"package label;"+
14154
			"import test.p.ZZZ;\n" +
14776
		"public class Test {\n" + 
14155
			"public class Test {\n" +
14777
		"  void foo() {\n" + 
14156
			"    public void method() {\n" +
14778
		"    #\n" + 
14157
			"        foo\n" +
14779
 		"    label1 : for(;;) {\n" + 
14158
			"    }\n" +
14780
 		"      class X {\n" + 
14159
			"}");
14781
 		"        void foo() {\n" + 
14160
	
14782
 		"          label2 : for(;;) {\n" + 
14161
	this.workingCopies[1] = getWorkingCopy(
14783
 		"            continue lab\n" + 
14162
			"/Completion/src3/test/p/ZZZ.java",
14784
 		"          }\n" + 
14163
			"package test.p;\n" +
14785
 		"        }\n" + 
14164
			"public class ZZZ {\n" +
14786
 		"      }\n" + 
14165
			"    public static int foo(){return 0;};\n" +
14787
 		"    }\n" + 
14166
			"}");
14788
		"  }\n" + 
14167
	
14789
		"}\n");
14168
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14790
14169
	requestor.allowAllRequiredProposals();
14791
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
14170
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
14171
	
14172
	String str = this.workingCopies[0].getSource();
14792
	String str = this.workingCopies[0].getSource();
14173
	String completeBehind = "foo";
14793
	String completeBehind = "lab";
14174
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14794
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14175
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14795
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14176
14796
14177
	int start1 = str.lastIndexOf("foo") + "".length();
14178
	int end1 = start1 + "foo".length();
14179
	assertResults(
14797
	assertResults(
14180
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}",
14798
			"label2[LABEL_REF]{label2, null, null, label2, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
14181
			requestor.getResults());
14799
			requestor.getResults());
14182
}
14800
}
14183
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14801
public void testParameterNames1() throws CoreException, IOException {
14184
public void testFavoriteImports030() throws JavaModelException {
14802
	Hashtable options = JavaCore.getOptions();
14185
	this.oldOptions = JavaCore.getOptions();
14803
	Object timeout = options.get(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC);
14804
	options.put(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC,"2000"); //$NON-NLS-1$
14186
	
14805
	
14806
	JavaCore.setOptions(options);
14807
14187
	try {
14808
	try {
14188
		Hashtable options = new Hashtable(this.oldOptions);
14809
		this.workingCopies = new ICompilationUnit[1];
14189
		options.put(JavaCore.CODEASSIST_SUGGEST_STATIC_IMPORTS, JavaCore.DISABLED);
14190
		JavaCore.setOptions(options);
14191
		
14192
		this.workingCopies = new ICompilationUnit[2];
14193
		this.workingCopies[0] = getWorkingCopy(
14810
		this.workingCopies[0] = getWorkingCopy(
14194
				"/Completion/src3/test/Test.java",
14811
			"/Completion/src/p/Test.java",
14195
				"package test;\n" +
14812
			"package p;"+
14196
				"public class Test {\n" +
14813
			"public class Test {\n" + 
14197
				"    public void method() {\n" +
14814
			"  void foo(doctest.X x) {\n" + 
14198
				"        foo\n" +
14815
			"    x.fo\n" + 
14199
				"    }\n" +
14816
			"  }\n" + 
14200
				"}");
14817
			"}\n");
14201
		
14202
		this.workingCopies[1] = getWorkingCopy(
14203
				"/Completion/src3/test/p/ZZZ.java",
14204
				"package test.p;\n" +
14205
				"public class ZZZ {\n" +
14206
				"    public static int foo(){}\n" +
14207
				"}");
14208
		
14209
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14210
		requestor.allowAllRequiredProposals();
14211
		requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
14212
		
14818
		
14213
		String str = this.workingCopies[0].getSource();
14819
		addLibrary(
14214
		String completeBehind = "foo";
14820
				"Completion", 
14215
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14821
				"tmpDoc.jar",
14216
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14822
				null,
14823
				"tmpDocDoc.zip",
14824
				false);
14217
		
14825
		
14218
		int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
14826
		CompletionTestsRequestor2 requestor;
14219
		int start1 = str.lastIndexOf("foo") + "".length();
14827
		try {
14220
		int end1 = start1 + "foo".length();
14828
			requestor = new CompletionTestsRequestor2(true);
14221
		int start2 = str.lastIndexOf("public class");
14829
			String str = this.workingCopies[0].getSource();
14222
		int end2 = start2 + "".length();
14830
			String completeBehind = "x.fo";
14223
		assertResults(
14831
			int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14224
				"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14832
			this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14225
				"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
14833
			
14834
			assertResults(
14835
				"foo[METHOD_REF]{foo(), Ldoctest.X;, (Ljava.lang.Object;)V, foo, (param), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}",
14226
				requestor.getResults());
14836
				requestor.getResults());
14837
		} finally {
14838
			removeLibrary("Completion", "tmpDoc.jar");
14839
		}
14227
	} finally {
14840
	} finally {
14228
		JavaCore.setOptions(oldOptions);
14841
		options.put(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, timeout);
14842
		JavaCore.setOptions(options);
14229
	}
14843
	}
14230
}
14844
}
14231
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14845
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=22072
14232
public void testFavoriteImports031() throws JavaModelException {
14846
public void testStaticMembers1() throws JavaModelException {
14233
	this.oldOptions = JavaCore.getOptions();
14847
	this.workingCopies = new ICompilationUnit[3];
14848
	this.workingCopies[0] = getWorkingCopy(
14849
		"/Completion/src/test/Test.java",
14850
		"package test;"+
14851
		"public class Test {\n" + 
14852
		"  void foo() {\n" + 
14853
 		"    StaticMembers.\n" + 
14854
		"  }\n" + 
14855
		"}\n");
14234
	
14856
	
14235
	try {
14857
	this.workingCopies[1] = getWorkingCopy(
14236
		Hashtable options = new Hashtable(this.oldOptions);
14858
		"/Completion/src/test/StaticMembers.java",
14237
		options.put(JavaCore.CODEASSIST_SUGGEST_STATIC_IMPORTS, JavaCore.ENABLED);
14859
		"package test;"+
14238
		JavaCore.setOptions(options);
14860
		"public class StaticMembers extends SuperStaticMembers {\n" + 
14239
		
14861
		"  public static int staticField;\n" + 
14240
		this.workingCopies = new ICompilationUnit[2];
14862
 		"  public static int staticMethod() {}\n" + 
14241
		this.workingCopies[0] = getWorkingCopy(
14863
		"  public class Clazz {}\n" + 
14242
				"/Completion/src3/test/Test.java",
14864
		"  public static class StaticClazz {}\n" + 
14243
				"package test;\n" +
14865
		"}\n");
14244
				"public class Test {\n" +
14866
	
14245
				"    public void method() {\n" +
14867
	this.workingCopies[2] = getWorkingCopy(
14246
				"        foo\n" +
14868
			"/Completion/src/test/SuperStaticMembers.java",
14247
				"    }\n" +
14869
			"package test;"+
14248
				"}");
14870
			"public class SuperStaticMembers {\n" + 
14249
		
14871
			"  public static int superStaticField;\n" + 
14250
		this.workingCopies[1] = getWorkingCopy(
14872
	 		"  public static int supeStaticMethod() {}\n" + 
14251
				"/Completion/src3/test/p/ZZZ.java",
14873
			"  public class SuperClazz {}\n" + 
14252
				"package test.p;\n" +
14874
			"  public static class SuperStaticClazz {}\n" + 
14253
				"public class ZZZ {\n" +
14875
			"}\n");
14254
				"    public static int foo(){}\n" +
14876
14255
				"}");
14877
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
14256
		
14878
	String str = this.workingCopies[0].getSource();
14257
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14879
	String completeBehind = "StaticMembers.";
14258
		requestor.allowAllRequiredProposals();
14880
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14259
		requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
14881
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14260
		
14882
14261
		String str = this.workingCopies[0].getSource();
14883
	assertResults(
14262
		String completeBehind = "foo";
14884
			"supeStaticMethod[METHOD_REF]{supeStaticMethod(), Ltest.SuperStaticMembers;, ()I, supeStaticMethod, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
14263
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14885
			"superStaticField[FIELD_REF]{superStaticField, Ltest.SuperStaticMembers;, I, superStaticField, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
14264
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14886
			"StaticMembers.Clazz[TYPE_REF]{Clazz, test, Ltest.StaticMembers$Clazz;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n" +
14265
		
14887
			"StaticMembers.StaticClazz[TYPE_REF]{StaticClazz, test, Ltest.StaticMembers$StaticClazz;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n" +
14266
		int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
14888
			"class[FIELD_REF]{class, null, Ljava.lang.Class;, class, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n" +
14267
		int start1 = str.lastIndexOf("foo") + "".length();
14889
			"staticField[FIELD_REF]{staticField, Ltest.StaticMembers;, I, staticField, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n" +
14268
		int end1 = start1 + "foo".length();
14890
			"staticMethod[METHOD_REF]{staticMethod(), Ltest.StaticMembers;, ()I, staticMethod, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}\n" +
14269
		int start2 = str.lastIndexOf("public class");
14891
			"this[KEYWORD]{this, null, null, this, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_INHERITED + R_NON_RESTRICTED) + "}",
14270
		int end2 = start2 + "".length();
14892
			requestor.getResults());
14271
		assertResults(
14272
				"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14273
				"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
14274
				requestor.getResults());
14275
	} finally {
14276
		JavaCore.setOptions(oldOptions);
14277
	}
14278
}
14893
}
14279
}
14894
}
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java (+44 lines)
Lines 9393-9398 Link Here
9393
			"clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}",
9393
			"clone[METHOD_REF]{clone(), Ljava.lang.Object;, ()Ljava.lang.Object;, clone, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}",
9394
			requestor.getResults());
9394
			requestor.getResults());
9395
}
9395
}
9396
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
9397
public void test0300() throws JavaModelException {
9398
	this.workingCopies = new ICompilationUnit[3];
9399
	this.workingCopies[0] = getWorkingCopy(
9400
		"/Completion/src/test/Test.java",
9401
		"package test;"+
9402
		"public class Test {\n" + 
9403
		"	public void throwing() throws IZZAException, Top<Object>.IZZException {}\n" +
9404
		"	public void foo() {\n" +
9405
		"      try {\n" +
9406
		"         throwing();\n" +
9407
		"      }\n" +
9408
		"      catch (IZZAException e) {\n" +
9409
		"         bar();\n" +
9410
		"      }\n" +
9411
		"      catch (IZZ) {\n" +
9412
		"      }\n" +
9413
		"   }" +
9414
		"}\n");
9415
	
9416
	this.workingCopies[1] = getWorkingCopy(
9417
			"/Completion/src/test/IZZAException.java",
9418
			"package test;"+
9419
			"public class IZZAException extends Exception {\n" + 
9420
			"}\n");
9421
	
9422
	this.workingCopies[2] = getWorkingCopy(
9423
			"/Completion/src/test/IZZException.java",
9424
			"package test;"+
9425
			"public class Top<T> {\n" + 
9426
			"  public class IZZException extends Exception {\n" + 
9427
			"  }\n" + 
9428
			"}\n");
9429
9430
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9431
	String str = this.workingCopies[0].getSource();
9432
	String completeBehind = "IZZ";
9433
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9434
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9435
9436
	assertResults(
9437
			"Top<java.lang.Object>.IZZException[TYPE_REF]{test.Top.IZZException, test, Ltest.Top<Ljava.lang.Object;>.IZZException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXCEPTION + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
9438
			requestor.getResults());
9439
}
9396
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=153130
9440
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=153130
9397
public void testEC001() throws JavaModelException {
9441
public void testEC001() throws JavaModelException {
9398
	this.workingCopies = new ICompilationUnit[1];
9442
	this.workingCopies = new ICompilationUnit[1];
(-)src/org/eclipse/jdt/core/tests/model/JavadocBugsCompletionModelTest.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 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 58-68 Link Here
58
	completeInJavadoc("/Completion/src/javadoc/bugs/BasicTestBugs.java", source, true, "@throws ", 0); // empty token
58
	completeInJavadoc("/Completion/src/javadoc/bugs/BasicTestBugs.java", source, true, "@throws ", 0); // empty token
59
	if (CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
59
	if (CompletionEngine.NO_TYPE_COMPLETION_ON_EMPTY_TOKEN) {
60
		assertSortedResults(
60
		assertSortedResults(
61
			"InterruptedException[TYPE_REF]{InterruptedException, java.lang, Ljava.lang.InterruptedException;, null, null, "+this.positions+R_DICUNREET+"}"
61
			"InterruptedException[TYPE_REF]{InterruptedException, java.lang, Ljava.lang.InterruptedException;, null, null, "+this.positions+R_DICUNREETE+"}"
62
		);
62
		);
63
	} else {
63
	} else {
64
		assertSortedResults(
64
		assertSortedResults(
65
			"InterruptedException[TYPE_REF]{InterruptedException, java.lang, Ljava.lang.InterruptedException;, null, null, "+this.positions+R_DICUNREET+"}\n" + 
65
			"InterruptedException[TYPE_REF]{InterruptedException, java.lang, Ljava.lang.InterruptedException;, null, null, "+this.positions+R_DICUNREETE+"}\n" + 
66
			"BasicTestBugs[TYPE_REF]{BasicTestBugs, javadoc.bugs, Ljavadoc.bugs.BasicTestBugs;, null, null, "+this.positions+R_DICUNR+"}"
66
			"BasicTestBugs[TYPE_REF]{BasicTestBugs, javadoc.bugs, Ljavadoc.bugs.BasicTestBugs;, null, null, "+this.positions+R_DICUNR+"}"
67
		);
67
		);
68
	}
68
	}
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavadocCompletionModelTest.java (+2 lines)
Lines 63-68 Link Here
63
	protected static final int R_DICNREET = R_DICNR+R_EXACT_EXPECTED_TYPE;
63
	protected static final int R_DICNREET = R_DICNR+R_EXACT_EXPECTED_TYPE;
64
	/** R_DEFAULT+R_INTERESTING+R_CASE+R_UNQUALIFIED<br>+R_NON_RESTRICTED+R_EXACT_EXPECTED_TYPE<br>= 51 */
64
	/** R_DEFAULT+R_INTERESTING+R_CASE+R_UNQUALIFIED<br>+R_NON_RESTRICTED+R_EXACT_EXPECTED_TYPE<br>= 51 */
65
	protected static final int R_DICUNREET = R_DICUNR+R_EXACT_EXPECTED_TYPE;
65
	protected static final int R_DICUNREET = R_DICUNR+R_EXACT_EXPECTED_TYPE;
66
	/** R_DEFAULT+R_INTERESTING+R_CASE+R_UNQUALIFIED<br>+R_NON_RESTRICTED+R_EXACT_EXPECTED_TYPE+R_EXCEPTION<br>= 71 */
67
	protected static final int R_DICUNREETE = R_DICUNR+R_EXACT_EXPECTED_TYPE+R_EXCEPTION;
66
68
67
	// Exact Expected Exception relevance values
69
	// Exact Expected Exception relevance values
68
	/** R_DEFAULT+R_INTERESTING+R_CASE+R_NON_RESTRICTED<br>+R_EXCEPTION+R_EXACT_EXPECTED_TYPE<br>= 68 */
70
	/** R_DEFAULT+R_INTERESTING+R_CASE+R_NON_RESTRICTED<br>+R_EXCEPTION+R_EXACT_EXPECTED_TYPE<br>= 68 */
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-16 / +309 lines)
Lines 220-225 Link Here
220
	private final static char[] ON_DEMAND = ".*".toCharArray();  //$NON-NLS-1$
220
	private final static char[] ON_DEMAND = ".*".toCharArray();  //$NON-NLS-1$
221
	private final static char[] IMPORT_END = ";\n".toCharArray();  //$NON-NLS-1$
221
	private final static char[] IMPORT_END = ";\n".toCharArray();  //$NON-NLS-1$
222
	
222
	
223
	private final static int NONE = 0;
223
	private final static int SUPERTYPE = 1;
224
	private final static int SUPERTYPE = 1;
224
	private final static int SUBTYPE = 2;
225
	private final static int SUBTYPE = 2;
225
	
226
	
Lines 235-240 Link Here
235
	Binding[] uninterestingBindings = new Binding[1];
236
	Binding[] uninterestingBindings = new Binding[1];
236
	int forbbidenBindingsPtr = -1;
237
	int forbbidenBindingsPtr = -1;
237
	Binding[] forbbidenBindings = new Binding[1];
238
	Binding[] forbbidenBindings = new Binding[1];
239
	int forbbidenBindingsFilter;
238
	
240
	
239
	ImportBinding[] favoriteReferenceBindings;
241
	ImportBinding[] favoriteReferenceBindings;
240
	
242
	
Lines 829-835 Link Here
829
			this.completionToken = type.token;
831
			this.completionToken = type.token;
830
			setSourceRange(type.sourceStart, type.sourceEnd);
832
			setSourceRange(type.sourceStart, type.sourceEnd);
831
			
833
			
832
			findTypesAndPackages(this.completionToken, scope);
834
			findTypesAndPackages(this.completionToken, scope, new ObjectVector());
833
			if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
835
			if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
834
				findKeywordsForMember(this.completionToken, field.modifiers);
836
				findKeywordsForMember(this.completionToken, field.modifiers);
835
			}
837
			}
Lines 851-857 Link Here
851
			SingleTypeReference type = (CompletionOnSingleTypeReference) method.returnType;
853
			SingleTypeReference type = (CompletionOnSingleTypeReference) method.returnType;
852
			this.completionToken = type.token;
854
			this.completionToken = type.token;
853
			setSourceRange(type.sourceStart, type.sourceEnd);
855
			setSourceRange(type.sourceStart, type.sourceEnd);
854
			findTypesAndPackages(this.completionToken, scope.parent);
856
			findTypesAndPackages(this.completionToken, scope.parent, new ObjectVector());
855
			if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
857
			if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
856
				findKeywordsForMember(this.completionToken, method.modifiers);
858
				findKeywordsForMember(this.completionToken, method.modifiers);
857
			}
859
			}
Lines 880-886 Link Here
880
					this.findEnumConstant(this.completionToken, (SwitchStatement) astNodeParent);
882
					this.findEnumConstant(this.completionToken, (SwitchStatement) astNodeParent);
881
				}
883
				}
882
			} else if (this.expectedTypesPtr > -1 && this.expectedTypes[0].isAnnotationType()) {
884
			} else if (this.expectedTypesPtr > -1 && this.expectedTypes[0].isAnnotationType()) {
883
				findTypesAndPackages(this.completionToken, scope);
885
				findTypesAndPackages(this.completionToken, scope, new ObjectVector());
884
			} else {
886
			} else {
885
				findVariablesAndMethods(
887
				findVariablesAndMethods(
886
					this.completionToken,
888
					this.completionToken,
Lines 890-896 Link Here
890
					insideTypeAnnotation,
892
					insideTypeAnnotation,
891
					singleNameReference.isInsideAnnotationAttribute);
893
					singleNameReference.isInsideAnnotationAttribute);
892
				// can be the start of a qualified type name
894
				// can be the start of a qualified type name
893
				findTypesAndPackages(this.completionToken, scope);
895
				findTypesAndPackages(this.completionToken, scope, new ObjectVector());
894
				if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
896
				if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) {
895
					if (this.completionToken != null && this.completionToken.length != 0) {
897
					if (this.completionToken != null && this.completionToken.length != 0) {
896
						findKeywords(this.completionToken, singleNameReference.possibleKeywords, false, false);
898
						findKeywords(this.completionToken, singleNameReference.possibleKeywords, false, false);
Lines 929-935 Link Here
929
					
931
					
930
					findParameterizedType((TypeReference)astNodeParent, scope);
932
					findParameterizedType((TypeReference)astNodeParent, scope);
931
				} else { 
933
				} else { 
932
					findTypesAndPackages(this.completionToken, scope);
934
					ObjectVector typesFound = new ObjectVector();
935
					if (this.assistNodeIsException && astNodeParent instanceof TryStatement) {
936
						findExceptionFromTryStatement(
937
								this.completionToken,
938
								null,
939
								scope.enclosingSourceType(),
940
								(BlockScope)scope,
941
								typesFound);
942
					}
943
					findTypesAndPackages(this.completionToken, scope, typesFound);
933
				}
944
				}
934
			} else if (!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
945
			} else if (!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
935
				findMemberTypes(
946
				findMemberTypes(
Lines 1112-1117 Link Here
1112
			if (qualifiedBinding instanceof ReferenceBinding && !(qualifiedBinding instanceof TypeVariableBinding)) {
1123
			if (qualifiedBinding instanceof ReferenceBinding && !(qualifiedBinding instanceof TypeVariableBinding)) {
1113
				if (!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
1124
				if (!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
1114
					setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
1125
					setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
1126
					
1127
					ObjectVector typesFound = new ObjectVector();
1128
					
1129
					if (this.assistNodeIsException && astNodeParent instanceof TryStatement) {
1130
						findExceptionFromTryStatement(
1131
								this.completionToken,
1132
								(ReferenceBinding)qualifiedBinding,
1133
								scope.enclosingSourceType(),
1134
								(BlockScope)scope,
1135
								typesFound);
1136
					}
1137
					
1115
					findMemberTypes(
1138
					findMemberTypes(
1116
						this.completionToken,
1139
						this.completionToken,
1117
						(ReferenceBinding) qualifiedBinding,
1140
						(ReferenceBinding) qualifiedBinding,
Lines 1119-1125 Link Here
1119
						scope.enclosingSourceType(),
1142
						scope.enclosingSourceType(),
1120
						false,
1143
						false,
1121
						false,
1144
						false,
1122
						new ObjectVector());
1145
						typesFound);
1123
				}
1146
				}
1124
			} else if (qualifiedBinding instanceof PackageBinding) {
1147
			} else if (qualifiedBinding instanceof PackageBinding) {
1125
1148
Lines 1335-1340 Link Here
1335
				this.completionToken = ref.completionIdentifier;
1358
				this.completionToken = ref.completionIdentifier;
1336
				long completionPosition = ref.sourcePositions[ref.tokens.length];
1359
				long completionPosition = ref.sourcePositions[ref.tokens.length];
1337
				setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
1360
				setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
1361
				
1362
				ObjectVector typesFound = new ObjectVector();
1363
				if (this.assistNodeIsException && astNodeParent instanceof TryStatement) {
1364
					findExceptionFromTryStatement(
1365
							this.completionToken,
1366
							(ReferenceBinding)qualifiedBinding,
1367
							scope.enclosingSourceType(),
1368
							(BlockScope)scope,
1369
							typesFound);
1370
				}
1371
				
1338
				findMemberTypes(
1372
				findMemberTypes(
1339
					this.completionToken,
1373
					this.completionToken,
1340
					(ReferenceBinding) qualifiedBinding,
1374
					(ReferenceBinding) qualifiedBinding,
Lines 1342-1348 Link Here
1342
					scope.enclosingSourceType(),
1376
					scope.enclosingSourceType(),
1343
					false,
1377
					false,
1344
					false,
1378
					false,
1345
					new ObjectVector());
1379
					typesFound);
1346
			}
1380
			}
1347
		} else if (astNode instanceof CompletionOnMarkerAnnotationName) {
1381
		} else if (astNode instanceof CompletionOnMarkerAnnotationName) {
1348
			CompletionOnMarkerAnnotationName annot = (CompletionOnMarkerAnnotationName) astNode;
1382
			CompletionOnMarkerAnnotationName annot = (CompletionOnMarkerAnnotationName) astNode;
Lines 1353-1359 Link Here
1353
				this.completionToken = type.token;
1387
				this.completionToken = type.token;
1354
				setSourceRange(type.sourceStart, type.sourceEnd);
1388
				setSourceRange(type.sourceStart, type.sourceEnd);
1355
				
1389
				
1356
				findTypesAndPackages(this.completionToken, scope);
1390
				findTypesAndPackages(this.completionToken, scope, new ObjectVector());
1357
			} else if (annot.type instanceof CompletionOnQualifiedTypeReference) {
1391
			} else if (annot.type instanceof CompletionOnQualifiedTypeReference) {
1358
				this.insideQualifiedReference = true;
1392
				this.insideQualifiedReference = true;
1359
				
1393
				
Lines 1392-1398 Link Here
1392
				}
1426
				}
1393
				if (this.assistNodeCanBeSingleMemberAnnotation) {
1427
				if (this.assistNodeCanBeSingleMemberAnnotation) {
1394
					if (this.expectedTypesPtr > -1 && this.expectedTypes[0].isAnnotationType()) {
1428
					if (this.expectedTypesPtr > -1 && this.expectedTypes[0].isAnnotationType()) {
1395
						findTypesAndPackages(this.completionToken, scope);
1429
						findTypesAndPackages(this.completionToken, scope, new ObjectVector());
1396
					} else {
1430
					} else {
1397
						findVariablesAndMethods(
1431
						findVariablesAndMethods(
1398
							this.completionToken,
1432
							this.completionToken,
Lines 1402-1408 Link Here
1402
							insideTypeAnnotation,
1436
							insideTypeAnnotation,
1403
							true);
1437
							true);
1404
						// can be the start of a qualified type name
1438
						// can be the start of a qualified type name
1405
						findTypesAndPackages(this.completionToken, scope);
1439
						findTypesAndPackages(this.completionToken, scope, new ObjectVector());
1406
					}
1440
					}
1407
				}
1441
				}
1408
			}
1442
			}
Lines 1463-1469 Link Here
1463
				this.completionToken = typeRef.token;
1497
				this.completionToken = typeRef.token;
1464
				this.javadocTagPosition = typeRef.tagSourceStart;
1498
				this.javadocTagPosition = typeRef.tagSourceStart;
1465
				setSourceRange(typeRef.sourceStart, typeRef.sourceEnd);
1499
				setSourceRange(typeRef.sourceStart, typeRef.sourceEnd);
1466
				findTypesAndPackages(this.completionToken, scope);
1500
				findTypesAndPackages(this.completionToken, scope, new ObjectVector());
1467
1501
1468
			} else if (astNode instanceof CompletionOnJavadocQualifiedTypeReference) {
1502
			} else if (astNode instanceof CompletionOnJavadocQualifiedTypeReference) {
1469
1503
Lines 1646-1652 Link Here
1646
		}
1680
		}
1647
		return true;
1681
		return true;
1648
	}
1682
	}
1649
	
1683
1650
	public void complete(IType type, char[] snippet, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic){	
1684
	public void complete(IType type, char[] snippet, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic){	
1651
		if(this.requestor != null){
1685
		if(this.requestor != null){
1652
			this.requestor.beginReporting();
1686
			this.requestor.beginReporting();
Lines 2244-2249 Link Here
2244
			}
2278
			}
2245
		}
2279
		}
2246
	}
2280
	}
2281
	
2282
	private void findExceptionFromTryStatement(
2283
			char[] typeName,
2284
			ReferenceBinding exceptionType,
2285
			ReferenceBinding receiverType,
2286
			SourceTypeBinding invocationType, 
2287
			BlockScope scope, 
2288
			ObjectVector typesFound,
2289
			boolean searchSuperClasses) {
2290
		
2291
		if (isForbidden(exceptionType)) {
2292
			this.knownTypes.put(CharOperation.concat(exceptionType.qualifiedPackageName(), exceptionType.qualifiedSourceName(), '.'), this);
2293
			return;
2294
		}
2295
		
2296
		if (searchSuperClasses) {
2297
			ReferenceBinding javaLangThrowable = scope.getJavaLangThrowable();
2298
			if (exceptionType != javaLangThrowable) {
2299
				ReferenceBinding superClass = exceptionType.superclass();
2300
				while(superClass != null && superClass != javaLangThrowable) {
2301
					findExceptionFromTryStatement(typeName, superClass, receiverType, invocationType, scope, typesFound, false);
2302
					superClass = superClass.superclass();
2303
				}
2304
			}
2305
		}
2306
		
2307
		if (typeName.length > exceptionType.sourceName.length)
2308
			return;
2309
2310
		if (!CharOperation.prefixEquals(typeName, exceptionType.sourceName, false/* ignore case */)
2311
				&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(typeName, exceptionType.sourceName)))
2312
			return;
2313
2314
		if (this.options.checkDeprecation &&
2315
				exceptionType.isViewedAsDeprecated() &&
2316
				!scope.isDefinedInSameUnit(exceptionType))
2317
			return;
2318
		
2319
		if (this.options.checkVisibility) {
2320
			if (invocationType != null && !exceptionType.canBeSeenBy(receiverType, invocationType)) {
2321
				return;
2322
			} else if(invocationType == null && !exceptionType.canBeSeenBy(this.unitScope.fPackage)) {
2323
				return;
2324
			}
2325
		}
2326
2327
		for (int j = typesFound.size; --j >= 0;) {
2328
			ReferenceBinding otherType = (ReferenceBinding) typesFound.elementAt(j);
2329
2330
			if (exceptionType == otherType)
2331
				return;
2332
2333
			if (CharOperation.equals(exceptionType.sourceName, otherType.sourceName, true)) {
2334
2335
				if (exceptionType.enclosingType().isSuperclassOf(otherType.enclosingType()))
2336
					return;
2337
2338
				if (otherType.enclosingType().isInterface())
2339
					if (exceptionType.enclosingType()
2340
						.implementsInterface(otherType.enclosingType(), true))
2341
						return;
2342
2343
				if (exceptionType.enclosingType().isInterface())
2344
					if (otherType.enclosingType()
2345
						.implementsInterface(exceptionType.enclosingType(), true))
2346
						return;
2347
			}
2348
		}
2349
2350
		typesFound.add(exceptionType);
2351
		
2352
		char[] completionName = exceptionType.sourceName();
2353
		
2354
		boolean isQualified = false;
2355
		
2356
		if(!this.insideQualifiedReference) {
2357
			isQualified = true;
2358
			
2359
			char[] memberPackageName = exceptionType.qualifiedPackageName();
2360
			char[] memberTypeName = exceptionType.sourceName();
2361
			char[] memberEnclosingTypeNames = null;
2362
			
2363
			ReferenceBinding enclosingType = exceptionType.enclosingType();
2364
			if (enclosingType != null) {
2365
				memberEnclosingTypeNames = exceptionType.enclosingType().qualifiedSourceName();
2366
			}
2367
			
2368
			Scope currentScope = scope;
2369
			done : while (currentScope != null) { // done when a COMPILATION_UNIT_SCOPE is found
2370
2371
				switch (currentScope.kind) {
2372
2373
					case Scope.METHOD_SCOPE :
2374
					case Scope.BLOCK_SCOPE :
2375
						BlockScope blockScope = (BlockScope) currentScope;
2376
2377
						for (int j = 0, length = blockScope.subscopeCount; j < length; j++) {
2378
2379
							if (blockScope.subscopes[j] instanceof ClassScope) {
2380
								SourceTypeBinding localType =
2381
									((ClassScope) blockScope.subscopes[j]).referenceContext.binding;
2382
								
2383
								if (localType == exceptionType) {
2384
									isQualified = false;
2385
									break done;
2386
								}
2387
							}
2388
						}
2389
						break;
2390
2391
					case Scope.CLASS_SCOPE :
2392
						SourceTypeBinding type = ((ClassScope)currentScope).referenceContext.binding;
2393
						ReferenceBinding[] memberTypes = type.memberTypes();
2394
						if (memberTypes != null) {
2395
							for (int j = 0; j < memberTypes.length; j++) {
2396
								if (memberTypes[j] == exceptionType) {
2397
									isQualified = false;
2398
									break done;
2399
								}
2400
							}
2401
						}
2402
						
2403
						
2404
						break;
2405
2406
					case Scope.COMPILATION_UNIT_SCOPE :
2407
						SourceTypeBinding[] types = ((CompilationUnitScope)currentScope).topLevelTypes;
2408
						if (types != null) {
2409
							for (int j = 0; j < types.length; j++) {
2410
								if (types[j] == exceptionType) {
2411
									isQualified = false;
2412
									break done;
2413
								}
2414
							}
2415
						}
2416
						break done;
2417
				}
2418
				currentScope = currentScope.parent;
2419
			}
2420
			
2421
			if (isQualified && mustQualifyType(memberPackageName, memberTypeName, memberEnclosingTypeNames, exceptionType.modifiers)) {
2422
				if (memberPackageName == null || memberPackageName.length == 0)
2423
					if (this.unitScope != null && this.unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR)
2424
						return; // ignore types from the default package from outside it
2425
			} else {
2426
				isQualified = false;
2427
			}
2428
			
2429
			if (isQualified) {
2430
				completionName =
2431
					CharOperation.concat(
2432
							memberPackageName,
2433
							CharOperation.concat(
2434
									memberEnclosingTypeNames,
2435
									memberTypeName,
2436
									'.'),
2437
							'.');
2438
			}
2439
		}
2440
		
2441
		int relevance = computeBaseRelevance();
2442
		relevance += computeRelevanceForInterestingProposal();
2443
		relevance += computeRelevanceForCaseMatching(typeName, exceptionType.sourceName);
2444
		relevance += computeRelevanceForExpectingType(exceptionType);
2445
		relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
2446
		if(!insideQualifiedReference) {
2447
			relevance += computeRelevanceForQualification(isQualified);
2448
		}
2449
		relevance += computeRelevanceForClass();
2450
		relevance += computeRelevanceForException();
2451
			
2452
		this.noProposal = false;
2453
		if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
2454
			createTypeProposal(exceptionType, exceptionType.qualifiedSourceName(), IAccessRule.K_ACCESSIBLE, completionName, relevance);
2455
		}
2456
	}
2457
	
2458
	private void findExceptionFromTryStatement(
2459
			char[] typeName,
2460
			ReferenceBinding receiverType,
2461
			SourceTypeBinding invocationType, 
2462
			BlockScope scope, 
2463
			ObjectVector typesFound) {
2464
		
2465
		for (int i = 0; i <= this.expectedTypesPtr; i++) {
2466
			ReferenceBinding exceptionType = (ReferenceBinding)this.expectedTypes[i];
2467
			
2468
			findExceptionFromTryStatement(typeName, exceptionType, receiverType, invocationType, scope, typesFound, true);
2469
		}
2470
	}
2247
	private void findExplicitConstructors(
2471
	private void findExplicitConstructors(
2248
		char[] name,
2472
		char[] name,
2249
		ReferenceBinding currentType,
2473
		ReferenceBinding currentType,
Lines 5185-5190 Link Here
5185
		}
5409
		}
5186
		return 0;
5410
		return 0;
5187
	}
5411
	}
5412
	private int computeRelevanceForException(){
5413
		if (this.assistNodeIsException) {
5414
			return R_EXCEPTION;
5415
		}
5416
		return 0;
5417
	}
5188
	private int computeRelevanceForException(char[] proposalName){
5418
	private int computeRelevanceForException(char[] proposalName){
5189
		
5419
		
5190
		if((this.assistNodeIsException || (this.assistNodeInJavadoc & CompletionOnJavadoc.EXCEPTION) != 0 )&&
5420
		if((this.assistNodeIsException || (this.assistNodeInJavadoc & CompletionOnJavadoc.EXCEPTION) != 0 )&&
Lines 5925-5930 Link Here
5925
										&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(typeName, localType.sourceName)))
6155
										&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(typeName, localType.sourceName)))
5926
									continue next;
6156
									continue next;
5927
								
6157
								
6158
								for (int j = typesFound.size; --j >= 0;) {
6159
									ReferenceBinding otherType = (ReferenceBinding) typesFound.elementAt(j);
6160
6161
									if (localType == otherType)
6162
										continue next;
6163
								}
6164
								
5928
								if(this.assistNodeIsClass) {
6165
								if(this.assistNodeIsClass) {
5929
									if(!localType.isClass()) continue next;
6166
									if(!localType.isClass()) continue next;
5930
								} else if(this.assistNodeIsInterface) {
6167
								} else if(this.assistNodeIsInterface) {
Lines 6070-6077 Link Here
6070
			scope = scope.parent;
6307
			scope = scope.parent;
6071
		}
6308
		}
6072
	}
6309
	}
6073
	
6310
	private void findTypesAndPackages(char[] token, Scope scope, ObjectVector typesFound) {
6074
	private void findTypesAndPackages(char[] token, Scope scope) {
6075
6311
6076
		if (token == null)
6312
		if (token == null)
6077
			return;
6313
			return;
Lines 6089-6096 Link Here
6089
		
6325
		
6090
		boolean proposeAllMemberTypes = !this.assistNodeIsConstructor;
6326
		boolean proposeAllMemberTypes = !this.assistNodeIsConstructor;
6091
		
6327
		
6092
		ObjectVector typesFound = new ObjectVector();
6093
		
6094
		if (!skip && proposeType && scope.enclosingSourceType() != null) {
6328
		if (!skip && proposeType && scope.enclosingSourceType() != null) {
6095
			findNestedTypes(token, scope.enclosingSourceType(), scope, proposeAllMemberTypes, typesFound);
6329
			findNestedTypes(token, scope.enclosingSourceType(), scope, proposeAllMemberTypes, typesFound);
6096
			if(!assistNodeIsConstructor) {
6330
			if(!assistNodeIsConstructor) {
Lines 6212-6217 Link Here
6212
							}
6446
							}
6213
						}
6447
						}
6214
						
6448
						
6449
						for (int j = 0; j < typesFound.size(); j++) {
6450
							ReferenceBinding typeFound = (ReferenceBinding)typesFound.elementAt(j);
6451
							if (typeFound == refBinding) {
6452
								continue next;
6453
							}
6454
						}
6455
						
6215
						boolean inSameUnit = this.unitScope.isDefinedInSameUnit(refBinding);
6456
						boolean inSameUnit = this.unitScope.isDefinedInSameUnit(refBinding);
6216
						
6457
						
6217
						// top level types of the current unit are already proposed.
6458
						// top level types of the current unit are already proposed.
Lines 6248-6253 Link Here
6248
							
6489
							
6249
							if(refBinding.isClass()) {
6490
							if(refBinding.isClass()) {
6250
								relevance += computeRelevanceForClass();
6491
								relevance += computeRelevanceForClass();
6492
								relevance += computeRelevanceForException(typeName);
6251
							} else if(refBinding.isEnum()) {
6493
							} else if(refBinding.isEnum()) {
6252
								relevance += computeRelevanceForEnum();
6494
								relevance += computeRelevanceForEnum();
6253
							} else if(refBinding.isInterface()) {
6495
							} else if(refBinding.isInterface()) {
Lines 7483-7488 Link Here
7483
					}
7725
					}
7484
				}
7726
				}
7485
			}
7727
			}
7728
		} else if (parent instanceof TryStatement) {
7729
			boolean isException = false;
7730
			if (node instanceof CompletionOnSingleTypeReference) {
7731
				isException = ((CompletionOnSingleTypeReference)node).isException();
7732
			} else if (node instanceof CompletionOnQualifiedTypeReference) {
7733
				isException = ((CompletionOnQualifiedTypeReference)node).isException();
7734
			} else if (node instanceof CompletionOnParameterizedQualifiedTypeReference) {
7735
				isException = ((CompletionOnParameterizedQualifiedTypeReference)node).isException();
7736
			}
7737
			if (isException) {
7738
				ThrownExceptionFinder thrownExceptionFinder = new ThrownExceptionFinder();
7739
				ReferenceBinding[] bindings = thrownExceptionFinder.find((TryStatement) parent, (BlockScope)scope);
7740
				if (bindings != null && bindings.length > 0) {
7741
					for (int i = 0; i < bindings.length; i++) {
7742
						addExpectedType(bindings[i], scope);
7743
					}
7744
					this.expectedTypesFilter = SUPERTYPE;
7745
				}
7746
			}
7747
			
7486
		// Expected types for javadoc
7748
		// Expected types for javadoc
7487
		} else if (parent instanceof Javadoc) {
7749
		} else if (parent instanceof Javadoc) {
7488
			if (scope.kind == Scope.METHOD_SCOPE) {
7750
			if (scope.kind == Scope.METHOD_SCOPE) {
Lines 7654-7659 Link Here
7654
	}
7916
	}
7655
7917
7656
	private Scope computeForbiddenBindings(ASTNode astNode, ASTNode astNodeParent, Scope scope) {
7918
	private Scope computeForbiddenBindings(ASTNode astNode, ASTNode astNodeParent, Scope scope) {
7919
		this.forbbidenBindingsFilter = NONE;
7657
		if(scope instanceof ClassScope) {
7920
		if(scope instanceof ClassScope) {
7658
			TypeDeclaration typeDeclaration = ((ClassScope)scope).referenceContext;
7921
			TypeDeclaration typeDeclaration = ((ClassScope)scope).referenceContext;
7659
			if(typeDeclaration.superclass == astNode) {
7922
			if(typeDeclaration.superclass == astNode) {
Lines 7668-7673 Link Here
7668
					return scope.parent;
7931
					return scope.parent;
7669
				}
7932
				}
7670
			}
7933
			}
7934
		} else {
7935
			if (astNodeParent != null && astNodeParent instanceof TryStatement) {
7936
				boolean isException = false;
7937
				if (astNode instanceof CompletionOnSingleTypeReference) {
7938
					isException = ((CompletionOnSingleTypeReference)astNode).isException();
7939
				} else if (astNode instanceof CompletionOnQualifiedTypeReference) {
7940
					isException = ((CompletionOnQualifiedTypeReference)astNode).isException();
7941
				} else if (astNode instanceof CompletionOnParameterizedQualifiedTypeReference) {
7942
					isException = ((CompletionOnParameterizedQualifiedTypeReference)astNode).isException();
7943
				}
7944
				if (isException) {
7945
					Argument[] catchArguments = ((TryStatement) astNodeParent).catchArguments;
7946
					int length = catchArguments == null ? 0 : catchArguments.length;
7947
					for (int i = 0; i < length; i++) {
7948
						TypeBinding caughtException = catchArguments[i].type.resolvedType;
7949
						if (caughtException != null) {
7950
							this.addForbiddenBindings(caughtException);
7951
							this.knownTypes.put(CharOperation.concat(caughtException.qualifiedPackageName(), caughtException.qualifiedSourceName(), '.'), this);
7952
						}
7953
					}
7954
					this.forbbidenBindingsFilter = SUBTYPE;
7955
				}
7956
			}
7671
		}
7957
		}
7672
//		else if(scope instanceof MethodScope) {
7958
//		else if(scope instanceof MethodScope) {
7673
//			MethodScope methodScope = (MethodScope) scope;
7959
//			MethodScope methodScope = (MethodScope) scope;
Lines 7745-7750 Link Here
7745
			if(this.forbbidenBindings[i] == binding) {
8031
			if(this.forbbidenBindings[i] == binding) {
7746
				return true;
8032
				return true;
7747
			}
8033
			}
8034
			if((this.forbbidenBindingsFilter & SUBTYPE) != 0) {
8035
				if (binding instanceof TypeBinding && 
8036
						this.forbbidenBindings[i] instanceof TypeBinding &&
8037
						((TypeBinding)binding).isCompatibleWith((TypeBinding)this.forbbidenBindings[i])) {
8038
					return true;
8039
				}
8040
			}
7748
		}
8041
		}
7749
		return false;
8042
		return false;
7750
	}
8043
	}
(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java (-1 / +69 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 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 74-79 Link Here
74
	
74
	
75
	public final static char[] FAKE_TYPE_NAME = new char[]{' '};
75
	public final static char[] FAKE_TYPE_NAME = new char[]{' '};
76
	public final static char[] FAKE_METHOD_NAME = new char[]{' '};
76
	public final static char[] FAKE_METHOD_NAME = new char[]{' '};
77
	public final static char[] FAKE_ARGUMENT_NAME = new char[]{' '};
77
	public final static char[] VALUE = new char[]{'v', 'a', 'l', 'u', 'e'};
78
	public final static char[] VALUE = new char[]{'v', 'a', 'l', 'u', 'e'};
78
	
79
	
79
	/* public fields */
80
	/* public fields */
Lines 235-240 Link Here
235
				currentElement.add(fakeType, 0);
236
				currentElement.add(fakeType, 0);
236
				return;
237
				return;
237
		}
238
		}
239
		
240
		if ((topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BETWEEN_CATCH_AND_RIGHT_PAREN)) {
241
			if (this.assistNode instanceof CompletionOnSingleTypeReference &&
242
					((CompletionOnSingleTypeReference)this.assistNode).isException()) {
243
				buildMoreTryStatementCompletionContext((TypeReference)this.assistNode);
244
				return;
245
			} else if (this.assistNode instanceof CompletionOnQualifiedTypeReference &&
246
					((CompletionOnQualifiedTypeReference)this.assistNode).isException()) {
247
				buildMoreTryStatementCompletionContext((TypeReference)this.assistNode);
248
				return;
249
			} else if (this.assistNode instanceof CompletionOnParameterizedQualifiedTypeReference &&
250
					((CompletionOnParameterizedQualifiedTypeReference)this.assistNode).isException()) {
251
				buildMoreTryStatementCompletionContext((TypeReference)this.assistNode);
252
				return;
253
			}
254
		}
255
		
238
		// add the completion node to the method declaration or constructor declaration
256
		// add the completion node to the method declaration or constructor declaration
239
		if (orphan instanceof Statement) {
257
		if (orphan instanceof Statement) {
240
			/* check for completion at the beginning of method body
258
			/* check for completion at the beginning of method body
Lines 905-910 Link Here
905
		}
923
		}
906
	}
924
	}
907
}
925
}
926
private void buildMoreTryStatementCompletionContext(TypeReference exceptionRef) {
927
	if (this.astLengthPtr > -1 &&
928
			this.astPtr > 1 &&
929
			this.astStack[this.astPtr] instanceof Block &&
930
			this.astStack[this.astPtr - 1] instanceof Argument) {
931
		TryStatement tryStatement = new TryStatement();
932
	
933
		int newAstPtr = this.astPtr;
934
		
935
		int length = this.astLengthStack[this.astLengthPtr];
936
		Block[] bks = (tryStatement.catchBlocks = new Block[length + 1]);
937
		Argument[] args = (tryStatement.catchArguments = new Argument[length + 1]);
938
		if (length != 0) {
939
			while (length-- > 0) {
940
				bks[length] = (Block) this.astStack[newAstPtr--];
941
				bks[length].statements = null; // statements of catch block won't be used
942
				args[length] = (Argument) this.astStack[newAstPtr--];
943
			}
944
		}
945
		
946
		bks[bks.length - 1] = new Block(0);
947
		args[args.length - 1] = new Argument(FAKE_ARGUMENT_NAME,0,exceptionRef,0);
948
		
949
		tryStatement.tryBlock = (Block) this.astStack[newAstPtr--];
950
		
951
		assistNodeParent = tryStatement;
952
		
953
		currentElement.add(tryStatement, 0);
954
	} else if (this.astLengthPtr > -1 &&
955
			this.astPtr > -1 &&
956
			this.astStack[this.astPtr] instanceof Block) {
957
		TryStatement tryStatement = new TryStatement();
958
		
959
		int newAstPtr = this.astPtr;
960
		
961
		Block[] bks = (tryStatement.catchBlocks = new Block[1]);
962
		Argument[] args = (tryStatement.catchArguments = new Argument[1]);
963
		
964
		bks[0] = new Block(0);
965
		args[0] = new Argument(FAKE_ARGUMENT_NAME,0,exceptionRef,0);
966
		
967
		tryStatement.tryBlock = (Block) this.astStack[newAstPtr--];
968
		
969
		assistNodeParent = tryStatement;
970
		
971
		currentElement.add(tryStatement, 0);
972
	}else {
973
		currentElement = currentElement.add(exceptionRef, 0);
974
	}
975
}
908
public int bodyEnd(AbstractMethodDeclaration method){
976
public int bodyEnd(AbstractMethodDeclaration method){
909
	return cursorLocation;
977
	return cursorLocation;
910
}
978
}
(-)codeassist/org/eclipse/jdt/internal/codeassist/ThrownExceptionFinder.java (+130 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.codeassist;
12
13
import java.util.Stack;
14
15
import org.eclipse.jdt.internal.compiler.ASTVisitor;
16
import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
17
import org.eclipse.jdt.internal.compiler.ast.Argument;
18
import org.eclipse.jdt.internal.compiler.ast.Block;
19
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
20
import org.eclipse.jdt.internal.compiler.ast.ThrowStatement;
21
import org.eclipse.jdt.internal.compiler.ast.TryStatement;
22
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
23
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
24
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
25
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
26
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
27
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
28
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
29
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
30
31
public class ThrownExceptionFinder extends ASTVisitor {
32
33
	private SimpleSet thrownExceptions;
34
	private Stack exceptionsStack;
35
	
36
	public ReferenceBinding[] find(TryStatement tryStatement, BlockScope scope) {
37
		this.thrownExceptions = new SimpleSet();
38
		this.exceptionsStack = new Stack();
39
		tryStatement.traverse(this, scope);
40
		removeCaughtExceptions(tryStatement);
41
		
42
		ReferenceBinding[] result = new ReferenceBinding[this.thrownExceptions.elementSize];
43
		this.thrownExceptions.asArray(result);
44
		return result;
45
	}
46
47
	private void acceptException(ReferenceBinding binding) {
48
		if (binding != null && binding.isValidBinding()) {
49
			this.thrownExceptions.add(binding);
50
		}
51
	}
52
	
53
	public void endVisit(MessageSend messageSend, BlockScope scope) {
54
		if (messageSend.binding != null) {
55
			this.endVisitMethodInvocation(messageSend.binding);
56
		}
57
		super.endVisit(messageSend, scope);
58
	}
59
	
60
	public void endVisit(AllocationExpression allocationExpression, BlockScope scope) {
61
		if (allocationExpression.binding != null) {
62
			this.endVisitMethodInvocation(allocationExpression.binding);
63
		}
64
		super.endVisit(allocationExpression, scope);
65
	}
66
	
67
	public void endVisit(ThrowStatement throwStatement, BlockScope scope) {
68
		this.acceptException((ReferenceBinding)throwStatement.exception.resolvedType);
69
		super.endVisit(throwStatement, scope);
70
	}
71
	
72
	
73
	private void endVisitMethodInvocation(MethodBinding methodBinding) {
74
		ReferenceBinding[] thrownExceptionBindings = methodBinding.thrownExceptions;
75
		int length = thrownExceptionBindings == null ? 0 : thrownExceptionBindings.length;
76
		for (int i = 0; i < length; i++) {
77
			this.acceptException(thrownExceptionBindings[i]);
78
		}
79
	}
80
	
81
	public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) {
82
		return this.visitType(typeDeclaration);
83
	}
84
	
85
	public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope scope) {
86
		return this.visitType(memberTypeDeclaration);
87
	}
88
	
89
	public boolean visit(TypeDeclaration localTypeDeclaration, BlockScope scope) {
90
		return this.visitType(localTypeDeclaration);
91
	}
92
	
93
	private boolean visitType(TypeDeclaration typeDeclaration) {
94
		return false;
95
	}
96
97
	public boolean visit(TryStatement tryStatement, BlockScope scope) {
98
		this.exceptionsStack.push(this.thrownExceptions);
99
		SimpleSet exceptionSet = new SimpleSet();
100
		this.thrownExceptions = exceptionSet;
101
		tryStatement.tryBlock.traverse(this, scope);
102
		
103
		this.removeCaughtExceptions(tryStatement);
104
105
		this.thrownExceptions = (SimpleSet)this.exceptionsStack.pop();
106
		
107
		Object[] values = exceptionSet.values;
108
		for (int i = 0; i < values.length; i++) {
109
			if (values[i] != null) {
110
				this.thrownExceptions.add(values[i]);
111
			}
112
		}
113
		
114
		Block[] catchBlocks = tryStatement.catchBlocks;
115
		for (int i = 0; i < catchBlocks.length; i++) {
116
			catchBlocks[i].traverse(this, scope);
117
		}
118
		return false;
119
	}
120
	
121
	private void removeCaughtExceptions(TryStatement tryStatement) {
122
		Argument[] catchArguments = tryStatement.catchArguments;
123
		for (int i = 0; i < catchArguments.length; i++) {
124
			TypeBinding exception = catchArguments[i].type.resolvedType;
125
			if (exception != null && exception.isValidBinding()) {
126
				this.thrownExceptions.remove(exception);
127
			}
128
		}
129
	}
130
}
(-)src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest2.java (-1 / +360 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 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 9332-9335 Link Here
9332
			expectedReplacedSource,
9332
			expectedReplacedSource,
9333
			"full ast");
9333
			"full ast");
9334
}
9334
}
9335
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
9336
public void test0167() {
9337
9338
	String str = 
9339
		"public class X {\n" +
9340
		"	public boolean foo() {\n" +
9341
		"      try {\n" +
9342
		"         throwing();\n" +
9343
		"      }\n" +
9344
		"      catch (IllegalAccessException e) {\n" +
9345
		"         bar();\n" +
9346
		"      }\n" +
9347
		"      catch (IZZ) {\n" +
9348
		"      }\n" +
9349
		"   }" +
9350
		"}\n"; 
9351
9352
	String completeBehind = "IZZ";
9353
	int cursorLocation = str.lastIndexOf("IZZ") + completeBehind.length() - 1;
9354
	String expectedCompletionNodeToString = "<NONE>";
9355
	String expectedParentNodeToString = "<NONE>";
9356
	String completionIdentifier = "<NONE>";
9357
	String expectedReplacedSource = "<NONE>";
9358
	String expectedUnitDisplayString =
9359
		"public class X {\n" + 
9360
		"  public X() {\n" + 
9361
		"  }\n" + 
9362
		"  public boolean foo() {\n" + 
9363
		"  }\n" + 
9364
		"}\n";
9365
9366
	checkDietParse(
9367
			str.toCharArray(),
9368
			cursorLocation,
9369
			expectedCompletionNodeToString,
9370
			expectedParentNodeToString,
9371
			expectedUnitDisplayString,
9372
			completionIdentifier,
9373
			expectedReplacedSource,
9374
	"diet ast");
9375
	
9376
	expectedCompletionNodeToString = "<CompleteOnException:IZZ>";
9377
	expectedParentNodeToString =
9378
		"try \n" + 
9379
		"  {\n" + 
9380
		"    throwing();\n" + 
9381
		"  }\n" + 
9382
		"catch (IllegalAccessException e)   {\n" + 
9383
		"  }\n" + 
9384
		"catch (<CompleteOnException:IZZ>  )   {\n" + 
9385
		"  }";
9386
	completionIdentifier = "IZZ";
9387
	expectedReplacedSource = "IZZ";
9388
	expectedUnitDisplayString =
9389
		"public class X {\n" + 
9390
		"  public X() {\n" + 
9391
		"  }\n" + 
9392
		"  public boolean foo() {\n" + 
9393
		"    try \n" + 
9394
		"      {\n" + 
9395
		"        throwing();\n" + 
9396
		"      }\n" + 
9397
		"    catch (IllegalAccessException e)       {\n" + 
9398
		"      }\n" + 
9399
		"    catch (<CompleteOnException:IZZ>  )       {\n" + 
9400
		"      }\n" + 
9401
		"  }\n" + 
9402
		"}\n";
9403
9404
	checkMethodParse(
9405
			str.toCharArray(),
9406
			cursorLocation,
9407
			expectedCompletionNodeToString,
9408
			expectedParentNodeToString,
9409
			expectedUnitDisplayString,
9410
			completionIdentifier,
9411
			expectedReplacedSource,
9412
			"full ast");
9413
}
9414
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
9415
public void test0168() {
9416
9417
	String str = 
9418
		"public class X {\n" +
9419
		"	public boolean foo() {\n" +
9420
		"      try {\n" +
9421
		"         throwing();\n" +
9422
		"      }\n" +
9423
		"      catch (IllegalAccessException e) {\n" +
9424
		"         bar();\n" +
9425
		"      }\n" +
9426
		"      catch (IZZ\n" +
9427
		"   }" +
9428
		"}\n"; 
9429
9430
	String completeBehind = "IZZ";
9431
	int cursorLocation = str.lastIndexOf("IZZ") + completeBehind.length() - 1;
9432
	String expectedCompletionNodeToString = "<NONE>";
9433
	String expectedParentNodeToString = "<NONE>";
9434
	String completionIdentifier = "<NONE>";
9435
	String expectedReplacedSource = "<NONE>";
9436
	String expectedUnitDisplayString =
9437
		"public class X {\n" + 
9438
		"  public X() {\n" + 
9439
		"  }\n" + 
9440
		"  public boolean foo() {\n" + 
9441
		"  }\n" + 
9442
		"}\n";
9443
9444
	checkDietParse(
9445
			str.toCharArray(),
9446
			cursorLocation,
9447
			expectedCompletionNodeToString,
9448
			expectedParentNodeToString,
9449
			expectedUnitDisplayString,
9450
			completionIdentifier,
9451
			expectedReplacedSource,
9452
	"diet ast");
9453
	
9454
	expectedCompletionNodeToString = "<CompleteOnException:IZZ>";
9455
	expectedParentNodeToString =
9456
		"try \n" + 
9457
		"  {\n" + 
9458
		"    throwing();\n" + 
9459
		"  }\n" + 
9460
		"catch (IllegalAccessException e)   {\n" + 
9461
		"  }\n" + 
9462
		"catch (<CompleteOnException:IZZ>  )   {\n" + 
9463
		"  }";
9464
	completionIdentifier = "IZZ";
9465
	expectedReplacedSource = "IZZ";
9466
	expectedUnitDisplayString =
9467
		"public class X {\n" + 
9468
		"  public X() {\n" + 
9469
		"  }\n" + 
9470
		"  public boolean foo() {\n" + 
9471
		"    try \n" + 
9472
		"      {\n" + 
9473
		"        throwing();\n" + 
9474
		"      }\n" + 
9475
		"    catch (IllegalAccessException e)       {\n" + 
9476
		"      }\n" + 
9477
		"    catch (<CompleteOnException:IZZ>  )       {\n" + 
9478
		"      }\n" + 
9479
		"  }\n" + 
9480
		"}\n";
9481
9482
	checkMethodParse(
9483
			str.toCharArray(),
9484
			cursorLocation,
9485
			expectedCompletionNodeToString,
9486
			expectedParentNodeToString,
9487
			expectedUnitDisplayString,
9488
			completionIdentifier,
9489
			expectedReplacedSource,
9490
			"full ast");
9491
}
9492
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
9493
public void test0169() {
9494
9495
	String str = 
9496
		"public class X {\n" +
9497
		"	public boolean foo() {\n" +
9498
		"      try {\n" +
9499
		"         throwing();\n" +
9500
		"      }\n" +
9501
		"      catch (IllegalAccessException e) {\n" +
9502
		"         bar()\n" +
9503
		"      }\n" +
9504
		"      catch (IZZ) {\n" +
9505
		"      }\n" +
9506
		"   }" +
9507
		"}\n"; 
9508
9509
	String completeBehind = "IZZ";
9510
	int cursorLocation = str.lastIndexOf("IZZ") + completeBehind.length() - 1;
9511
	String expectedCompletionNodeToString = "<NONE>";
9512
	String expectedParentNodeToString = "<NONE>";
9513
	String completionIdentifier = "<NONE>";
9514
	String expectedReplacedSource = "<NONE>";
9515
	String expectedUnitDisplayString =
9516
		"public class X {\n" + 
9517
		"  public X() {\n" + 
9518
		"  }\n" + 
9519
		"  public boolean foo() {\n" + 
9520
		"  }\n" + 
9521
		"}\n";
9522
9523
	checkDietParse(
9524
			str.toCharArray(),
9525
			cursorLocation,
9526
			expectedCompletionNodeToString,
9527
			expectedParentNodeToString,
9528
			expectedUnitDisplayString,
9529
			completionIdentifier,
9530
			expectedReplacedSource,
9531
	"diet ast");
9532
	
9533
	expectedCompletionNodeToString = "<CompleteOnException:IZZ>";
9534
	expectedParentNodeToString = "<NONE>";
9535
	completionIdentifier = "IZZ";
9536
	expectedReplacedSource = "IZZ";
9537
	expectedUnitDisplayString =
9538
		"public class X {\n" + 
9539
		"  public X() {\n" + 
9540
		"  }\n" + 
9541
		"  public boolean foo() {\n" + 
9542
		"    <CompleteOnException:IZZ>;\n" + 
9543
		"  }\n" + 
9544
		"}\n";
9545
9546
	checkMethodParse(
9547
			str.toCharArray(),
9548
			cursorLocation,
9549
			expectedCompletionNodeToString,
9550
			expectedParentNodeToString,
9551
			expectedUnitDisplayString,
9552
			completionIdentifier,
9553
			expectedReplacedSource,
9554
			"full ast");
9555
}
9556
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
9557
public void test0170() {
9558
9559
	String str = 
9560
		"public class X {\n" +
9561
		"	public boolean foo() {\n" +
9562
		"      #\n" +
9563
		"      try {\n" +
9564
		"         throwing();\n" +
9565
		"      }\n" +
9566
		"      catch (IllegalAccessException e) {\n" +
9567
		"         bar();\n" +
9568
		"      }\n" +
9569
		"      catch (IZZ) {\n" +
9570
		"      }\n" +
9571
		"   }" +
9572
		"}\n"; 
9573
9574
	String completeBehind = "IZZ";
9575
	int cursorLocation = str.lastIndexOf("IZZ") + completeBehind.length() - 1;
9576
	String expectedCompletionNodeToString = "<NONE>";
9577
	String expectedParentNodeToString = "<NONE>";
9578
	String completionIdentifier = "<NONE>";
9579
	String expectedReplacedSource = "<NONE>";
9580
	String expectedUnitDisplayString =
9581
		"public class X {\n" + 
9582
		"  public X() {\n" + 
9583
		"  }\n" + 
9584
		"  public boolean foo() {\n" + 
9585
		"  }\n" + 
9586
		"}\n";
9587
9588
	checkDietParse(
9589
			str.toCharArray(),
9590
			cursorLocation,
9591
			expectedCompletionNodeToString,
9592
			expectedParentNodeToString,
9593
			expectedUnitDisplayString,
9594
			completionIdentifier,
9595
			expectedReplacedSource,
9596
	"diet ast");
9597
	
9598
	expectedCompletionNodeToString = "<CompleteOnException:IZZ>";
9599
	expectedParentNodeToString = "<NONE>";
9600
	completionIdentifier = "IZZ";
9601
	expectedReplacedSource = "IZZ";
9602
	expectedUnitDisplayString =
9603
		"public class X {\n" + 
9604
		"  public X() {\n" + 
9605
		"  }\n" + 
9606
		"  public boolean foo() {\n" + 
9607
		"    <CompleteOnException:IZZ>;\n" + 
9608
		"  }\n" + 
9609
		"}\n";
9610
9611
	checkMethodParse(
9612
			str.toCharArray(),
9613
			cursorLocation,
9614
			expectedCompletionNodeToString,
9615
			expectedParentNodeToString,
9616
			expectedUnitDisplayString,
9617
			completionIdentifier,
9618
			expectedReplacedSource,
9619
			"full ast");
9620
}
9621
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
9622
public void test0171() {
9623
9624
	String str = 
9625
		"public class X {\n" +
9626
		"	public boolean foo() {\n" +
9627
		"      try {\n" +
9628
		"         throwing();\n" +
9629
		"      }\n" +
9630
		"      catch (IZZ) {\n" +
9631
		"      }\n" +
9632
		"   }" +
9633
		"}\n"; 
9634
9635
	String completeBehind = "IZZ";
9636
	int cursorLocation = str.lastIndexOf("IZZ") + completeBehind.length() - 1;
9637
	String expectedCompletionNodeToString = "<NONE>";
9638
	String expectedParentNodeToString = "<NONE>";
9639
	String completionIdentifier = "<NONE>";
9640
	String expectedReplacedSource = "<NONE>";
9641
	String expectedUnitDisplayString =
9642
		"public class X {\n" + 
9643
		"  public X() {\n" + 
9644
		"  }\n" + 
9645
		"  public boolean foo() {\n" + 
9646
		"  }\n" + 
9647
		"}\n";
9648
9649
	checkDietParse(
9650
			str.toCharArray(),
9651
			cursorLocation,
9652
			expectedCompletionNodeToString,
9653
			expectedParentNodeToString,
9654
			expectedUnitDisplayString,
9655
			completionIdentifier,
9656
			expectedReplacedSource,
9657
	"diet ast");
9658
	
9659
	expectedCompletionNodeToString = "<CompleteOnException:IZZ>";
9660
	expectedParentNodeToString =
9661
		"try \n" + 
9662
		"  {\n" + 
9663
		"    throwing();\n" + 
9664
		"  }\n" + 
9665
		"catch (<CompleteOnException:IZZ>  )   {\n" + 
9666
		"  }"
9667
;
9668
	completionIdentifier = "IZZ";
9669
	expectedReplacedSource = "IZZ";
9670
	expectedUnitDisplayString =
9671
		"public class X {\n" + 
9672
		"  public X() {\n" + 
9673
		"  }\n" + 
9674
		"  public boolean foo() {\n" + 
9675
		"    try \n" + 
9676
		"      {\n" + 
9677
		"        throwing();\n" + 
9678
		"      }\n" + 
9679
		"    catch (<CompleteOnException:IZZ>  )       {\n" + 
9680
		"      }\n" + 
9681
		"  }\n" + 
9682
		"}\n";
9683
9684
	checkMethodParse(
9685
			str.toCharArray(),
9686
			cursorLocation,
9687
			expectedCompletionNodeToString,
9688
			expectedParentNodeToString,
9689
			expectedUnitDisplayString,
9690
			completionIdentifier,
9691
			expectedReplacedSource,
9692
			"full ast");
9693
}
9335
}
9694
}
(-)src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java (-4 / +101 lines)
Lines 1742-1748 Link Here
1742
	"diet ast");
1742
	"diet ast");
1743
	
1743
	
1744
	expectedCompletionNodeToString = "<CompleteOnException:Y<Z>.>";
1744
	expectedCompletionNodeToString = "<CompleteOnException:Y<Z>.>";
1745
	expectedParentNodeToString = "<NONE>";
1745
	expectedParentNodeToString =
1746
		"try \n" + 
1747
		"  {\n" + 
1748
		"  }\n" + 
1749
		"catch (<CompleteOnException:Y<Z>.>  )   {\n" + 
1750
		"  }";
1746
	completionIdentifier = "";
1751
	completionIdentifier = "";
1747
	expectedReplacedSource = "Y<Z>.";
1752
	expectedReplacedSource = "Y<Z>.";
1748
	expectedUnitDisplayString =
1753
	expectedUnitDisplayString =
Lines 1750-1756 Link Here
1750
		"  public X() {\n" + 
1755
		"  public X() {\n" + 
1751
		"  }\n" + 
1756
		"  }\n" + 
1752
		"  void foo() {\n" + 
1757
		"  void foo() {\n" + 
1753
		"    <CompleteOnException:Y<Z>.>;\n" + 
1758
		"    try \n" + 
1759
		"      {\n" + 
1760
		"      }\n" + 
1761
		"    catch (<CompleteOnException:Y<Z>.>  )       {\n" + 
1762
		"      }\n" + 
1754
		"  }\n" + 
1763
		"  }\n" + 
1755
		"}\n";
1764
		"}\n";
1756
1765
Lines 1799-1805 Link Here
1799
	"diet ast");
1808
	"diet ast");
1800
	
1809
	
1801
	expectedCompletionNodeToString = "<CompleteOnException:Y<Z>.>";
1810
	expectedCompletionNodeToString = "<CompleteOnException:Y<Z>.>";
1802
	expectedParentNodeToString = "<NONE>";
1811
	expectedParentNodeToString = 
1812
		"try \n" + 
1813
		"  {\n" + 
1814
		"  }\n" + 
1815
		"catch (<CompleteOnException:Y<Z>.>  )   {\n" + 
1816
		"  }";
1803
	completionIdentifier = "";
1817
	completionIdentifier = "";
1804
	expectedReplacedSource = "Y<Z>.";
1818
	expectedReplacedSource = "Y<Z>.";
1805
	expectedUnitDisplayString =
1819
	expectedUnitDisplayString =
Lines 1807-1813 Link Here
1807
		"  public X() {\n" + 
1821
		"  public X() {\n" + 
1808
		"  }\n" + 
1822
		"  }\n" + 
1809
		"  void foo() {\n" + 
1823
		"  void foo() {\n" + 
1810
		"    <CompleteOnException:Y<Z>.>;\n" + 
1824
		"    try \n" + 
1825
		"      {\n" + 
1826
		"      }\n" + 
1827
		"    catch (<CompleteOnException:Y<Z>.>  )       {\n" + 
1828
		"      }\n" + 
1811
		"  }\n" + 
1829
		"  }\n" + 
1812
		"}\n";
1830
		"}\n";
1813
1831
Lines 9422-9425 Link Here
9422
			expectedReplacedSource,
9440
			expectedReplacedSource,
9423
	"diet ast");
9441
	"diet ast");
9424
}
9442
}
9443
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=157584
9444
public void test0213() {
9445
9446
	String str = 
9447
		"public class X {\n" +
9448
		"	public boolean foo() {\n" +
9449
		"      try {\n" +
9450
		"         throwing();\n" +
9451
		"      }\n" +
9452
		"      catch (IllegalAccessException e) {\n" +
9453
		"         bar();\n" +
9454
		"      }\n" +
9455
		"      catch (Top<Object>.IZZ) {\n" +
9456
		"      }\n" +
9457
		"   }" +
9458
		"}\n"; 
9459
9460
	String completeBehind = "IZZ";
9461
	int cursorLocation = str.lastIndexOf("IZZ") + completeBehind.length() - 1;
9462
	String expectedCompletionNodeToString = "<NONE>";
9463
	String expectedParentNodeToString = "<NONE>";
9464
	String completionIdentifier = "<NONE>";
9465
	String expectedReplacedSource = "<NONE>";
9466
	String expectedUnitDisplayString =
9467
		"public class X {\n" + 
9468
		"  public X() {\n" + 
9469
		"  }\n" + 
9470
		"  public boolean foo() {\n" + 
9471
		"  }\n" + 
9472
		"}\n";
9473
9474
	checkDietParse(
9475
			str.toCharArray(),
9476
			cursorLocation,
9477
			expectedCompletionNodeToString,
9478
			expectedParentNodeToString,
9479
			expectedUnitDisplayString,
9480
			completionIdentifier,
9481
			expectedReplacedSource,
9482
	"diet ast");
9483
	
9484
	expectedCompletionNodeToString = "<CompleteOnException:Top<Object>.IZZ>";
9485
	expectedParentNodeToString =
9486
		"try \n" + 
9487
		"  {\n" + 
9488
		"    throwing();\n" + 
9489
		"  }\n" + 
9490
		"catch (IllegalAccessException e)   {\n" + 
9491
		"  }\n" + 
9492
		"catch (<CompleteOnException:Top<Object>.IZZ>  )   {\n" + 
9493
		"  }";
9494
	completionIdentifier = "IZZ";
9495
	expectedReplacedSource = "Top<Object>.IZZ";
9496
	expectedUnitDisplayString =
9497
		"public class X {\n" + 
9498
		"  public X() {\n" + 
9499
		"  }\n" + 
9500
		"  public boolean foo() {\n" + 
9501
		"    try \n" + 
9502
		"      {\n" + 
9503
		"        throwing();\n" + 
9504
		"      }\n" + 
9505
		"    catch (IllegalAccessException e)       {\n" + 
9506
		"      }\n" + 
9507
		"    catch (<CompleteOnException:Top<Object>.IZZ>  )       {\n" + 
9508
		"      }\n" + 
9509
		"  }\n" + 
9510
		"}\n";
9511
9512
	checkMethodParse(
9513
			str.toCharArray(),
9514
			cursorLocation,
9515
			expectedCompletionNodeToString,
9516
			expectedParentNodeToString,
9517
			expectedUnitDisplayString,
9518
			completionIdentifier,
9519
			expectedReplacedSource,
9520
			"full ast");
9521
}
9425
}
9522
}
(-)src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java (-1 / +6 lines)
Lines 1587-1593 Link Here
1587
		"  public EA() {\n" + 
1587
		"  public EA() {\n" + 
1588
		"  }\n" + 
1588
		"  }\n" + 
1589
		"  void foo() {\n" + 
1589
		"  void foo() {\n" + 
1590
		"    <CompleteOnException:E>;\n" + 
1590
		"    try \n" + 
1591
		"      {\n" + 
1592
		"        throw new Error();\n" + 
1593
		"      }\n" + 
1594
		"    catch (<CompleteOnException:E>  )       {\n" + 
1595
		"      }\n" + 
1591
		"  }\n" + 
1596
		"  }\n" + 
1592
		"}\n";
1597
		"}\n";
1593
1598
(-)src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceTypeCompletionTest.java (-6 / +21 lines)
Lines 153-160 Link Here
153
		"class Bar {\n" + 
153
		"class Bar {\n" + 
154
		"  Bar() {\n" + 
154
		"  Bar() {\n" + 
155
		"  }\n" + 
155
		"  }\n" + 
156
		"  void foo() {\n" +
156
		"  void foo() {\n" + 
157
		"    <CompleteOnException:X>;\n" + 
157
		"    try \n" + 
158
		"      {\n" + 
159
		"        fred();\n" + 
160
		"      }\n" + 
161
		"    catch (<CompleteOnException:X>  )       {\n" + 
162
		"      }\n" + 
158
		"  }\n" + 
163
		"  }\n" + 
159
		"}\n",
164
		"}\n",
160
		// expectedCompletionIdentifier:
165
		// expectedCompletionIdentifier:
Lines 187-194 Link Here
187
		"class Bar {\n" + 
192
		"class Bar {\n" + 
188
		"  Bar() {\n" + 
193
		"  Bar() {\n" + 
189
		"  }\n" + 
194
		"  }\n" + 
190
		"  void foo() {\n" +
195
		"  void foo() {\n" + 
191
		"    <CompleteOnException:X>;\n" + 
196
		"    try \n" + 
197
		"      {\n" + 
198
		"        fred();\n" + 
199
		"      }\n" + 
200
		"    catch (<CompleteOnException:X>  )       {\n" + 
201
		"      }\n" + 
192
		"  }\n" + 
202
		"  }\n" + 
193
		"}\n",
203
		"}\n",
194
		// expectedCompletionIdentifier:
204
		// expectedCompletionIdentifier:
Lines 221-228 Link Here
221
		"class Bar {\n" + 
231
		"class Bar {\n" + 
222
		"  Bar() {\n" + 
232
		"  Bar() {\n" + 
223
		"  }\n" + 
233
		"  }\n" + 
224
		"  void foo() {\n" +
234
		"  void foo() {\n" + 
225
		"    <CompleteOnException:x.y.X>;\n" + 
235
		"    try \n" + 
236
		"      {\n" + 
237
		"        fred();\n" + 
238
		"      }\n" + 
239
		"    catch (<CompleteOnException:x.y.X>  )       {\n" + 
240
		"      }\n" + 
226
		"  }\n" + 
241
		"  }\n" + 
227
		"}\n",
242
		"}\n",
228
		// expectedCompletionIdentifier:
243
		// expectedCompletionIdentifier:

Return to bug 157584