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

Added refactoring for changing with section to let #563

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AlexXuChen
Copy link
Contributor

@AlexXuChen AlexXuChen commented Feb 17, 2022

Added diagnostic for deprecated #with section and CodeAction to use #let.
replacewithwithlet2

Fixes #489

Signed-off-by: Alexander Chen [email protected]

@AlexXuChen AlexXuChen force-pushed the issue489-qute branch 7 times, most recently from 00f52fa to 9fee111 Compare February 23, 2022 20:03
@rgrunber
Copy link
Member

As discussed, I think a good starting point would be to highlight the entire range as opposed to just the start element. It's likely that we won't need to set the deprecated tag.

@AlexXuChen AlexXuChen force-pushed the issue489-qute branch 2 times, most recently from 9b2f96c to 9a87820 Compare February 24, 2022 21:53
@AlexXuChen AlexXuChen marked this pull request as ready for review February 24, 2022 21:58
@AlexXuChen AlexXuChen requested a review from rgrunber February 24, 2022 21:58
@AlexXuChen AlexXuChen force-pushed the issue489-qute branch 2 times, most recently from 7e81a8e to cd32991 Compare February 25, 2022 15:15
Copy link
Member

@rgrunber rgrunber left a comment

Choose a reason for hiding this comment

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

Overall, works well. Just a few minor fixes and one special case.

@AlexXuChen AlexXuChen force-pushed the issue489-qute branch 2 times, most recently from 45867a2 to 037a9fa Compare February 25, 2022 22:25
@angelozerr
Copy link
Contributor

In the demo, the code action doesn't generate properly the #let fix (yo can see warning on name and price.

The code action should generate:

{#let name=item.name price=item.price }
  ...
{\let}

After that, please write tests with diagnostic and code action.

@AlexXuChen AlexXuChen force-pushed the issue489-qute branch 2 times, most recently from fee85eb to e15e8fa Compare March 3, 2022 15:20
@AlexXuChen AlexXuChen force-pushed the issue489-qute branch 2 times, most recently from b6ac712 to d2d635a Compare March 3, 2022 21:59
@AlexXuChen AlexXuChen requested a review from angelozerr March 4, 2022 18:39
@AlexXuChen
Copy link
Contributor Author

If we use deprecated tags in the future, create

public static Diagnostic createDiagnosticWithTags(Range range, DiagnosticSeverity severity,
	IQuteErrorCode errorCode, List<DiagnosticTag> tags, Object... arguments) {
String message = errorCode.getMessage(arguments);
Diagnostic diagnostic = new Diagnostic(range, message, severity, QUTE_SOURCE,
		errorCode != null ? errorCode.getCode() : null);
diagnostic.setTags(tags);
return diagnostic;
}

in DiagnosticDataFactory.java

@AlexXuChen AlexXuChen force-pushed the issue489-qute branch 3 times, most recently from 8029c9b to cc21c50 Compare March 7, 2022 21:48
@AlexXuChen AlexXuChen requested a review from angelozerr March 7, 2022 21:52
@@ -106,6 +106,16 @@ public static CodeAction replace(String title, Range range, String replaceText,
return replace(title, Collections.singletonList(replace), document, diagnostic);
}

@SuppressWarnings("null")
public static CodeAction replace(String title, List<Range> ranges, String replaceText, TextDocumentItem document,
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a javadoc

@AlexXuChen AlexXuChen force-pushed the issue489-qute branch 2 times, most recently from 23d4294 to 7806f85 Compare March 11, 2022 06:05
@fbricon
Copy link
Collaborator

fbricon commented Mar 15, 2022

@fbricon
Copy link
Collaborator

fbricon commented Mar 15, 2022

the code action should appear as a refactoring item

@rgrunber rgrunber changed the title Added diagnostic for deprecated with section and CodeAction to use let Added refactoring for changing with section let Apr 6, 2022
@rgrunber rgrunber changed the title Added refactoring for changing with section let Added refactoring for changing with section to let Apr 6, 2022
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.

CodeAction to replace deprecated #with into #let section
4 participants