Lines 107-117
Link Here
|
107 |
protected TypeReference createTypeReference( |
107 |
protected TypeReference createTypeReference( |
108 |
char[] typeName, |
108 |
char[] typeName, |
109 |
int start, |
109 |
int start, |
|
|
110 |
int end, |
111 |
boolean includeGenericsAnyway) { |
112 |
|
113 |
int length = typeName.length; |
114 |
this.namePos = 0; |
115 |
return decodeType(typeName, length, start, end, true); |
116 |
} |
117 |
|
118 |
/* |
119 |
* Build a type reference from a readable name, e.g. java.lang.Object[][] |
120 |
*/ |
121 |
protected TypeReference createTypeReference( |
122 |
char[] typeName, |
123 |
int start, |
110 |
int end) { |
124 |
int end) { |
111 |
|
125 |
|
112 |
int length = typeName.length; |
126 |
int length = typeName.length; |
113 |
this.namePos = 0; |
127 |
this.namePos = 0; |
114 |
return decodeType(typeName, length, start, end); |
128 |
return decodeType(typeName, length, start, end, false); |
115 |
} |
129 |
} |
116 |
|
130 |
|
117 |
/* |
131 |
/* |
Lines 351-357
Link Here
|
351 |
} |
365 |
} |
352 |
} |
366 |
} |
353 |
|
367 |
|
354 |
private TypeReference decodeType(char[] typeName, int length, int start, int end) { |
368 |
private TypeReference decodeType(char[] typeName, int length, int start, int end, boolean includeGenericsAnyway) { |
355 |
int identCount = 1; |
369 |
int identCount = 1; |
356 |
int dim = 0; |
370 |
int dim = 0; |
357 |
int nameFragmentStart = this.namePos, nameFragmentEnd = -1; |
371 |
int nameFragmentStart = this.namePos, nameFragmentEnd = -1; |
Lines 373-379
Link Here
|
373 |
} |
387 |
} |
374 |
this.namePos += max; |
388 |
this.namePos += max; |
375 |
Wildcard result = new Wildcard(Wildcard.SUPER); |
389 |
Wildcard result = new Wildcard(Wildcard.SUPER); |
376 |
result.bound = decodeType(typeName, length, start, end); |
390 |
result.bound = decodeType(typeName, length, start, end, includeGenericsAnyway); |
377 |
result.sourceStart = start; |
391 |
result.sourceStart = start; |
378 |
result.sourceEnd = end; |
392 |
result.sourceEnd = end; |
379 |
return result; |
393 |
return result; |
Lines 389-395
Link Here
|
389 |
} |
403 |
} |
390 |
this.namePos += max; |
404 |
this.namePos += max; |
391 |
Wildcard result = new Wildcard(Wildcard.EXTENDS); |
405 |
Wildcard result = new Wildcard(Wildcard.EXTENDS); |
392 |
result.bound = decodeType(typeName, length, start, end); |
406 |
result.bound = decodeType(typeName, length, start, end, includeGenericsAnyway); |
393 |
result.sourceStart = start; |
407 |
result.sourceStart = start; |
394 |
result.sourceEnd = end; |
408 |
result.sourceEnd = end; |
395 |
return result; |
409 |
return result; |
Lines 414-436
Link Here
|
414 |
identCount ++; |
428 |
identCount ++; |
415 |
break; |
429 |
break; |
416 |
case '<' : |
430 |
case '<' : |
417 |
/* We need to convert and preserve 1.5 specific constructs only if compliance is 1.5 or above, |
431 |
/* We need to convert and preserve 1.5 specific constructs either if compliance is 1.5 or above, |
418 |
but in all cases, we must skip over them to see if there are any applicable type fragments |
432 |
or the caller has explicitly requested generics to be included. The parameter includeGenericsAnyway |
419 |
after the type parameters: i.e we just aren't done having seen a '<' in 1.4 mode. Because of |
433 |
should be used by the caller to signal that in the calling context generics information must be |
420 |
the way type signatures are encoded, TypeConverter.decodeType(String, int, int, int) is immune |
434 |
internalized even when the requesting project is 1.4. But in all cases, we must skip over them to |
|
|
435 |
see if there are any applicable type fragments after the type parameters: i.e we just aren't done |
436 |
having seen a '<' in 1.4 mode. |
437 |
|
438 |
Because of the way type signatures are encoded, TypeConverter.decodeType(String, int, int, int) is immune |
421 |
to this problem. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=325633 |
439 |
to this problem. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=325633 |
422 |
*/ |
440 |
*/ |
423 |
if (this.has1_5Compliance) { |
441 |
if (this.has1_5Compliance || includeGenericsAnyway) { |
424 |
if (fragments == null) fragments = new ArrayList(2); |
442 |
if (fragments == null) fragments = new ArrayList(2); |
425 |
} |
443 |
} |
426 |
nameFragmentEnd = this.namePos-1; |
444 |
nameFragmentEnd = this.namePos-1; |
427 |
if (this.has1_5Compliance) { |
445 |
if (this.has1_5Compliance || includeGenericsAnyway) { |
428 |
char[][] identifiers = CharOperation.splitOn('.', typeName, nameFragmentStart, this.namePos); |
446 |
char[][] identifiers = CharOperation.splitOn('.', typeName, nameFragmentStart, this.namePos); |
429 |
fragments.add(identifiers); |
447 |
fragments.add(identifiers); |
430 |
} |
448 |
} |
431 |
this.namePos++; // skip '<' |
449 |
this.namePos++; // skip '<' |
432 |
TypeReference[] arguments = decodeTypeArguments(typeName, length, start, end); // positionned on '>' at end |
450 |
TypeReference[] arguments = decodeTypeArguments(typeName, length, start, end, includeGenericsAnyway); // positionned on '>' at end |
433 |
if (this.has1_5Compliance) { |
451 |
if (this.has1_5Compliance || includeGenericsAnyway) { |
434 |
fragments.add(arguments); |
452 |
fragments.add(arguments); |
435 |
identCount = 0; |
453 |
identCount = 0; |
436 |
nameFragmentStart = -1; |
454 |
nameFragmentStart = -1; |
Lines 519-529
Link Here
|
519 |
} |
537 |
} |
520 |
} |
538 |
} |
521 |
|
539 |
|
522 |
private TypeReference[] decodeTypeArguments(char[] typeName, int length, int start, int end) { |
540 |
private TypeReference[] decodeTypeArguments(char[] typeName, int length, int start, int end, boolean includeGenericsAnyway) { |
523 |
ArrayList argumentList = new ArrayList(1); |
541 |
ArrayList argumentList = new ArrayList(1); |
524 |
int count = 0; |
542 |
int count = 0; |
525 |
argumentsLoop: while (this.namePos < length) { |
543 |
argumentsLoop: while (this.namePos < length) { |
526 |
TypeReference argument = decodeType(typeName, length, start, end); |
544 |
TypeReference argument = decodeType(typeName, length, start, end, includeGenericsAnyway); |
527 |
count++; |
545 |
count++; |
528 |
argumentList.add(argument); |
546 |
argumentList.add(argument); |
529 |
if (this.namePos >= length) break argumentsLoop; |
547 |
if (this.namePos >= length) break argumentsLoop; |