Introduce specific `Name` type
ryangjchandler opened this issue · 1 comments
Right now, we use SimpleIdentifier
for basically everything that is "named", e.g:
- Named arguments.
- Structure names.
- Function names.
- Labels
- Declare statements
This was a good way of getting things to work, but now that I'm trying to do more complicated things I'd like to introduce a new Name
type. The difference between a Name
and SimpleIdentifier
is where they're used.
Name
would be used for things like functions, classes, etc. The current IdentifierQualification
stuff would be moved away from SimpleIdentifier
and turned into NameQualification
.
This has been completed through various commits and PRs.
Essentially, anywhere a class or type name can appear is now an instance of Name
instead of SimpleIdentifier
. The parser does a little bit of extra work too, resolving names where possible.
Example of name resolution:
use Foo\Bar\Baz;
$baz = new Baz();
The new Baz()
part will have a target
field containing:
Name {
kind: NameKind::Resolved(ResolvedName {
resolved: "Foo\Bar\Baz",
original: "Baz"
}),
span: ...
}
Since the parser tracks use
statements, it can correctly resolve the Baz
part to the imported Foo\Bar\Baz
class.