Skip to content

Package: DummyModelQuickFix

DummyModelQuickFix

nameinstructionbranchcomplexitylinemethod
DummyModelQuickFix(String)
M: 0 C: 23
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
applyFix(EObject)
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getLabel(Diagnostic)
M: 21 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
isApplicable(Diagnostic)
M: 2 C: 15
88%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 1 C: 3
75%
M: 0 C: 1
100%
setPriority(double)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Alexandra Buzila - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.ui.quickfix.test;
15:
16: import java.util.HashMap;
17:
18: import org.eclipse.emf.common.util.Diagnostic;
19: import org.eclipse.emf.ecore.EObject;
20: import org.eclipse.emf.ecp.quickfix.ModelQuickFix;
21: import org.eclipse.emf.ecp.quickfix.ModelQuickFixException;
22:
23: /**
24: * @author Alexandra Buzila
25: *
26: */
27: public class DummyModelQuickFix implements ModelQuickFix {
28:
29:         private double priority;
30:         private final String problemID;
31:         /* map from problemID to label */
32:         private final HashMap<String, String> labels = new HashMap<String, String>();
33:
34:         /**
35:          * Default constructor.
36:          *
37:          * @param problemID the problem ID
38:          */
39:         public DummyModelQuickFix(String problemID) {
40:                 this.problemID = problemID;
41:                 labels.put(problemID, "Solve problem " + problemID);
42:         }
43:
44:         /**
45:          * {@inheritDoc}
46:          *
47:          * @see org.eclipse.emf.ecp.quickfix.ModelQuickFix#isApplicable(org.eclipse.emf.common.util.Diagnostic)
48:          */
49:         @Override
50:         public double isApplicable(Diagnostic diagnostic) {
51:                 final Object data = diagnostic.getData().get(0);
52:
53:•                if (data != null && data.equals(problemID)) {
54:                         return priority;
55:                 }
56:                 return 0;
57:         }
58:
59:         /**
60:          * {@inheritDoc}
61:          *
62:          * @see org.eclipse.emf.ecp.quickfix.ModelQuickFix#applyFix(org.eclipse.emf.ecore.EObject)
63:          */
64:         @Override
65:         public void applyFix(EObject target) throws ModelQuickFixException {
66:                 // do nothing
67:         }
68:
69:         /**
70:          * Sets the priority.
71:          *
72:          * @param priority the priority
73:          */
74:         public void setPriority(double priority) {
75:                 this.priority = priority;
76:         }
77:
78:         /**
79:          * {@inheritDoc}
80:          *
81:          * @see org.eclipse.emf.ecp.quickfix.ModelQuickFix#getLabel(org.eclipse.emf.common.util.Diagnostic)
82:          */
83:         @Override
84:         public String getLabel(Diagnostic diagnostic) {
85:                 final Object data = diagnostic.getData().get(0);
86:
87:•                if (data != null && data.equals(problemID)) {
88:                         return labels.get(problemID);
89:                 }
90:                 return "";
91:         }
92:
93: }