1 | boolean result = true;↵ | | 1 | boolean result = true;↵
|
2 | List<String> literals = new ArrayList<String>();↵ | | 2 | List<String> names = new ArrayList<String>();↵
|
3 | EList<EEnumLiteral> eLiterals = eEnum.getELiterals();↵ | | 3 | EList<EParameter> eParameters = eOperation.getEParameters();↵
|
4 | for (EEnumLiteral eEnumLiteral : eLiterals)↵ | | 4 | for (EParameter eParameter : eParameters)↵
|
5 | {↵ | | 5 | {↵
|
6 | String literal = eEnumLiteral.getLiteral();↵ | | 6 | String name = eParameter.getName();↵
|
7 | if (literal != null)↵ | | 7 | if (name != null)↵
|
8 | {↵ | | 8 | {↵
|
9 | int index = literals.indexOf(literal);↵ | | 9 | int index = names.indexOf(name);↵
|
10 | if (index != -1)↵ | | 10 | if (index != -1)↵
|
11 | {↵ | | 11 | {↵
|
12 | if (diagnostics == null)↵ | | 12 | if (diagnostics == null)↵
|
13 | {↵ | | 13 | {↵
|
14 | return false;↵ | | 14 | return false;↵
|
15 | }↵ | | 15 | }↵
|
16 | else↵ | | 16 | else↵
|
17 | {↵ | | 17 | {↵
|
18 | result = false;↵ | | 18 | result = false;↵
|
19 | EEnumLiteral otherEEnumLiteral = eLiterals.get(index);↵ | | 19 | E↵
|
20 | // Don't complain about the literals if they are the same as the names and the names collide.↵ | | |
|
21 | //↵ | | |
|
22 | String name = eEnumLiteral.getName();↵ | | 20 | Parameter otherEParameter = eParameters.get↵
|
23 | if (name == null || !name.equals(literal) || !name.equals(otherEEnumLiteral.getName()))↵ | | |
|
24 | {↵ | | |
|
25 | ↵ | | 21 | (index);↵
|
26 | diagnostics.add↵ | | 22 | diagnostics.add↵
|
27 | (createDiagnostic↵ | | 23 | (createDiagnostic↵
|
28 | (Diagnostic.ERROR,↵ | | 24 | (Diagnostic.ERROR,↵
|
29 | DIAGNOSTIC_SOURCE,↵ | | 25 | DIAGNOSTIC_SOURCE,↵
|
30 | UNIQUE_ENUMERATOR_LITERALS,↵ | | 26 | UNIQUE_PARAMETER_NAMES,↵
|
31 | "_UI_EEnumUniqueEnumeratorLiterals_diagnostic", ↵ | | 27 | "_UI_EOperationUniqueParameterNames_diagnostic", ↵
|
32 | new Object[] { literal },↵ | | 28 | new Object[] { name },↵
|
33 | new Object[] { eEnum, eEnumLiteral, otherEEnumLiteral },↵ | | 29 | new Object[] { eOperation, eParameter, otherEParameter },↵
|
34 | context));↵ | | 30 | context));↵
|
35 | }↵ | | 31 | ↵
|
36 | ↵ | | 32 | }↵
|
37 | }↵ | | 33 | }↵
|
38 | }↵ | | 34 | }↵
|
39 | }↵ | | 35 | ↵
|
40 | literals.add(literal);↵ | | 36 | names.add(name);↵
|
41 | }↵ | | 37 | }↵
|
42 | return result; | | 38 | return result;
|