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

Use els_utils:lookup_document for lookup #930

Merged
merged 3 commits into from
Mar 4, 2021

Conversation

sgillis
Copy link
Contributor

@sgillis sgillis commented Mar 1, 2021

Description

Use els_utils:lookup_document for document lookups to make sure that files that were not yet indexed are indexed on request. Related to #881

Fixes #928

@sgillis sgillis changed the title Use els_utils:lookup_document for lookup #928 Use els_utils:lookup_document for lookup Mar 1, 2021
Copy link
Contributor

@gomoripeti gomoripeti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks a lot

Copy link
Member

@robertoaloi robertoaloi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Even if in principle this makes sense, I am a bit worried about what would happen in case the project is misconfigured (which can happen often among new users). This change would cause crashes, which would result in providers stopping and the server malfunctioning. See comments below for a possible solution.

?LOG_WARNING("Failed lookup while expanding includes [uri=~p]", [Uri]),
[]
end.
{ok, Document} = els_utils:lookup_document(Uri),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen if the included path is incorrect or if it does not exist yet? Or, more likely, if the current project is not configured correctly, so the included file is not found? That could cause the provider to crash, right?

?LOG_INFO("Lookup failed [Error=~p]", [Error]),
[]
end.
{ok, Document} = els_utils:lookup_document(Uri),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. If a project is misconfigured, some dependencies will not be found and a hard pattern match here would result in a less stable server. Maybe we want to modify the els_utils:lookup_document/1 so that if it fails after indexing it returns an error and keep the case in the callers?

@sgillis
Copy link
Contributor Author

sgillis commented Mar 3, 2021

@robertoaloi Makes sense, I'll change that.

@robertoaloi
Copy link
Member

Nice, thanks!

@robertoaloi robertoaloi merged commit 209b68f into erlang-ls:main Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot find definition for functions defined in OTP
3 participants