File path: /ArgoUML-0.34-src/argouml/src/argouml-core-model-mdr/src/org/argouml/model/mdr/ActivityGraphsHelperMDRImpl.java | File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/profile/internal/ModelUtils.java | |||
Method name: Object findClassifierByName(Object, String)
|
Method name: Object findTypeInModel(String, Object)
|
|||
Number of AST nodes: 5 | Number of AST nodes: 3 | |||
1 | public Object findClassifierByName(Object ofs, String s) { | 1 | /** | |
2 | if (!(ofs instanceof ObjectFlowState)) { | 2 | * Finds a type in a model by name | |
3 | throw new IllegalArgumentException(); | 3 | * | |
4 | } | 4 | * @param s the type name | |
5 | 5 | * @param model the model | ||
6 | CompositeState cs = ((ObjectFlowState) ofs).getContainer(); | 6 | * @return the type or <code>null</code> if the type has not been found. | |
7 | StateMachine sm = cs.getStateMachine(); | 7 | */ | |
8 | ModelElement ns = sm.getContext(); | 8 | public static Object findTypeInModel(String s, Object model) { | |
9 | if (ns == null) { | 9 | ||
10 | return null; | 10 | if (!Model.getFacade().isANamespace(model)) { | |
11 | } | 11 | throw new IllegalArgumentException( | |
12 | if (!(ns instanceof Namespace)) { | 12 | "Looking for the classifier " + s | |
13 | ns = ns.getNamespace(); | 13 | + " in a non-namespace object of " + model | |
14 | } | 14 | + ". A namespace was expected."); | |
15 | if (ns != null) { | 15 | } | |
16 | Collection c = | 16 | ||
17 | Model.getModelManagementHelper().getAllModelElementsOfKind( | 17 | Collection allClassifiers = | |
18 | ns, Model.getMetaTypes().getClassifier()); | 18 | Model.getModelManagementHelper() | |
19 | Iterator i = c.iterator(); | 19 | .getAllModelElementsOfKind(model, | |
20 | while (i.hasNext()) { | 20 | Model.getMetaTypes().getClassifier()); | |
21 | ModelElement classifier = (ModelElement) i.next(); | 21 | ||
22 | String cn = classifier.getName(); | 22 | for (Object classifier : allClassifiers) { | |
23 | if (cn != null && cn.equals(s)) { | 23 | if (Model.getFacade().getName(classifier) != null | |
24 | return classifier; | 24 | && Model.getFacade().getName(classifier).equals(s)) { | |
25 | } | 25 | return classifier; | |
26 | } | 26 | } | |
27 | } else { | 27 | } | |
28 | throw new IllegalArgumentException(); | 28 | ||
29 | } | 29 | return null; | |
30 | return null; | 30 | } | |
31 | } | |||
See real code fragment | See real code fragment |
Number of mapped statements | 4 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 0.0 |
Similarity Score | 0.333 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
13 | while (i.hasNext()) | 4 | for (Object classifier : allClassifiers) | ||||||||||||||||
14 | ModelElement classifier = (ModelElement)i.next(); | | |||||||||||||||||
15 | String cn = classifier.getName(); |
| | ||||||||||||||||
16 | if (cn != null && cn.equals(s)) |
| 5 | if (Model.getFacade().getName(classifier) != null && Model.getFacade().getName(classifier).equals(s)) | |||||||||||||||
|
| 6 | return classifier; | ||||||||||||||||
17 | return classifier; |
| |
Row | Violation |
---|---|
1 | Unmatched statement String cn=classifier.getName(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Expression Model.getFacade().getName(classifier) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression Model.getFacade().getName(classifier) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Unmatched statement return classifier; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
5 | Unmatched return classifier; |
6 | Unmatched statement return classifier; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
7 | Unmatched return classifier; |
8 | Clone fragment #1 returns variable classifier with type org.omg.uml.foundation.core.ModelElement , while Clone fragment #2 returns variable classifier with type java.lang.Object |