mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
side effects warning: make format reusable
This commit is contained in:
+6
-17
@@ -35,6 +35,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -148,25 +149,13 @@ public class AccessStaticViaInstanceFix extends LocalQuickFixAndIntentionActionO
|
||||
@Override
|
||||
protected String sideEffectsDescription() {
|
||||
if (canCopeWithSideEffects) {
|
||||
return "<html><body>" +
|
||||
" There are possible side effects found in expression '" +
|
||||
qualifierExpression.getText() +
|
||||
"'<br>" +
|
||||
" You can:<ul><li><b>Remove</b> class reference along with whole expressions involved, or</li>" +
|
||||
" <li><b>Transform</b> qualified expression into the statement on its own.<br>" +
|
||||
" That is,<br>" +
|
||||
" <table border=1><tr><td><code>" +
|
||||
myExpression.getText() +
|
||||
"</code></td></tr></table><br> becomes: <br>" +
|
||||
" <table border=1><tr><td><code>" +
|
||||
qualifierExpression.getText() +
|
||||
";<br>" +
|
||||
qualifiedWithClassName.getText() +
|
||||
" </code></td></tr></table></li>" +
|
||||
" </body></html>";
|
||||
return MessageFormat.format(getFormatString(),
|
||||
"expression '" + qualifierExpression.getText() + "'",
|
||||
myExpression.getText(), //before text
|
||||
qualifierExpression.getText() + ";<br>" + qualifiedWithClassName.getText());//after text
|
||||
}
|
||||
return "<html><body> There are possible side effects found in expression '" + qualifierExpression.getText() + "'<br>" +
|
||||
"You can:<ul><li><b>Remove</b> class reference along with whole expressions involved, or</li></body></html>";
|
||||
"You can <b>Remove</b> class reference along with whole expressions involved</body></html>";
|
||||
}
|
||||
};
|
||||
dialog.show();
|
||||
|
||||
+29
-27
@@ -124,35 +124,37 @@ public class SideEffectWarningDialog extends DialogWrapper {
|
||||
return panel;
|
||||
}
|
||||
|
||||
protected String getFormatString() {
|
||||
return "<html>\n" +
|
||||
"<body>\n" +
|
||||
"There are possible side effects found in {0}<br>\n" +
|
||||
"You can:\n" +
|
||||
"<br>\n" +
|
||||
"- <b>Remove</b> variable usages along with all expressions involved, or<br>\n" +
|
||||
"- <b>Transform</b> expressions assigned to variable into the statements on their own.<br>\n" +
|
||||
"<div style=\"padding-left: 0.6cm;\">\n" +
|
||||
" That is,<br>\n" +
|
||||
" <table border=\"0\">\n" +
|
||||
" <tr>\n" +
|
||||
" <td><code>{1};</code></td>\n" +
|
||||
" </tr>\n" +
|
||||
" </table>\n" +
|
||||
" becomes: <br>\n" +
|
||||
" <table border=\"0\">\n" +
|
||||
" <tr>\n" +
|
||||
" <td><code>{2};</code></td>\n" +
|
||||
" </tr>\n" +
|
||||
" </table>\n" +
|
||||
"</div>\n" +
|
||||
"</body>\n" +
|
||||
"</html>";
|
||||
}
|
||||
|
||||
protected String sideEffectsDescription() {
|
||||
if (myCanCopeWithSideEffects) {
|
||||
String format = "<html>\n" +
|
||||
"<body>\n" +
|
||||
"There are possible side effects found in expressions assigned to the variable ''{0}''<br>\n" +
|
||||
"You can:\n" +
|
||||
"<br>\n" +
|
||||
"- <b>Remove</b> variable usages along with all expressions involved, or<br>\n" +
|
||||
"- <b>Transform</b> expressions assigned to variable into the statements on their own.<br>\n" +
|
||||
"<div style=\"padding-left: 0.6cm;\">\n" +
|
||||
" That is,<br>\n" +
|
||||
" <table border=\"0\">\n" +
|
||||
" <tr>\n" +
|
||||
" <td><code>{1} {0} = {2};</code></td>\n" +
|
||||
" </tr>\n" +
|
||||
" </table>\n" +
|
||||
" becomes: <br>\n" +
|
||||
" <table border=\"0\">\n" +
|
||||
" <tr>\n" +
|
||||
" <td><code>{3};</code></td>\n" +
|
||||
" </tr>\n" +
|
||||
" </table>\n" +
|
||||
"</div>\n" +
|
||||
"</body>\n" +
|
||||
"</html>";
|
||||
return MessageFormat.format(format,
|
||||
myVariable.getName(),
|
||||
myVariable.getType().getPresentableText(),
|
||||
myBeforeText,
|
||||
return MessageFormat.format(getFormatString(),
|
||||
"expressions assigned to the variable '" + myVariable.getName() + "'",
|
||||
myVariable.getType().getPresentableText() + " " + myVariable.getName() + " = " + myBeforeText,
|
||||
myAfterText);
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user