258 |
|
|
259 |
public String toString() { return "ClassDoc{"+qualifiedTypeName()+"}"; } |
public String toString() { return "ClassDoc{"+qualifiedTypeName()+"}"; } |
260 |
|
|
261 |
|
public TypeVariable asTypeVariable() { return null; } |
262 |
|
|
263 |
public static ClassDocImpl createInstance(ClassDoc containingClass, |
public static ClassDocImpl createInstance(ClassDoc containingClass, |
264 |
PackageDoc containingPackage, |
PackageDoc containingPackage, |
285 |
final int STATE_STARC = 3; |
final int STATE_STARC = 3; |
286 |
|
|
287 |
int state=STATE_NORMAL; |
int state=STATE_NORMAL; |
288 |
|
int varLevel=0; |
289 |
char prev=0; |
char prev=0; |
290 |
for (int ndx=startIndex; ndx<=endIndex; ++ndx) { |
for (int ndx=startIndex; ndx<=endIndex; ++ndx) { |
291 |
char c=(ndx==endIndex)?10:source[ndx]; |
char c=(ndx==endIndex)?10:source[ndx]; |
292 |
|
boolean processWord=false; |
293 |
if (state==STATE_SLASHC) { |
if (state==STATE_SLASHC) { |
294 |
if (c=='\n') { |
if (c=='\n') { |
295 |
state=STATE_NORMAL; |
state=STATE_NORMAL; |
303 |
} |
} |
304 |
} |
} |
305 |
else { |
else { |
|
|
|
|
boolean processWord=false; |
|
|
|
|
306 |
if (c=='/' && prev=='/') { |
if (c=='/' && prev=='/') { |
307 |
state=STATE_SLASHC; |
state=STATE_SLASHC; |
308 |
c=0; |
c=0; |
315 |
word=word.substring(0,word.length()-1); |
word=word.substring(0,word.length()-1); |
316 |
processWord=true; |
processWord=true; |
317 |
} |
} |
318 |
else if (c=='{' || c==',' || Parser.WHITESPACE.indexOf(c)>=0) { |
else if (c=='<') |
319 |
|
{ |
320 |
|
++varLevel; |
321 |
|
word += c; |
322 |
|
} |
323 |
|
else if (c=='>') |
324 |
|
{ |
325 |
|
--varLevel; |
326 |
|
word += c; |
327 |
|
} |
328 |
|
else if (c=='{' || c==',' && varLevel == 0 || |
329 |
|
Parser.WHITESPACE.indexOf(c)>=0) { |
330 |
processWord=true; |
processWord=true; |
331 |
} |
} |
332 |
else { |
else { |
366 |
item=3; |
item=3; |
367 |
} |
} |
368 |
else if (item==1) { |
else if (item==1) { |
369 |
rc.setClass(word); |
int parameterIndex = word.indexOf("<"); |
370 |
|
if (parameterIndex == -1) |
371 |
|
rc.setClass(word); |
372 |
|
else |
373 |
|
{ |
374 |
|
rc.setClass(word.substring(0, parameterIndex)); |
375 |
|
parseTypeVariables(rc,word.substring(parameterIndex, |
376 |
|
word.length())); |
377 |
|
} |
378 |
} |
} |
379 |
else if (item==2) { |
else if (item==2) { |
380 |
//Debug.log(9,"setting baseclass of "+rc+" to "+word); |
//Debug.log(9,"setting baseclass of "+rc+" to "+word); |
381 |
superclassName=word; |
int parameterIndex = word.indexOf("<"); |
382 |
|
if (parameterIndex == -1) |
383 |
|
superclassName=word; |
384 |
|
else |
385 |
|
{ |
386 |
|
/* FIXME: Parse type parameters */ |
387 |
|
superclassName=word.substring(0,parameterIndex); |
388 |
|
} |
389 |
} |
} |
390 |
else if (item==3) { |
else if (item==3) { |
391 |
implementedInterfaces.add(word); |
int parameterIndex = word.indexOf("<"); |
392 |
|
if (parameterIndex == -1) |
393 |
|
implementedInterfaces.add(word); |
394 |
|
else |
395 |
|
{ |
396 |
|
/* FIXME: Parse type parameters */ |
397 |
|
implementedInterfaces.add(word.substring(0,parameterIndex)); |
398 |
|
} |
399 |
} |
} |
400 |
word=""; |
word=""; |
401 |
} |
} |
636 |
private MethodDoc[] unfilteredMethods; |
private MethodDoc[] unfilteredMethods; |
637 |
private ConstructorDoc[] filteredConstructors; |
private ConstructorDoc[] filteredConstructors; |
638 |
private ConstructorDoc[] unfilteredConstructors; |
private ConstructorDoc[] unfilteredConstructors; |
639 |
|
private TypeVariable[] typeParameters; |
640 |
|
|
641 |
private boolean resolved=false; |
private boolean resolved=false; |
642 |
|
|
1048 |
{ |
{ |
1049 |
return importStatementList; |
return importStatementList; |
1050 |
} |
} |
1051 |
|
|
1052 |
|
public TypeVariable[] typeParameters() |
1053 |
|
{ |
1054 |
|
return typeParameters; |
1055 |
|
} |
1056 |
|
|
1057 |
|
/** |
1058 |
|
* <p> |
1059 |
|
* Parses the type variables declared in the class definition. |
1060 |
|
* The syntax is: |
1061 |
|
* </p> |
1062 |
|
* <p> |
1063 |
|
* <dl> |
1064 |
|
* <dt>TypeParameters:</dt> |
1065 |
|
* <dd><code>< <em>TypeParameter</em> { <em>, TypeParameter }</code></dd> |
1066 |
|
* <dt>TypeParameter:</dt> |
1067 |
|
* <dd><code><em>Identifier</em> { <strong>extends</strong> <em>Bound</em> |
1068 |
|
* }</dd> |
1069 |
|
* <dt>Bound:</dt> |
1070 |
|
* <dd><code><em>Type</em>{<strong>&</strong> <em>Type</em> } </dd> |
1071 |
|
* </dl> |
1072 |
|
* |
1073 |
|
* @param rc the owning class. |
1074 |
|
* @param typeVariables the string to be parsed. |
1075 |
|
* @throws ParseException if parsing fails. |
1076 |
|
*/ |
1077 |
|
public static void parseTypeVariables(ClassDocImpl rc, |
1078 |
|
String typeVariables) |
1079 |
|
throws ParseException |
1080 |
|
{ |
1081 |
|
List parsedBounds = null; |
1082 |
|
StringTokenizer parameters = new StringTokenizer(typeVariables, |
1083 |
|
Parser.WHITESPACE + |
1084 |
|
"<>,"); |
1085 |
|
List variables = new ArrayList(); |
1086 |
|
while (parameters.hasMoreTokens()) |
1087 |
|
{ |
1088 |
|
String parameter = parameters.nextToken(); |
1089 |
|
StringTokenizer parts = new StringTokenizer(parameter, |
1090 |
|
Parser.WHITESPACE); |
1091 |
|
TypeVariableImpl variable = new TypeVariableImpl(rc.qualifiedName(), |
1092 |
|
parts.nextToken(),"", |
1093 |
|
rc); |
1094 |
|
if (parts.hasMoreTokens()) |
1095 |
|
{ |
1096 |
|
if (!parts.nextToken().equals("extends")) |
1097 |
|
throw new ParseException("Invalid type parameter: " + parameter); |
1098 |
|
StringTokenizer bounds = new StringTokenizer(parts.nextToken(), |
1099 |
|
Parser.WHITESPACE |
1100 |
|
+ "&"); |
1101 |
|
parsedBounds = new ArrayList(); |
1102 |
|
while (bounds.hasMoreTokens()) |
1103 |
|
{ |
1104 |
|
String bound = bounds.nextToken(); |
1105 |
|
int nameSep = bound.lastIndexOf("."); |
1106 |
|
String packageName = bound.substring(0, nameSep); |
1107 |
|
String boundName = bound.substring(nameSep, bound.length()); |
1108 |
|
parsedBounds.add(new TypeImpl(packageName,boundName,"")); |
1109 |
|
} |
1110 |
|
} |
1111 |
|
if (parsedBounds != null) |
1112 |
|
variable.setBounds(parsedBounds); |
1113 |
|
variables.add(variable); |
1114 |
|
} |
1115 |
|
rc.setTypeParameters(variables); |
1116 |
|
} |
1117 |
|
|
1118 |
|
/** |
1119 |
|
* Set the type parameters to the contents of the supplied list. |
1120 |
|
* |
1121 |
|
* @param variables a list of type parameters. |
1122 |
|
*/ |
1123 |
|
void setTypeParameters(List variables) |
1124 |
|
{ |
1125 |
|
typeParameters = |
1126 |
|
(TypeVariable[]) variables.toArray(new TypeVariable[variables.size()]); |
1127 |
|
} |
1128 |
|
|
1129 |
} |
} |
1130 |
|
|