class AmbiguousName extends Object
x.y.z a.b.c()Clearly, z is a field and c is a method. But what about x.y and a.b ? x could be a package name and y a type, making for a (static) class field selection. Or, x could be a local variable and y an instance field. The parser cannot know how to parse these. Disambiguating the ambiguity must wait until analysis time. The parser can, with x.y.z, treat the .z as a field selection, but constructs an AmbiguousName object encapsulating the x.y . And it can, with a.b.c(), treat the .c() as a message expression, but constructs an AbiguousName object encapsulating a.b. reclassify() is called upon in JFieldSelection.analyze() and JMessageExpression.analyze() to reclassify the components and construct the proper ast, following the rules for names in the Java language Specification (Third Edition), section 6.5.2. In j--, both x.y and a.b are clearly expressions in these contexts. If inner types were to be introduced, their meaning and their reclassification would necessarily be more complicated.
Constructor and Description |
---|
AmbiguousName(int line,
String name)
Construct an encapsulation of the ambiguous portion of a snippet like
x.y.z.
|
Modifier and Type | Method and Description |
---|---|
JExpression |
reclassify(Context context)
Reclassify the name according to the rules in the Java Language
Specification.
|
public AmbiguousName(int line, String name)
line
- line in which the ambiguous name occurs in the source file.name
- the ambiguous part.public JExpression reclassify(Context context)
context
- context in which we look up the component names.