File path: /ArgoUML-0.34-src/argouml-cpp/src/org/argouml/language/cpp/profile/BaseProfile.java | File path: /ArgoUML-0.34-src/argouml-sql/src/org/argouml/language/sql/Utils.java | |||
Method name: Object getTagDefinition(String)
|
Method name: Object getAttributeForName(Object, String)
|
|||
Number of AST nodes: 3 | Number of AST nodes: 5 | |||
1 | public static Object getTagDefinition(String tdName) { | 1 | /** | |
2 | // look for it in all the models | 2 | * Search the attribute named <code>attributeName</code> in the given | |
3 | Collection models = getModels(); | 3 | * relation. If there exist more than one attribute the first one is | |
4 | for (Object model : models) { | 4 | * returned. | |
5 | Collection tagDefinitions = getModelManagementHelper(). | 5 | * | |
6 | getAllModelElementsOfKindWithModel(model, | 6 | * @param relation | |
7 | Model.getMetaTypes().getTagDefinition()); | 7 | * The relation in which to search the attribute. | |
8 | for (Object td : tagDefinitions) { | 8 | * @param attributeName | |
9 | if (tdName.equals(getFacade().getName(td))) { | 9 | * The name of the attribute to search. | |
10 | return td; | 10 | * @return The attribute if found, <code>null</code> else. | |
11 | } | 11 | */ | |
12 | } | 12 | public static Object getAttributeForName(Object relation, | |
13 | } | 13 | String attributeName) { | |
14 | // create it in an editable model if one is found | 14 | Object attribute = null; | |
15 | Collection editableModels = getEditableModels(); | 15 | ||
16 | Iterator it = editableModels.iterator(); | 16 | Collection attributes = Model.getFacade().getAttributes(relation); | |
17 | if (it.hasNext()) { | 17 | for (Iterator it = attributes.iterator(); it.hasNext();) { | |
18 | return getExtensionMechanismsFactory().buildTagDefinition(tdName, | 18 | Object attr = it.next(); | |
19 | null, it.next()); | 19 | if (Model.getFacade().getName(attr).equals(attributeName)) { | |
20 | } | 20 | attribute = attr; | |
21 | throw new IllegalStateException("Unable to find an editable model."); | 21 | break; | |
22 | } | 22 | } | |
23 | } | |||
24 | ||||
25 | return attribute; | |||
26 | } | |||
See real code fragment | See real code fragment |
Number of mapped statements | 3 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 2 |
Time elapsed for statement mapping (ms) | 0.0 |
Similarity Score | 0.833 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4 | for (Object td : tagDefinitions) |
| 3 | for (Iterator it = attributes.iterator(); it.hasNext(); ) | |||||||||||||
|
| 4 | Object attr = it.next(); | ||||||||||||||
5 | if (tdName.equals(getFacade().getName(td))) |
| 5 | if (Model.getFacade().getName(attr).equals(attributeName)) | |||||||||||||
|
| 6 | attribute = attr; | ||||||||||||||
6 | return td; |
| | ||||||||||||||
|
| 7 | break; |
Row | Violation |
---|---|
1 | Unmatched statement attribute=attr; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement return td; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched return td; |
4 | Unmatched break; |