Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record type locations for definition files types (AstDeclaredClassProp and AstStatDeclareFunction) #1137

Open
JohnnyMorganz opened this issue Dec 26, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@JohnnyMorganz
Copy link
Contributor

Props in AstStatDeclareClass currently do not record their typeLocations in the property type created, like AstTypeTables do (following on from #802):

if (assignTo.count(propName) == 0)
{
assignTo[propName] = {propTy};
}
else
{
TypeId currentTy = assignTo[propName].type();
// We special-case this logic to keep the intersection flat; otherwise we
// would create a ton of nested intersection types.
if (const IntersectionType* itv = get<IntersectionType>(currentTy))
{
std::vector<TypeId> options = itv->parts;
options.push_back(propTy);
TypeId newItv = addType(IntersectionType{std::move(options)});
assignTo[propName] = {newItv};
}
else if (get<FunctionType>(currentTy))
{
TypeId intersection = addType(IntersectionType{{currentTy, propTy}});
assignTo[propName] = {intersection};
}

It seems that there is no position stored in the Ast for AstDeclaredClassProp, so that will need to be added first.

Likewise, the FunctionType produced via AstStatDeclareFunction does not record a FunctionDefinition:

TypeId fnType = addType(FunctionType{funScope->level, std::move(genericTys), std::move(genericTps), argPack, retPack});

These missing locations makes it difficult to find the location in a definitions file where these types are declared. These locations are useful to power Go To Definition functionality and documentation comments inlined in definitions files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant