blob: 0023cab54f2f4704d7b40a1d1cfe960e23b93c2e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/*******************************************************************************
* Copyright (c) 2011 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.framework.core.dsl.validation;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType;
import org.eclipse.osee.framework.core.dsl.oseeDsl.XAttributeType;
import org.eclipse.osee.framework.core.dsl.oseeDsl.XRelationType;
import org.eclipse.xtext.resource.IEObjectDescription;
import org.eclipse.xtext.util.CancelIndicator;
import org.eclipse.xtext.validation.NamesAreUniqueValidator;
import org.eclipse.xtext.validation.ValidationMessageAcceptor;
/**
* Osee specific name validator that ignores types names cause they conflict between types.<br>
* <br>
* Types instead will be checked via OseeDslJavaValidator
*
* @author Donald G. Dunne
*/
public class OseeNamesAreUniqueValidator extends NamesAreUniqueValidator {
OseeNamesAreUniqueValidationHelper oseeHelper;
public OseeNamesAreUniqueValidator() {
super();
oseeHelper = new OseeNamesAreUniqueValidationHelper();
}
public class OseeNamesAreUniqueValidationHelper extends org.eclipse.xtext.validation.NamesAreUniqueValidationHelper {
@Override
public void checkUniqueNames(Iterable<IEObjectDescription> descriptions, ValidationMessageAcceptor acceptor) {
super.checkUniqueNames(descriptions, acceptor);
}
@Override
public void checkUniqueNames(Iterable<IEObjectDescription> descriptions, CancelIndicator cancelIndicator, ValidationMessageAcceptor acceptor) {
List<IEObjectDescription> validDescriptions = new ArrayList<>();
for (IEObjectDescription description : descriptions) {
if (!(description.getEObjectOrProxy() instanceof XArtifactType) && !(description.getEObjectOrProxy() instanceof XAttributeType) && !(description.getEObjectOrProxy() instanceof XRelationType)) {
validDescriptions.add(description);
}
}
super.checkUniqueNames(validDescriptions, cancelIndicator, acceptor);
}
}
@Override
public void checkUniqueNamesInResourceOf(EObject eObject) {
if (!(getHelper() instanceof OseeNamesAreUniqueValidationHelper)) {
setHelper(oseeHelper);
}
super.checkUniqueNamesInResourceOf(eObject);
}
}
|