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 in-memory source code for diagnostic printing #217

Merged
merged 5 commits into from
Oct 15, 2020

Conversation

georgejecook
Copy link
Contributor

@georgejecook georgejecook commented Oct 14, 2020

improves diagnostic printing, by going to program to retrieve file contents, and allowing in-memory files to be used, not failing when there is no content, and improving efficiency

…ntents, and allowing in-memory files to be used, not failing when there is no content, and improving efficiency
@TwitchBronBron TwitchBronBron changed the title improves diagnostic printing, by going to program to retrieve file co… Use in-memory source code for diagnostic printing Oct 15, 2020
let severity = typeof diagnostic.severity === 'number' ? diagnostic.severity : DiagnosticSeverity.Error;
//format output
printDiagnostic(options, severity, filePath, lines, diagnostic);
try {
Copy link
Member

Choose a reason for hiding this comment

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

We should not be wrapping and then throwing away any runtime exceptions that happen here...that would cause even more confusion for plugin authors and developers because there wouldn't even be runtime error messages or stack traces if something went wrong.

//load the file text
let fileText = await util.getFileContents(pathAbsolute);
let lines = util.getLines(fileText);
const file = this.program.getFileByPathAbsolute(pathAbsolute);
Copy link
Member

Choose a reason for hiding this comment

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

This loads the file contents from the in-memory BrsFile/XmlFile. Previously the contents were being loaded from disk, which does not work for in-memory-only files injected by plugins.

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.

2 participants