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

Add more workshop features #1834

Merged
merged 2 commits into from
Apr 27, 2021
Merged

Add more workshop features #1834

merged 2 commits into from
Apr 27, 2021

Conversation

johnpryan
Copy link
Contributor

This adds more features for #1763:

  • analysis results
  • completions
  • doc panel
  • Hide UI Output in Dart mode
  • busy light
  • keyboard shortcuts
  • format button

A lot of the code here is grabbed from lib/playground.dart - need to look into sharing code for analysis and keyboard shortcuts.

- analysis results
- completions
- doc panel
- Hide UI Output in Dart mode
- busy light
- keyboard shortcuts
- format button
Copy link
Member

@srawlins srawlins left a comment

Choose a reason for hiding this comment

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

I love seeing Sass variables and stuff, so refreshing over basic CSS 😁

@@ -51,6 +60,12 @@ class CodelabUi {
MaterialTabController consolePanelTabController;
Counter unreadConsoleCounter;
Dialog dialog;
DocHandler docHandler;
Future _analysisRequest;
Copy link
Member

Choose a reason for hiding this comment

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

This is a 'raw type'; implicitly it is a Future<dynamic> which is probably not what we want. I'm not sure what the correct type is...


// Listen for changes that would effect the documentation panel.
editor.onMouseDown.listen((e) {
// Delay to give codemirror time to process the mouse event.
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, what might codemirror be doing such that we need to wait?

Copy link
Member

Choose a reason for hiding this comment

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

CodeMirror is quite the beast. It does a fair amount of DOM manipulation to achieve something that approximates an editor in a browser, IIUC.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code is copy pasted from playground.dart so I'm not sure, but I think this is a safeguard against getting the previous cursor position instead of the new one when _cursorPositionIsWhitespace() is called

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll de-dupe this code, though.

analysisResultsController = AnalysisResultsController(
DElement(querySelector('#issues')),
DElement(querySelector('#issues-message')),
DElement(querySelector('#issues-toggle')))
Copy link
Member

Choose a reason for hiding this comment

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

A trailing comma after the last DElement might make the next line more readable; might make it clearer what the ..onItemClicked is attached to, but I'm not sure.

var hasErrors = result.issues.any((issue) => issue.kind == 'error');
var hasWarnings = result.issues.any((issue) => issue.kind == 'warning');

return hasErrors == false && hasWarnings == false;
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, hasErrors and hasWarnings are not going to be null, right? So this could be return !hasErrors && !hasWarnings.

Or to possibly short circuit the warnings check, you could do

return !result.issues.any((issue) => issue.kind == 'error') &&
    !result.issues.any((issue) => issue.kind == 'warning');

@@ -330,6 +449,99 @@ class CodelabUi {
}
}

/// Perform static analysis of the source code. Return whether the code
/// analyzed cleanly (had no errors or warnings).
Future<bool> _performAnalysis() {
Copy link
Member

Choose a reason for hiding this comment

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

Are these 60 lines which handle an analyzer call duplicated from somewhere else? It seems like this would be very similar code to whatever is going on in playground, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it's very very similar, but not exactly the same

});
}

Future<void> _format() {
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, this seems like there should be opportunity to share this code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, let me see if we can set that up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

quick update, I'm going to follow up with this to make the review easier

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -23,6 +23,7 @@ dependencies:
yaml: ^2.2.0
checked_yaml: ^1.0.0
js: ^0.6.0
stream_transform: any
Copy link
Member

Choose a reason for hiding this comment

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

any chance of a min version?

@johnpryan johnpryan merged commit 5c16db3 into dart-lang:master Apr 27, 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.

3 participants