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 support for fix all in file & project-info #234

Merged
merged 3 commits into from
Feb 4, 2018

Conversation

ananthakumaran
Copy link
Owner

Related to microsoft/TypeScript#20338. Need typescript@next for testing.

@ananthakumaran ananthakumaran changed the title add support for fix all in file add support for fix all in file & project-info Jan 28, 2018
@josteink
Copy link
Collaborator

It's not clear from the description, but if I were to test this... Would the simplest way to do so, would be with a TS-file with multiple unused imorts (as per microsoft/TypeScript#14549)?

What other kinds of use-cases would be useful to verify?

tide.el Outdated
(display-buffer (current-buffer) t)))

(defun tide-project-info ()
"Show the version of tsserver."
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this name is (currently) pretty misleading. It doesn't show much info about the project at all. What did you intend for this function to be used for? I think a naming based on that would work better.

For instance, if this is meant to aid diagnostics, we should call it tide-show-diagnostics or something similar.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah, it's mostly for debugging. project-info may be inaccurate. What about tide-verify-setup?. I am not sure about show-diagnostics

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm OK with that. That's still much better than tide-project-info.

tide.el Outdated
(tide-on-response-success response nil
(tide-apply-codefix (plist-get response :body)))))

(defun tide-apply-codefixes (fixes apply-codefix)
(cond ((= 0 (length fixes)) (message "No code-fixes available."))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think variable name apply-codefix is not very good. To me that name almost seems to imply this is a boolean, and IMO is a source of needless confusion or mental overhead.

codefix-function or something which hints at its type would be better.

Copy link
Owner Author

Choose a reason for hiding this comment

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

will do

tide.el Outdated
(defun tide-fix ()
"Apply code fix for the error at point."
(interactive)
(defun tide-code-fix (apply-codefix)
(unless (tide-get-flycheck-errors-ids-at-point)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same with the variable name apply-codefix here.

@ananthakumaran
Copy link
Owner Author

These are the couple of cases I have tested.

// @ts-check

class C {
    constructor() {

    }
    method() {
      var x = this.x;
      x += this.y();
      x += this.x;
      return x;
    }
}
export interface Shape {
    getArea(): number;
}

export class Circle implements Shape {
}

class Rectangle implements Shape {
}

class Square implements Shape {
}

@josteink
Copy link
Collaborator

josteink commented Feb 4, 2018

Not a big difference in terms of code, but I still think that makes it much more readable and apparent what things are about :)

@ananthakumaran
Copy link
Owner Author

have you had a chance to test this out?

@josteink
Copy link
Collaborator

josteink commented Feb 4, 2018

Sorry, but I simply haven't had time for that. Busy as heck at work.

If it works for the use-cases you have intended, I say merge ahead. I have another few patches on another few projects which will probably get my attention first (which are also pending a proper review).

@ananthakumaran ananthakumaran merged commit caff812 into master Feb 4, 2018
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