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<E↵
|
4 | for (EEnumLiteral eEnumLiteral : eLiteral↵ | | 4 | Package> eSubpackages = ePackage.getESubpackages();↵
|
5 | s)↵ | | 5 | for (EPackage eSubpackage : eSubpackages)↵
|
6 | {↵ | | 6 | {↵
|
7 | String literal = eEnumLiteral.getLiteral();↵ | | 7 | String name = eSubpackage.getName();↵
|
8 | if (literal != null)↵ | | 8 | if (name != null)↵
|
9 | {↵ | | 9 | {↵
|
10 | int index = literals.indexOf(literal);↵ | | 10 | int index = names.indexOf(name);↵
|
11 | if (index != -1)↵ | | 11 | if (index != -1)↵
|
12 | {↵ | | 12 | {↵
|
13 | if (diagnostics == null)↵ | | 13 | if (diagnostics == null)↵
|
14 | {↵ | | 14 | {↵
|
15 | return false;↵ | | 15 | return false;↵
|
16 | }↵ | | 16 | }↵
|
17 | else↵ | | 17 | else↵
|
18 | {↵ | | 18 | {↵
|
19 | result = false;↵ | | 19 | result = false;↵
|
20 | EEnumLiteral otherEEnumLiteral = eLiterals.get(index);↵ | | 20 | E↵
|
21 | // Don't complain about the literals if they are the same as the names and the names collide.↵ | | |
|
22 | //↵ | | |
|
23 | String name = eEnumLiteral.getName();↵ | | |
|
24 | if (name == null || !name.equals(literal) || !name.equals(otherEEnumLiteral.getName()))↵ | | 21 | Package otherESubpackage = ↵
|
25 | {↵ | | |
|
26 | ↵ | | 22 | eSubpackages.get(index);↵
|
27 | diagnostics.add↵ | | 23 | diagnostics.add↵
|
28 | (createDiagnostic↵ | | 24 | (createDiagnostic↵
|
29 | (Diagnostic.ERROR,↵ | | 25 | (Diagnostic.ERROR,↵
|
30 | DIAGNOSTIC_SOURCE,↵ | | 26 | DIAGNOSTIC_SOURCE,↵
|
31 | UNIQUE_ENUMERATOR_LITERALS,↵ | | 27 | UNIQUE_SUBPACKAGE_NAMES,↵
|
32 | "_UI_EEnumUniqueEnumeratorLiterals_diagnostic", ↵ | | 28 | "_UI_EPackageUniqueSubpackageNames_diagnostic", ↵
|
33 | new Object[] { literal },↵ | | 29 | new Object[] { name },↵
|
34 | new Object[] { eEnum, eEnumLiteral, otherEEnumLiteral },↵ | | 30 | new Object[] { ePackage, eSubpackage, otherESubpackage },↵
|
35 | context));↵ | | 31 | context));↵
|
36 | }↵ | | 32 | }↵
|
37 | }↵ | | 33 | ↵
|
38 | ↵ | | 34 | }↵
|
39 | }↵ | | 35 | }↵
|
40 | }↵ | | 36 | ↵
|
41 | literals.add(literal);↵ | | 37 | names.add(name);↵
|
42 | }↵ | | 38 | }↵
|
43 | return result; | | 39 | return result;
|