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

Implementation: Suggested Code fixes #615

Closed
timotheeguerin opened this issue Jun 10, 2022 · 1 comment · Fixed by #2888
Closed

Implementation: Suggested Code fixes #615

timotheeguerin opened this issue Jun 10, 2022 · 1 comment · Fixed by #2888
Assignees
Milestone

Comments

@timotheeguerin
Copy link
Member

timotheeguerin commented Jun 10, 2022

From design #497

Change

  • Diagnostic takes a new property fixes which is a list of code fixes that can be run.
reportDiagnostic(program, {
   code: "library-not-found", 
   message: "Cannot find library @cadl-lang/rest",
   target: node,
   codefixes: [
     createInstallLibCodeFix("@cadl-lang/rest"),
   ]
})

export interface CodeFix {
  id: string;
  label: string;
  fix: (fixContext: FixContext) => CodeFixAction | CodeFixAction[] | Promise<void> | void
}

export interface FixContext {
  replaceText(node: Node, newText: string): CodeAction;
}

export function createInstallLibCodeFix(library: string) {
  return {
    id: "install-lib",
    label: "Install library",

  }
}

Rules that could have a simple fixer:

@ghost ghost added the Needs Triage label Jun 10, 2022
@markcowl markcowl changed the title Implementation: Code fixes Implementation: Suggested Code fixes Jun 13, 2022
@markcowl
Copy link
Contributor

estimate: 13

@markcowl markcowl added this to the [2022] September milestone Jun 16, 2022
@markcowl markcowl modified the milestones: [2022] December, [2023] March Dec 5, 2022
@markcowl markcowl modified the milestones: [2023] March, [2023] April Jan 11, 2023
@markcowl markcowl modified the milestones: [2023] April, Backlog Jan 28, 2023
@timotheeguerin timotheeguerin self-assigned this Feb 5, 2024
timotheeguerin added a commit that referenced this issue Mar 5, 2024
closes #615

## Code fixes added

### Suppress
![Kapture 2024-02-05 at 15 16
22](https://github.com/microsoft/typespec/assets/1031227/644014a3-9352-4bd4-b1b8-0d314c627405)

### `number` -> `float64` typo fix

![Kapture 2024-02-06 at 09 50
28](https://github.com/microsoft/typespec/assets/1031227/65b2e9aa-c510-440f-a1c6-7851611b65a2)

### Enum to extensible enum in typespec-azure

Azure/typespec-azure#258

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
markcowl added a commit to markcowl/cadl that referenced this issue Mar 8, 2024
closes microsoft#615

## Code fixes added

### Suppress
![Kapture 2024-02-05 at 15 16
22](https://github.com/microsoft/typespec/assets/1031227/644014a3-9352-4bd4-b1b8-0d314c627405)

### `number` -> `float64` typo fix

![Kapture 2024-02-06 at 09 50
28](https://github.com/microsoft/typespec/assets/1031227/65b2e9aa-c510-440f-a1c6-7851611b65a2)

### Enum to extensible enum in typespec-azure

Azure/typespec-azure#258

---------

Co-authored-by: Mark Cowlishaw <markcowl@microsoft.com>
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 a pull request may close this issue.

3 participants