Lines 11-19
Link Here
|
11 |
package org.eclipse.jdt.core.tests.compiler.parser; |
11 |
package org.eclipse.jdt.core.tests.compiler.parser; |
12 |
|
12 |
|
13 |
import java.util.Locale; |
13 |
import java.util.Locale; |
|
|
14 |
import java.util.Map; |
14 |
|
15 |
|
15 |
import junit.framework.Test; |
16 |
import junit.framework.Test; |
16 |
|
17 |
|
|
|
18 |
import org.eclipse.jdt.core.JavaCore; |
17 |
import org.eclipse.jdt.core.compiler.CategorizedProblem; |
19 |
import org.eclipse.jdt.core.compiler.CategorizedProblem; |
18 |
import org.eclipse.jdt.core.compiler.CharOperation; |
20 |
import org.eclipse.jdt.core.compiler.CharOperation; |
19 |
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest; |
21 |
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest; |
Lines 44-50
Link Here
|
44 |
this.source = source; |
46 |
this.source = source; |
45 |
} |
47 |
} |
46 |
static { |
48 |
static { |
47 |
// TESTS_NUMBERS = new int[] { 99662 }; |
49 |
TESTS_NUMBERS = new int[] { 81 }; |
48 |
} |
50 |
} |
49 |
public static Test suite() { |
51 |
public static Test suite() { |
50 |
return buildAllCompliancesTestSuite(SourceElementParserTest.class); |
52 |
return buildAllCompliancesTestSuite(SourceElementParserTest.class); |
Lines 227-233
Link Here
|
227 |
if (typeInfo.typeParameters != null) { |
229 |
if (typeInfo.typeParameters != null) { |
228 |
for (int i = 0, length = typeInfo.typeParameters.length; i < length; i++) { |
230 |
for (int i = 0, length = typeInfo.typeParameters.length; i < length; i++) { |
229 |
TypeParameterInfo typeParameterInfo = typeInfo.typeParameters[i]; |
231 |
TypeParameterInfo typeParameterInfo = typeInfo.typeParameters[i]; |
230 |
addTypeParameter(typeParameterInfo); |
232 |
addTypeParameterToType(typeParameterInfo); |
231 |
} |
233 |
} |
232 |
} |
234 |
} |
233 |
} |
235 |
} |
Lines 279-289
Link Here
|
279 |
if (methodInfo.typeParameters != null) { |
281 |
if (methodInfo.typeParameters != null) { |
280 |
for (int i = 0, length = methodInfo.typeParameters.length; i < length; i++) { |
282 |
for (int i = 0, length = methodInfo.typeParameters.length; i < length; i++) { |
281 |
TypeParameterInfo typeParameterInfo = methodInfo.typeParameters[i]; |
283 |
TypeParameterInfo typeParameterInfo = methodInfo.typeParameters[i]; |
282 |
addTypeParameter(typeParameterInfo); |
284 |
addTypeParameterToMethod(typeParameterInfo); |
283 |
} |
285 |
} |
284 |
} |
286 |
} |
285 |
} |
287 |
} |
286 |
public void addTypeParameter(TypeParameterInfo typeParameterInfo) { |
288 |
public void addTypeParameterToMethod(TypeParameterInfo typeParameterInfo) { |
287 |
if (this.currentMethod.typeParameterNames == null) { |
289 |
if (this.currentMethod.typeParameterNames == null) { |
288 |
this.currentMethod.typeParameterNames = new char[][] {typeParameterInfo.name}; |
290 |
this.currentMethod.typeParameterNames = new char[][] {typeParameterInfo.name}; |
289 |
this.currentMethod.typeParameterBounds = new char[][][] {typeParameterInfo.bounds}; |
291 |
this.currentMethod.typeParameterBounds = new char[][][] {typeParameterInfo.bounds}; |
Lines 295-300
Link Here
|
295 |
this.currentMethod.typeParameterBounds[length] = typeParameterInfo.bounds; |
297 |
this.currentMethod.typeParameterBounds[length] = typeParameterInfo.bounds; |
296 |
} |
298 |
} |
297 |
} |
299 |
} |
|
|
300 |
public void addTypeParameterToType(TypeParameterInfo typeParameterInfo) { |
301 |
if (this.currentType.typeParameterNames == null) { |
302 |
this.currentType.typeParameterNames = new char[][] {typeParameterInfo.name}; |
303 |
this.currentType.typeParameterBounds = new char[][][] {typeParameterInfo.bounds}; |
304 |
} else { |
305 |
int length = this.currentType.typeParameterNames.length; |
306 |
System.arraycopy(this.currentType.typeParameterNames, 0, this.currentType.typeParameterNames = new char[length+1][],0, length); |
307 |
this.currentMethod.typeParameterNames[length] = typeParameterInfo.name; |
308 |
System.arraycopy(this.currentType.typeParameterBounds, 0, this.currentType.typeParameterBounds = new char[length+1][][],0, length); |
309 |
this.currentType.typeParameterBounds[length] = typeParameterInfo.bounds; |
310 |
} |
311 |
} |
298 |
public void exitType(int declarationEnd) { |
312 |
public void exitType(int declarationEnd) { |
299 |
this.currentType.setDeclarationSourceEnd(declarationEnd); |
313 |
this.currentType.setDeclarationSourceEnd(declarationEnd); |
300 |
if (this.currentType.parent != null) { |
314 |
if (this.currentType.parent != null) { |
Lines 317-329
Link Here
|
317 |
public void fullParse(String s, String testName) { |
331 |
public void fullParse(String s, String testName) { |
318 |
this.fullParse(s, testName, false); |
332 |
this.fullParse(s, testName, false); |
319 |
} |
333 |
} |
320 |
public void fullParse(String s, String testName, boolean recordLocalDeclaration) { |
334 |
public void fullParse(String s, String testName, Map options) { |
|
|
335 |
this.fullParse(s, testName, false, options); |
336 |
} |
337 |
public void fullParse(String s, String testName, boolean recordLocalDeclaration, Map options) { |
321 |
this.source = s.toCharArray(); |
338 |
this.source = s.toCharArray(); |
322 |
reset(); |
339 |
reset(); |
323 |
SourceElementParser parser = |
340 |
SourceElementParser parser = |
324 |
new SourceElementParser( |
341 |
new SourceElementParser( |
325 |
this, new DefaultProblemFactory(Locale.getDefault()), |
342 |
this, new DefaultProblemFactory(Locale.getDefault()), |
326 |
new CompilerOptions(getCompilerOptions()), |
343 |
new CompilerOptions(options), |
327 |
recordLocalDeclaration/*don't record local declarations*/, |
344 |
recordLocalDeclaration/*don't record local declarations*/, |
328 |
true/*optimize string literals*/); |
345 |
true/*optimize string literals*/); |
329 |
|
346 |
|
Lines 331-336
Link Here
|
331 |
|
348 |
|
332 |
parser.parseCompilationUnit(sourceUnit, true, null); |
349 |
parser.parseCompilationUnit(sourceUnit, true, null); |
333 |
} |
350 |
} |
|
|
351 |
public void fullParse(String s, String testName, boolean recordLocalDeclaration) { |
352 |
this.fullParse(s, testName, recordLocalDeclaration, getCompilerOptions()); |
353 |
} |
334 |
public void reset() { |
354 |
public void reset() { |
335 |
this.currentType = null; |
355 |
this.currentType = null; |
336 |
this.currentMethod = null; |
356 |
this.currentMethod = null; |
Lines 5276-5279
Link Here
|
5276 |
expectedUnitToString, |
5296 |
expectedUnitToString, |
5277 |
this.currentType.toString()); |
5297 |
this.currentType.toString()); |
5278 |
} |
5298 |
} |
|
|
5299 |
public void test81() { |
5300 |
|
5301 |
Map options = getCompilerOptions(); |
5302 |
options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); |
5303 |
options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); |
5304 |
options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); |
5305 |
|
5306 |
String s = |
5307 |
"import java.util.Collection;\n" + |
5308 |
"\n" + |
5309 |
"public class X {\n" + |
5310 |
" public abstract class AbstractData {}\n" + |
5311 |
" \n" + |
5312 |
" public interface IScalarData<T extends AbstractData> {}\n" + |
5313 |
"\n" + |
5314 |
" private static interface ValueObjectPropertyIterator {\n" + |
5315 |
" public <T extends AbstractData> void iterateOnValueObjectProperty(IScalarData<T> scalarObject, T valueObject, Class<?> valueObjectType, final String name, final Class<?> scalarType) throws Exception;\n" + |
5316 |
" }\n" + |
5317 |
"\n" + |
5318 |
" private static <T extends AbstractData> void iterateOnValueObjectProperties(IScalarData<T> scalarObject, T valueObject, ValueObjectPropertyIterator valueObjectPropertyIterator) {}\n" + |
5319 |
" \n" + |
5320 |
" public static <T extends AbstractData> void loadScalarFromValueObject(IScalarData<T> scalarObject, T valueObject) {\n" + |
5321 |
" iterateOnValueObjectProperties(scalarObject, valueObject, new ValueObjectPropertyIterator() {\n" + |
5322 |
" public <T extends AbstractData> void iterateOnValueObjectProperty(IScalarData<T> scalarObject, T valueObject, Class<?> valueObjectType, String name, Class<?> scalarType) throws Exception {\n" + |
5323 |
" if (true) {\n" + |
5324 |
" if (true) {\n" + |
5325 |
" if (true) {\n" + |
5326 |
" final Collection<IScalarData<AbstractData>> lazyCollection = createLazyCollection(\n" + |
5327 |
" name, scalarType, null, null,\n" + |
5328 |
" new CollectionProviderForTargetCollection<IScalarData<AbstractData>>() {\n" + |
5329 |
" @Override\n" + |
5330 |
" public Collection<IScalarData<AbstractData>> provideCollection(\n" + |
5331 |
" final Collection<IScalarData<AbstractData> targetCollection, final Class<IScalarData<AbstractData>> scalarCollectionType) {\n" + |
5332 |
" return null;\n" + |
5333 |
" }\n" + |
5334 |
" });\n" + |
5335 |
" }\n" + |
5336 |
" }\n" + |
5337 |
" }\n" + |
5338 |
" }\n" + |
5339 |
"\n" + |
5340 |
" abstract class CollectionProviderForTargetCollection<S> {\n" + |
5341 |
" abstract public Collection<S> provideCollection(Collection<S> targetCollection, Class<S> scalarCollectionType);\n" + |
5342 |
" }\n" + |
5343 |
"\n" + |
5344 |
" private <S> Collection<S> createLazyCollection(String name,\n" + |
5345 |
" Class<?> scalarType, final Collection<AbstractData> valueObjectCollection,\n" + |
5346 |
" final Class<S> scalarCollectionType, CollectionProviderForTargetCollection<S> collectionProvider) {\n" + |
5347 |
" return null;\n" + |
5348 |
" }\n" + |
5349 |
" });\n" + |
5350 |
" }\n" + |
5351 |
"}"; |
5352 |
|
5353 |
String expectedUnitToString = |
5354 |
"import java.util.Collection;\n" + |
5355 |
"public class X {\n" + |
5356 |
" public abstract class AbstractData {\n" + |
5357 |
" java.lang.Object(0)\n" + |
5358 |
" }\n" + |
5359 |
" public interface IScalarData {\n" + |
5360 |
" }\n" + |
5361 |
" private static interface ValueObjectPropertyIterator {\n" + |
5362 |
" public void iterateOnValueObjectProperty(IScalarData<T> scalarObject, T valueObject, Class<?> valueObjectType, String name, Class<?> scalarType, ) throws Exception, {}\n" + |
5363 |
" }\n" + |
5364 |
" java.lang.Object(0)\n" + |
5365 |
" private static void iterateOnValueObjectProperties(IScalarData<T> scalarObject, T valueObject, ValueObjectPropertyIterator valueObjectPropertyIterator, ) {}\n" + |
5366 |
" public static void loadScalarFromValueObject(IScalarData<T> scalarObject, T valueObject, ) {}\n" + |
5367 |
"}"; |
5368 |
|
5369 |
String testName = "test81: full parse"; |
5370 |
fullParse(s,testName, options); |
5371 |
assertEquals( |
5372 |
"Invalid source " + testName, |
5373 |
expectedUnitToString, |
5374 |
this.currentType.toString()); |
5375 |
} |
5279 |
} |
5376 |
} |