本文整理汇总了Java中net.ssehub.easy.varModel.model.Project.accept方法的典型用法代码示例。如果您正苦于以下问题:Java Project.accept方法的具体用法?Java Project.accept怎么用?Java Project.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.ssehub.easy.varModel.model.Project
的用法示例。
在下文中一共展示了Project.accept方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: freezeProject
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Adds freezes blocks to the configuration projects.
* @param baseProject The copied QM model (the starting point, which imports all the other models).
*/
private void freezeProject(Project baseProject) {
DeclarationFinder finder = new DeclarationFinder(baseProject, FilterType.ALL, null);
List<DecisionVariableDeclaration> allDeclarations = new ArrayList<DecisionVariableDeclaration>();
List<AbstractVariable> tmpList = finder.getVariableDeclarations(VisibilityType.ALL);
for (int i = 0, end = tmpList.size(); i < end; i++) {
AbstractVariable declaration = tmpList.get(i);
if (declaration instanceof DecisionVariableDeclaration
&& !(declaration.getNameSpace().equals(QmConstants.PROJECT_OBSERVABLESCFG)
&& declaration.getName().equals("qualityParameters"))) {
allDeclarations.add((DecisionVariableDeclaration) declaration);
}
}
ProjectRewriteVisitor rewriter = new ProjectRewriteVisitor(baseProject, FilterType.ALL);
ProjectFreezeModifier freezer = new ProjectFreezeModifier(baseProject, allDeclarations);
rewriter.addProjectModifier(freezer);
baseProject.accept(rewriter);
}
示例2: setUp
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* setUp for all test cases.
*/
@Before
public void setUp() {
// Create project and datatypes.
project = new Project("a_project");
setType = new Set("SetType", IntegerType.TYPE, project);
seqType = new Sequence("SeqType", IntegerType.TYPE, project);
project.add(setType);
project.add(seqType);
//Check whether project is valid and can be used for testing.
IvmlValidationVisitor validator = new IvmlValidationVisitor();
project.accept(validator);
Assert.assertEquals("Project is not valid, and cannot be used for testing other components",
0, validator.getMessageCount());
}
示例3: setUp
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* SetUp method: creates an empty project together with a configuration.
*/
@Before
public void setUp() {
project = new Project("configurationTestProject");
Set setType = new Set("SET", IntegerType.TYPE, project);
set = new DecisionVariableDeclaration("set", setType, project);
project.add(set);
innerCompound = new Compound("CMP", project);
project.add(innerCompound);
DecisionVariableDeclaration intA = new DecisionVariableDeclaration("intA", IntegerType.TYPE, innerCompound);
DecisionVariableDeclaration intB = new DecisionVariableDeclaration("intB", IntegerType.TYPE, innerCompound);
innerCompound.add(intA);
innerCompound.add(intB);
Set setOfCompoundType = new Set("SetOfCompound", innerCompound, project);
setOfCompound = new DecisionVariableDeclaration("setOfCompound", setOfCompoundType, project);
project.add(setOfCompound);
IvmlValidationVisitor validationer = new IvmlValidationVisitor();
project.accept(validationer);
Assert.assertEquals(0, validationer.getErrorCount());
configuration = new Configuration(project);
}
示例4: validateParsedProject
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Checks whether a loaded/parsed {@link Project} contains errors and aborts the current test if it contain
* at least one error.
* @param uri The location from where the project was loaded from.
* @param project The currently loaded/parsed project, which shall be checked.
*/
private void validateParsedProject(URI uri, Project project) {
IvmlValidationVisitor valVis = new IvmlValidationVisitor();
project.accept(valVis);
if (valVis.getErrorCount() > 0) {
StringBuffer errMsg = new StringBuffer("Project \"");
errMsg.append(project.getName());
errMsg.append("\" of \"");
errMsg.append(uri.toFileString());
errMsg.append("\" contains errors:");
for (int m = 0; m < valVis.getMessageCount(); m++) {
errMsg.append("\n");
errMsg.append(" - " + valVis.getMessage(m).getDescription());
}
Assert.fail(errMsg.toString());
}
}
示例5: specialTreatment
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
@Override
protected void specialTreatment(Project mainProject) {
QMModelStatistics modelVisitor = new QMModelStatistics(mainProject);
mainProject.accept(modelVisitor);
getStatistics().setStaticConstraints(modelVisitor.noOfConstraints());
getStatistics().setOperations(modelVisitor.noOfOperations());
getStatistics().setTopLevelDeclarations(modelVisitor.noOfToplevelDeclarations());
getStatistics().setNestedDeclarations(modelVisitor.noOfNestedDeclarations());
getStatistics().setTopLevelAnnotations(modelVisitor.noOfToplevelAnnotations());
getStatistics().setNestedAnnotations(modelVisitor.noOfNestedAnnotations());
}
示例6: DatatypeFinder
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Sole constructor for creating a new {@link DatatypeFinder}.
* @param originProject The project where the visiting shall start
* @param filterType Specifies whether project imports shall be considered or not.
* @param type An optional parameter of which kind the found elements should be.
* This should be a {@link CustomDatatype}.
* If it is <tt>null</tt> all {@link CustomDatatype} will be collected.
*/
public DatatypeFinder(Project originProject, FilterType filterType, IDatatype type) {
super(originProject, filterType);
foundDatatypes = new LinkedList<CustomDatatype>();
this.type = type;
//Start visiting
originProject.accept(this);
}
示例7: initializeNested
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
@Override
protected void initializeNested() {
// this is not optimal if a configuration is used directly for projection but ok for now
// (re) initializes self and leaves parent untouched where instances may be reused
if (null == variables) {
Project project = configuration.getProject();
VariableCollector collector = new VariableCollector(this, filter);
project.accept(collector);
variables = collector.getCollectedVariables();
index(variables);
}
}
示例8: visitProjectImport
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
@Override
public void visitProjectImport(ProjectImport pImport) {
Project imported = pImport.getResolved();
if (null != imported) {
if (!done.contains(imported)) { // cycle prevention
done.add(imported);
imported.accept(this);
}
}
}
示例9: testStepwiseExtentionOfSet
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Tests the stepwise creation of nested Values of a set.
* This is needed for the stepwise configuration inside the GUI.
* @throws ValueDoesNotMatchTypeException Must not occur, otherwise {@link ValueFactory} is broken.
* @throws ConfigurationException Must not occur, otherwise {@link SetVariable#setValue(Value, IAssignmentState)}
* is broken.
*/
@Test
public void testStepwiseExtentionOfSet() throws ValueDoesNotMatchTypeException, ConfigurationException {
String testValue = "1";
// Retrieve setVariable
SetVariable setVar = retrieveSetVariable(set);
Container setType = (Container) setVar.getDeclaration().getType();
IDatatype setOfType = setType.getContainedType();
// Extend variable (insert new nested element) and configure nested element
IDecisionVariable nestedElement = createNestedElement(setVar);
Value tmpNestedValue = ValueFactory.createValue(setOfType, testValue);
nestedElement.setValue(tmpNestedValue, AssignmentState.ASSIGNED);
// Test correct behavior of configuring the nested element.
Assert.assertEquals(testValue, nestedElement.getValue().getValue().toString());
ContainerValue completeValue = (ContainerValue) setVar.getValue();
Value nestedValue = completeValue.getElement(0);
Assert.assertNotNull(nestedValue);
Assert.assertNotNull(nestedValue.getValue());
Assert.assertEquals(testValue, nestedValue.getValue().toString());
// Test whether the variable would be saved correctly
Project confProject = configuration.toProject(true);
StringWriter sWriter = new StringWriter();
IVMLWriter writer = new IVMLWriter(sWriter);
confProject.accept(writer);
StringBuffer output = sWriter.getBuffer();
String savedValueAssignment = getValue(output, 0);
String expected = set.getName() + " " + IvmlKeyWords.ASSIGNMENT + " "
+ StringProvider.toIvmlString(completeValue);
Assert.assertEquals(expected, savedValueAssignment);
}
示例10: testConstraintVariablesAreConsidered
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Tests whether constraints of constraint variables will be considered.
* @throws ValueDoesNotMatchTypeException Must not occur, otherwise {@link ConstraintType}s are broken.
* @throws CSTSemanticException Must not occur, otherwise {@link ConstraintType}s are broken.
*/
@Test
public void testConstraintVariablesAreConsidered() throws ValueDoesNotMatchTypeException, CSTSemanticException {
// Create Project with 3 declarations and a constraint variable using 2 of them
Project project = new Project("testConstraintVariablesAreConsidered");
DecisionVariableDeclaration declA = new DecisionVariableDeclaration("intA", IntegerType.TYPE, project);
DecisionVariableDeclaration declB = new DecisionVariableDeclaration("intB", IntegerType.TYPE, project);
DecisionVariableDeclaration declC = new DecisionVariableDeclaration("intC", IntegerType.TYPE, project);
project.add(declA);
project.add(declB);
project.add(declC);
DecisionVariableDeclaration declConstraint = new DecisionVariableDeclaration("constraint", ConstraintType.TYPE,
project);
OCLFeatureCall compCall = new OCLFeatureCall(isDefined(declA), OclKeyWords.AND, isDefined(declB));
declConstraint.setValue(compCall);
project.add(declConstraint);
// Create configuration out of valid project
ProjectTestUtilities.validateProject(project);
Configuration config = new Configuration(project);
// Check importance
MandatoryDeclarationClassifier finder = new MandatoryDeclarationClassifier(config, FilterType.ALL);
project.accept(finder);
VariableContainer importances = finder.getImportances();
// Test correct behavior
assertVariable(config.getDecision(declA), true, importances);
assertVariable(config.getDecision(declB), true, importances);
assertVariable(config.getDecision(declC), false, importances);
assertVariable(config.getDecision(declConstraint), false, importances);
}
示例11: ProjectRewriteVisitor
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Default constructor for this class.
* @param originProject The project where the visiting shall start
* @param filterType Specifies whether project imports shall be considered or not.
*/
public ProjectRewriteVisitor(Project originProject, FilterType filterType) {
this.originProject = originProject;
this.filterType = filterType;
done = new HashSet<Project>();
modifiers = new HashMap<Class<? extends ModelElement>, List<IModelElementFilter<?>>>();
importModifiers = new ArrayList<IProjectImportFilter>();
projectModifiers = new ArrayList<IProjectModifier>();
context = new RewriteContext();
// Create initial structure table, for faster lookup during rewriting
InitialStructureCollector initializer = new InitialStructureCollector(originProject, filterType,
context.getLookUpTable());
originProject.accept(initializer);
}
示例12: testOmmitFrozenConstraintVariables
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Tests whether filtering of frozen constraint variables works.
* @throws ValueDoesNotMatchTypeException Must not occur, otherwise the {@link ValueFactory} or
* {@link net.ssehub.easy.varModel.model.AbstractVariable#setValue(String)} are broken.
* @throws CSTSemanticException Must not occur, otherwise
*/
@Test
public void testOmmitFrozenConstraintVariables() throws ValueDoesNotMatchTypeException, CSTSemanticException {
// Create original project with one declaration and one comment
Project p = new Project("testProjectConstraintVar");
DecisionVariableDeclaration intDecl = new DecisionVariableDeclaration("intA", IntegerType.TYPE, p);
p.add(intDecl);
DecisionVariableDeclaration constVar = new DecisionVariableDeclaration("constVar", ConstraintType.TYPE, p);
p.add(constVar);
Variable constraintVar = new Variable(intDecl);
OCLFeatureCall comparison = new OCLFeatureCall(constraintVar, OclKeyWords.GREATER, ZERO);
constVar.setValue(comparison);
DecisionVariableDeclaration constVar2 = new DecisionVariableDeclaration("constVar2", ConstraintType.TYPE, p);
p.add(constVar2);
OCLFeatureCall comparison2 = new OCLFeatureCall(constraintVar, OclKeyWords.GREATER, ZERO);
constVar2.setValue(comparison2);
// Freeze all, but one constraint
p.add(new FreezeBlock(new IFreezable[] {intDecl, constVar}, null, null, p));
// Project should be valid
ProjectTestUtilities.validateProject(p);
Configuration config = new Configuration(p);
// Create copy while omitting the comment
ProjectRewriteVisitor copynator = new ProjectRewriteVisitor(p, FilterType.NO_IMPORTS);
copynator.addModelCopyModifier(new FrozenConstraintVarFilter(config));
p.accept(copynator);
// Copied project should contain the declaration, freezeblock, and unfrozen constraint
ProjectTestUtilities.validateProject(p);
assertProjectContainment(p, intDecl, true, 3);
assertProjectContainment(p, constVar2, true, 3);
assertProjectContainment(p, constVar, false, 3);
}
示例13: run
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
@Override
public void run(IAction action) {
if (selection instanceof IStructuredSelection) {
StringBuilder errors = new StringBuilder();
for (Iterator<?> it = ((IStructuredSelection) selection).iterator(); it.hasNext();) {
Object element = it.next();
IProject project = null;
if (element instanceof IProject) {
project = (IProject) element;
} else if (element instanceof IAdaptable) {
project = (IProject) ((IAdaptable) element).getAdapter(IProject.class);
}
try {
if (project != null && NatureUtils.hasNature(project, EASyNature.NATURE_ID)) {
String id = ResourcesMgmt.INSTANCE.getIDfromResource(project);
PLPInfo plp = SPLsManager.INSTANCE.getPLP(id);
Project mainProject = plp.getProject();
ProjectRewriteVisitor rewriter = new ProjectRewriteVisitor(mainProject, FilterType.ALL);
DeclarationFinder finder = new DeclarationFinder(mainProject, FilterType.ALL, null);
List<DecisionVariableDeclaration> allDeclarations = new ArrayList<DecisionVariableDeclaration>();
List<AbstractVariable> tmpList = finder.getVariableDeclarations(VisibilityType.ALL);
for (int i = 0, end = tmpList.size(); i < end; i++) {
AbstractVariable declaration = tmpList.get(i);
if (declaration instanceof DecisionVariableDeclaration
&& !(declaration.getNameSpace().equals(QmConstants.PROJECT_OBSERVABLESCFG)
&& declaration.getName().equals("qualityParameters"))) {
allDeclarations.add((DecisionVariableDeclaration) declaration);
}
};
ProjectFreezeModifier freezer = new ProjectFreezeModifier(mainProject, allDeclarations);
rewriter.addProjectModifier(freezer);
// Freezes all projects as a side effect, but won't save them
mainProject.accept(rewriter);
}
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (errors.length() > 0) {
MessageDialog.openError(shell, "Error while modifying natures", errors.toString());
}
}
}
示例14: visitProject
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* {@inheritDoc} <br/>
* <b><font color="red">Attention:</font></b> This method will modify the visited project as a side effect.
* If the original project should not be modified, it is necessary to create a copy first via the
* {@link ProjectCopyVisitor}.
*/
@Override
public void visitProject(Project project) {
if (!done.contains(project)) {
context.addUsedProject(project);
done.add(project);
boolean isImportedProject = originProject != project;
boolean anyProject = FilterType.ALL == filterType;
boolean onlyImports = FilterType.ONLY_IMPORTS == filterType && isImportedProject;
boolean noImports = FilterType.NO_IMPORTS == filterType && !isImportedProject;
if (anyProject || onlyImports || noImports) {
// Remove all elements from project
ProjectImport[] pImports = new ProjectImport[project.getImportsCount()];
for (int i = 0; i < pImports.length; i++) {
pImports[i] = project.getImport(i);
}
ContainableModelElement[] unfilteredElements = new ContainableModelElement[project.getElementCount()];
for (int i = 0; i < unfilteredElements.length; i++) {
unfilteredElements[i] = project.getElement(i);
}
project.clear();
// visit all elements to check which shall be kept and add them again
for (int i = 0; i < pImports.length; i++) {
ProjectImport unfilteredImport = pImports[i];
for (int j = 0, n = importModifiers.size(); j < n && null != pImports[i]; j++) {
IProjectImportFilter currentModifier = importModifiers.get(j);
pImports[i] = currentModifier.handleImport(pImports[i], context);
}
if (null != pImports[i]) {
project.addImport(pImports[i]);
Project importedProject = pImports[i].getResolved();
if (null != importedProject) {
visitProject(importedProject);
}
} else {
Project removedProject = unfilteredImport.getResolved();
if (null != removedProject) {
DeletedElementsCollector collector = new DeletedElementsCollector(removedProject,
FilterType.ALL, context);
removedProject.accept(collector);
}
}
}
currentProject = project;
for (int i = 0; i < unfilteredElements.length; i++) {
unfilteredElements[i].accept(this);
}
// Project modifier
for (int i = 0, end = projectModifiers.size(); i < end; i++) {
IProjectModifier modifier = projectModifiers.get(i);
if (null != modifier) {
modifier.modifyProject(project, context);
}
}
}
if (project == this.originProject) {
context.removeElementsOfRemovedImports();
if (context.elementesWereRemoved()) {
/*
* Elements where removed start filtering again, maybe there exist some elements pointing
* to the removed elements.
*/
revisit(project);
}
}
}
}
示例15: testConfiguration
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Tests the configuration wrapper.
*/
@Test
public void testConfiguration() {
net.ssehub.easy.varModel.confModel.Configuration cfg = DefaultConfiguration.createDefaultConfiguration();
Assert.assertNotNull("creating default IVML configuration failed", cfg);
Configuration configuration = new Configuration(cfg);
Assert.assertNotNull(configuration);
Project project = cfg.getProject();
Assert.assertNotNull(project);
Assert.assertEquals(configuration.getName(), cfg.getName());
Assert.assertEquals(configuration.getQualifiedName(), project.getQualifiedName());
Assert.assertEquals(configuration.getTypeName(), project.getType().getName());
Assert.assertEquals(configuration.getQualifiedType(), project.getType().getQualifiedName());
TestVisitor visitor = new TestVisitor(cfg, configuration);
project.accept(visitor);
try {
compare(configuration.selectByName("pInt"), cfg, new NameSelector("pInt"));
compare(configuration.selectByName("p.*"), cfg, new NamePatternSelector("p.*"));
compare(configuration.selectByName("sse.*"), cfg, new NamePatternSelector("sse.*"));
compare(configuration.selectByType("Boolean"), cfg, new TypeSelector("Boolean"));
compare(configuration.selectByType("Int.*"), cfg, new TypePatternSelector("Int.*"));
compare(configuration.selectByType("SSE.*"), cfg, new TypePatternSelector("SSE.*"));
compare(configuration.selectByAttribute("bindingTime"), cfg, new AttributeSelector("bindingTime"));
compare(configuration.selectByAttribute("bind.*"), cfg, new AttributePatternSelector("bind.*"));
compare(configuration.selectByAttribute("bla.*"), cfg, new AttributePatternSelector("bla.*"));
// emulate external call
IvmlElement bindingTime = Utils.getAttributeDeclaration(configuration, "noAttribute");
Assert.assertNull(bindingTime); // just a x-check
bindingTime = Utils.getAttributeDeclaration(configuration, "bindingTime");
Assert.assertNotNull(bindingTime);
compare(configuration.selectByAttribute(bindingTime.getQualifiedName(), 1), cfg,
new AttributeSelector("bindingTime", 1));
compare(configuration.selectByAttribute(bindingTime.getQualifiedName(), 100), cfg,
new AttributeSelector("bindingTime", 100));
Assert.assertEquals(configuration.selectByAttribute(
bindingTime.getQualifiedName(), null).variables().size(), 0);
// the case that the element was not resolved
Assert.assertEquals(configuration.selectByAttribute(null, 100).variables().size(), 0);
} catch (VilException e) {
Assert.fail("unexpected exception " + e.getMessage());
}
}