Skip to content

Commit 99e2abf

Browse files
committed
[NONE] DOT Editor - Refactoring the DotProposalProvider class.
- Use a switch case statement over enum instead of if-then-else statements when computing the GEF DOT Editor content assist proposals.
1 parent ffad4f8 commit 99e2abf

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

org.eclipse.gef.dot.ui/src/org/eclipse/gef/dot/internal/ui/language/contentassist/DotProposalProvider.java

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2010, 2020 itemis AG and others.
2+
* Copyright (c) 2010, 2021 itemis AG and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -306,13 +306,16 @@ public void completeAttribute_Value(EObject model, Assignment assignment,
306306
ICompletionProposalAcceptor acceptor) {
307307
if (model instanceof Attribute) {
308308
Attribute attribute = (Attribute) model;
309+
Context attributeContext = DotAttributes.getContext(attribute);
310+
String attributeName = attribute.getName().toValue();
309311

310312
context = context.copy()
311313
.setMatcher(new AttributeValueMatcher(context.getMatcher()))
312314
.toContext();
313315

314-
if (DotAttributes.getContext(attribute) == Context.EDGE) {
315-
switch (attribute.getName().toValue()) {
316+
switch (attributeContext) {
317+
case EDGE:
318+
switch (attributeName) {
316319
case DotAttributes.ARROWHEAD__E:
317320
case DotAttributes.ARROWTAIL__E:
318321
proposeAttributeValues(
@@ -385,8 +388,9 @@ public void completeAttribute_Value(EObject model, Assignment assignment,
385388
acceptor);
386389
break;
387390
}
388-
} else if (DotAttributes.getContext(attribute) == Context.GRAPH) {
389-
switch (attribute.getName().toValue()) {
391+
break;
392+
case GRAPH:
393+
switch (attributeName) {
390394
case DotAttributes.BGCOLOR__GC:
391395
proposeColorListAttributeValues(attribute, context,
392396
acceptor);
@@ -438,8 +442,9 @@ public void completeAttribute_Value(EObject model, Assignment assignment,
438442
acceptor);
439443
break;
440444
}
441-
} else if (DotAttributes.getContext(attribute) == Context.NODE) {
442-
switch (attribute.getName().toValue()) {
445+
break;
446+
case NODE:
447+
switch (attributeName) {
443448
case DotAttributes.COLOR__CNE:
444449
proposeColorAttributeValues(attribute, context, acceptor);
445450
break;
@@ -488,8 +493,9 @@ public void completeAttribute_Value(EObject model, Assignment assignment,
488493
default:
489494
break;
490495
}
491-
} else if (DotAttributes.getContext(attribute) == Context.CLUSTER) {
492-
switch (attribute.getName().toValue()) {
496+
break;
497+
case CLUSTER:
498+
switch (attributeName) {
493499
case DotAttributes.BGCOLOR__GC:
494500
proposeColorListAttributeValues(attribute, context,
495501
acceptor);
@@ -525,17 +531,15 @@ public void completeAttribute_Value(EObject model, Assignment assignment,
525531
DotActivator.ORG_ECLIPSE_GEF_DOT_INTERNAL_LANGUAGE_DOTESCSTRING,
526532
context, acceptor);
527533
}
528-
} else if (DotAttributes
529-
.getContext(attribute) == Context.SUBGRAPH) {
530-
switch (attribute.getName().toValue()) {
534+
break;
535+
case SUBGRAPH:
536+
switch (attributeName) {
531537
case DotAttributes.RANK__S:
532538
proposeAttributeValues(RankType.values(), context,
533539
acceptor);
534540
break;
535541
}
536-
}
537-
538-
else {
542+
default:
539543
super.completeAttribute_Value(model, assignment, context,
540544
acceptor);
541545
}

0 commit comments

Comments
 (0)