-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
7026: Improve `Convert to type` quick-fixes r=Undin a=Undin These changes: - refactor `Convert to type` quick-fixes. All common code is extracted into a single place, new base `ConvertToTyFix` class. Also, now you can only pass `RsExpr` to the corresponding quick-fixes instead of any psi object - omit default type parameters in a quick-fix text changelog: Omit default type parameters in a `Convert to type` quick-fix text Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
- Loading branch information
Showing
14 changed files
with
199 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/org/rust/ide/annotator/fixes/ConvertToTyFix.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Use of this source code is governed by the MIT license that can be | ||
* found in the LICENSE file. | ||
*/ | ||
|
||
package org.rust.ide.annotator.fixes | ||
|
||
import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement | ||
import com.intellij.psi.PsiElement | ||
import org.rust.ide.presentation.render | ||
import org.rust.lang.core.psi.RsExpr | ||
import org.rust.lang.core.types.ty.Ty | ||
|
||
abstract class ConvertToTyFix : LocalQuickFixAndIntentionActionOnPsiElement { | ||
|
||
private val tyName: String | ||
private val convertSubject: String | ||
|
||
constructor(expr: RsExpr, tyName: String, convertSubject: String): super(expr) { | ||
this.tyName = tyName | ||
this.convertSubject = convertSubject | ||
} | ||
|
||
constructor(expr: RsExpr, ty: Ty, convertSubject: String) : | ||
this(expr, ty.render(skipUnchangedDefaultTypeArguments = true), convertSubject) | ||
|
||
override fun getFamilyName(): String = "Convert to type" | ||
override fun getText(): String = "Convert to $tyName using $convertSubject" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.