tmysik commented on code in PR #5704:
URL: https://github.com/apache/netbeans/pull/5704#discussion_r1148306221
##########
php/php.editor/src/org/netbeans/modules/php/editor/verification/IntroduceSuggestion.java:
##########
@@ -719,6 +734,79 @@ int getOffset() throws BadLocationException {
}
}
+ private static class IntroduceEnumCaseFix extends IntroduceFix {
+
+ private final EnumScope type;
+ private final String template;
+ private final String enumCaseName;
+ private final String backingType;
+
+ public IntroduceEnumCaseFix(BaseDocument doc, StaticConstantAccess
node, EnumScope type) {
+ super(doc, node);
+ this.type = type;
+ this.enumCaseName = ((StaticConstantAccess)
node).getConstantName().getName();
+ this.backingType = type.getBackingType() != null ?
type.getBackingType().toString() : null;
+ this.template = String.format(getTemplate(backingType),
enumCaseName);
+ }
+
+ private String getTemplate(String backingType) {
+ String caseTemplate = "case %s;"; // NOI18N
+ if (backingType != null) {
+ if (Type.STRING.equals(backingType)) {
+ caseTemplate = "case %s = '';"; // NOI18N
+ } else if (Type.INT.equals(backingType)) {
+ caseTemplate = "case %s = " + (getLastIntIndex() + 1) +
";"; // NOI18N
+ }
Review Comment:
No `else`? At least some log?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists