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

Feature nullability #5400

Merged
merged 45 commits into from
Oct 11, 2022

Conversation

winstliu
Copy link
Contributor

@winstliu winstliu commented Oct 9, 2022

Note: I'm aware of #5276 and that the feature/ folder may well become obsolete in the near future.
Nevertheless, given there's no set timeline yet, I figure the sooner strict mode can be turned on globally, the better, and I also got to learn some new TypeScript tricks along the way (like type guards).

Note that none of these changes have been validated on an actual codebase.

A good chunk of the fixes fall into one of two buckets: a) simply explicitly returning undefined (or an empty array) when we have nothing to return to VS Code or b) reducing a has check on a Map followed by a get to just get and then a check against undefined.

Otherwise:

  • Significant refactoring around creating codelens for tests. Mostly removing helper methods and checking for things inline, where we have more context on whether something can be nullable or not.
  • For commands that need to act on active text editors, added various guards to make sure there is an active editor in the first place.
  • For autocomplete, pass the document that the initial autocomplete acted upon to afterInsert, to avoid race conditions where a) the active text editor changed, or b) the active text editor was closed between the time it took to insert the completion and call afterInsert.
  • Changed Process in processPicker from a class to an interface - there is still some manual casting needed when we add a finalized process to the array, but at least we're no longer creating invalid Process classes anymore.

Impact:
Brings strict errors down to 234 from 377 when compared to master @ 9336244.
(If we ignore tests, the number of violations goes down further to just 40, 27 of which are in folders I haven't looked at yet.)

Copy link
Member

@JoeRobich JoeRobich left a comment

Choose a reason for hiding this comment

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

You've made such great progress. Thanks for the contribution.

@@ -1188,17 +1188,20 @@
{
"command": "o.fixAll.solution",
"title": "Fix all occurrences of a code issue within solution",
"category": "OmniSharp"
"category": "OmniSharp",
"enablement": "editorFocus"
Copy link
Member

Choose a reason for hiding this comment

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

Thanks, this is a nice change.

@@ -119,18 +119,20 @@ export default class OmnisharpCompletionProvider extends AbstractProvider implem
return;
}

const responseLine = response.Line;
const responseColumn = response.Column;
const editor = window.visibleTextEditors.find(editor => editor.document === document);
Copy link
Member

Choose a reason for hiding this comment

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

This seems like a bug fix. Did you run into issues with this during development?

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 actually caught it via TS warning that window.activeTextEditor could be undefined! Though I can definitely see the bug occurring during normal development.

export async function reAnalyze(server: OmniSharpServer, request: any) {
return server.makeRequest<any>(protocol.Requests.ReAnalyze, request);
export async function reAnalyze(server: OmniSharpServer, request: protocol.ReAnalyzeRequest) {
return server.makeRequest<protocol.ReAnalyzeReponse>(protocol.Requests.ReAnalyze, request);
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for this fix.

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