Skip to content
Snippets Groups Projects
Commit f8502684 authored by Vincent Aravantinos's avatar Vincent Aravantinos
Browse files

addMissingConstraints

refs 2334
parent e80fc5e2
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@ import java.util.Map;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
......@@ -54,7 +55,7 @@ import org.osgi.framework.Bundle;
* @author aravantinos
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: CD9A6244C4050965CF48516EFF160EF4
* @ConQAT.Rating YELLOW Hash: 1686D63A145633ABB0CE51E3617E7CA0
*/
public final class ConstraintVerificationService implements IIntrospectiveKernelService,
IConstraintVerificationService {
......@@ -377,4 +378,22 @@ public final class ConstraintVerificationService implements IIntrospectiveKernel
public Collection<IIntrospectionItem> getIntrospectionItems() {
return emptyList();
}
/** {@inheritDoc} */
@Override
public List<Constraint> addMissingConstraints(ITopLevelElement top, String id) {
List<Constraint> addedConstraints = new ArrayList<Constraint>();
IConstraintVerifier verifier = getFirstVerifier(id);
TreeIterator<EObject> it = top.getRootModelElement().eAllContents();
while(it.hasNext()) {
EObject elt = it.next();
if(elt instanceof IConstrained) {
Constraint cstr = verifier.addConstraintIfNeeded((IConstrained)elt);
if(cstr != null) {
addedConstraints.add(cstr);
}
}
}
return addedConstraints;
}
}
......@@ -4,6 +4,7 @@ import java.util.List;
import java.util.function.Consumer;
import org.fortiss.tooling.kernel.extension.IConstraintVerifier;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.internal.ConstraintVerificationService;
import org.fortiss.tooling.kernel.model.constraints.Constraint;
import org.fortiss.tooling.kernel.model.constraints.IConstrained;
......@@ -17,9 +18,10 @@ import org.fortiss.tooling.kernel.model.constraints.OutdatedVerificationStatus;
* @author aravantinos
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: F5501E6C42356F1144C44D6ED201BF04
* @ConQAT.Rating YELLOW Hash: 4B4CDB48E5D52B2656D7453E8E87A860
*/
public interface IConstraintVerificationService {
/** Returns the service instance. */
public static IConstraintVerificationService getInstance() {
return ConstraintVerificationService.getInstance();
......@@ -113,6 +115,16 @@ public interface IConstraintVerificationService {
*/
void setConstrained(Constraint constraint, IConstrained constrained, int index);
/**
* @param top
* @param id
* Completes <code>top</code> with missing constraints of type <code>id</code>, if
* applicable.
* @return List of added constraints.
*
*/
List<Constraint> addMissingConstraints(ITopLevelElement top, String id);
/** Registers the given verifier with the service. */
void registerConstraintVerifier(IConstraintVerifier verifier);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment