diff options
Diffstat (limited to 'extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext')
9 files changed, 0 insertions, 733 deletions
diff --git a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/GenerateStereotypeApplicationWithVSL.mwe2 b/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/GenerateStereotypeApplicationWithVSL.mwe2 deleted file mode 100644 index 8467596632f..00000000000 --- a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/GenerateStereotypeApplicationWithVSL.mwe2 +++ /dev/null @@ -1,113 +0,0 @@ -module org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.StereotypeApplicationWithVSL - -import org.eclipse.emf.mwe.utils.* -import org.eclipse.xtext.generator.* -import org.eclipse.xtext.ui.generator.* - -var grammarURI = "classpath:/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/StereotypeApplicationWithVSL.xtext" -var file.extensions = "StereotypeApplicationWithVSL" -var projectName = "org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext" -var runtimeProject = "../${projectName}" - -Workflow { - /* bean = StandaloneSetup { - platformUri = "${runtimeProject}/.." - } */ - - bean = StandaloneSetup { - platformUri = "${runtimeProject}/.." - registerGeneratedEPackage = "org.eclipse.uml2.uml.UMLPackage" - registerGeneratedEPackage = "org.eclipse.uml2.codegen.ecore.genmodel.GenModelPackage" - uriMap = {from="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore" - to="platform:/resource/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/model/Ecore.ecore"} - uriMap = {from="platform:/plugin/org.eclipse.emf.ecore/model/Ecore.genmodel" - to="platform:/resource/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/model/Ecore.genmodel"} - } - - component = DirectoryCleaner { - directory = "${runtimeProject}/src-gen" - } - - component = DirectoryCleaner { - directory = "${runtimeProject}.ui/src-gen" - } - - component = Generator { - pathRtProject = runtimeProject - pathUiProject = "${runtimeProject}.ui" - projectNameRt = projectName - projectNameUi = "${projectName}.ui" - language = { - uri = grammarURI - fileExtensions = file.extensions - - // Java API to access grammar elements (required by several other fragments) - fragment = grammarAccess.GrammarAccessFragment {} - - // generates Java API for the generated EPackages - fragment = ecore.EcoreGeneratorFragment { - referencedGenModels = - "platform:/resource/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/model/UML.genmodel" - referencedGenModels = - "platform:/resource/org.eclipse.papyrus.marte.vsl/src-gen/org/eclipse/papyrus/marte/vsl/VSL.genmodel" - - } - - // the serialization component - fragment = parseTreeConstructor.ParseTreeConstructorFragment {} - - // a custom ResourceFactory for use with EMF - fragment = resourceFactory.ResourceFactoryFragment { - fileExtensions = file.extensions - } - - // The antlr parser generator fragment. - fragment = parser.antlr.XtextAntlrGeneratorFragment { - // options = { - // backtrack = true - // } - } - - // java-based API for validation - fragment = validation.JavaValidatorFragment { - composedCheck = "org.eclipse.xtext.validation.ImportUriValidator" - composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator" - // registerForImportedPackages = true - } - - // scoping and exporting API - fragment = scoping.ImportURIScopingFragment {} - fragment = exporting.SimpleNamesFragment {} - - // scoping and exporting API - // fragment = scoping.ImportNamespacesScopingFragment {} - // fragment = exporting.QualifiedNamesFragment {} - // fragment = builder.BuilderIntegrationFragment {} - - // formatter API - fragment = formatting.FormatterFragment {} - - // labeling API - fragment = labeling.LabelProviderFragment {} - - // outline API - fragment = outline.OutlineTreeProviderFragment {} - fragment = outline.QuickOutlineFragment {} - - // quickfix API - fragment = quickfix.QuickfixProviderFragment {} - - // content assist API - fragment = contentAssist.JavaBasedContentAssistFragment {} - - // generates a more lightweight Antlr parser and lexer tailored for content assist - fragment = parser.antlr.XtextAntlrUiGeneratorFragment {} - - // project wizard (optional) - // fragment = projectWizard.SimpleProjectWizardFragment { - // generatorProjectName = "${projectName}.generator" - // modelFileExtension = file.extensions - // } - } - } -} diff --git a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/StereotypeApplicationWithVSL.xtext b/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/StereotypeApplicationWithVSL.xtext deleted file mode 100644 index 7c37eaa060f..00000000000 --- a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/StereotypeApplicationWithVSL.xtext +++ /dev/null @@ -1,34 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * 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: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -grammar org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.StereotypeApplicationWithVSL -//with org.eclipse.xtext.common.Terminals -with org.eclipse.papyrus.marte.vsl.VSL - -import "http://www.eclipse.org/uml2/5.0.0/UML" as uml - -generate stereotypeApplicationWithVSL "http://www.eclipse.org/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/StereotypeApplicationWithVSL" - -StereotypeApplicationsRule : - (stereotypeApplications += StereotypeApplicationRule)* ; - -StereotypeApplicationRule : - '<<' stereotype = [uml::Stereotype] '>>' - (tagSpecification += TagSpecificationRule (',' tagSpecification += TagSpecificationRule)*)?; - -TagSpecificationRule : - property = [uml::Property] (value = ExpressionValueRule) ; - -ExpressionValueRule : - '=' expression = Expression ;
\ No newline at end of file diff --git a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/StereotypeApplicationWithVSLPostProcessor.ext b/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/StereotypeApplicationWithVSLPostProcessor.ext deleted file mode 100644 index d1707a68d37..00000000000 --- a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/StereotypeApplicationWithVSLPostProcessor.ext +++ /dev/null @@ -1,61 +0,0 @@ -import ecore;
-//import uml ;
-
-process(xtext::GeneratedMetamodel this) :
- process(ePackage)
-;
-
-process(EPackage this) :
- eClassifiers.typeSelect(EClass).process()
-;
-
-/*process(EClass this) :
- switch (name) {
- case "Foo": (addOperation("doFoo", getEcoreDataType("EString")) -> addOperation("getBar", ePackage.getEClassifier("Bar")))
- default: null
- }
-;*/
-
-process(EClass theClass) :
- //switch (theClass.name) {
- // case "ExpressionValueRule":
- addOperation(theClass, getTypeEClass(), "getExpectedType",
- "return org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.validation.ContextUtil.getExpectedType(this) ;") ->
- addOperation(theClass, getElementEClass(), "getContextElement",
- "return org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.validation.ContextUtil.getContextElement(this) ;")
- // default: null
- //}
-;
-
-EClass getTypeEClass () :
- JAVA org.eclipse.papyrus.marte.vsl.extensions.XtendUtil.getTypeEClass() ;
-
-EClass getElementEClass () :
- JAVA org.eclipse.papyrus.marte.vsl.extensions.XtendUtil.getElementEClass() ;
-
-addOperation(EClass this, EClassifier type, String operationName, String body) :
- let op = newOperation(this, operationName, type) :
- newDelegatingBodyAnnotation(op, body)
-;
-
-create EOperation newOperation(EClass owner, String name, EClassifier type) :
- setName(name) -> setEType(type) -> owner.eOperations.add(this)
-;
-
-create EAnnotation newDelegatingBodyAnnotation(EOperation op, String body) :
- let d = new EStringToStringMapEntry :
- setSource("http://www.eclipse.org/emf/2002/GenModel") ->
- d.setKey("body") ->
- //d.setValue((op.eType != null ? "return " : "") + op.delegateMethodName() + "(this);") ->
- //d.setValue((op.eType != null ? "return " : "") + op.delegateMethodName() ) ->
- d.setValue(body) ->
- details.add(d) ->
- op.eAnnotations.add(this)
-;
-
-//delegateMethodName(EOperation this) :
- //"com.mycompany." + eContainingClass.name + "Helper." + name
-// "
-// return org.eclipse.papyrus.marte.vsl.validation.VSLContextUtil.getExpectedType(this) ;
-// "
-//;
\ No newline at end of file diff --git a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/StereotypeApplicationWithVSLRuntimeModule.java b/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/StereotypeApplicationWithVSLRuntimeModule.java deleted file mode 100644 index ab75ed70142..00000000000 --- a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/StereotypeApplicationWithVSLRuntimeModule.java +++ /dev/null @@ -1,21 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * 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: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext; - -/** - * Use this class to register components to be used at runtime / without the Equinox extension registry. - */ -public class StereotypeApplicationWithVSLRuntimeModule extends org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.AbstractStereotypeApplicationWithVSLRuntimeModule { - -} diff --git a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/StereotypeApplicationWithVSLStandaloneSetup.java b/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/StereotypeApplicationWithVSLStandaloneSetup.java deleted file mode 100644 index 3ee08d4e8fa..00000000000 --- a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/StereotypeApplicationWithVSLStandaloneSetup.java +++ /dev/null @@ -1,27 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * 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: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext; - - -/** - * Initialization support for running Xtext languages - * without equinox extension registry - */ -public class StereotypeApplicationWithVSLStandaloneSetup extends StereotypeApplicationWithVSLStandaloneSetupGenerated { - - public static void doSetup() { - new StereotypeApplicationWithVSLStandaloneSetup().createInjectorAndDoEMFRegistration(); - } -} diff --git a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/formatting/StereotypeApplicationWithVSLFormatter.java b/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/formatting/StereotypeApplicationWithVSLFormatter.java deleted file mode 100644 index 671d4036f57..00000000000 --- a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/formatting/StereotypeApplicationWithVSLFormatter.java +++ /dev/null @@ -1,39 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * 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: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.formatting; - -import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter; -import org.eclipse.xtext.formatting.impl.FormattingConfig; - -/** - * This class contains custom formatting description. - * - * see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#formatting - * on how and when to use it - * - * Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example - */ -public class StereotypeApplicationWithVSLFormatter extends AbstractDeclarativeFormatter { - - @Override - protected void configureFormatting(FormattingConfig c) { - org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.services.StereotypeApplicationWithVSLGrammarAccess f = (org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.services.StereotypeApplicationWithVSLGrammarAccess) getGrammarAccess(); - - c.setLinewrap(0, 1, 2).before(f.getSL_COMMENTRule()); - c.setLinewrap(0, 1, 2).before(f.getML_COMMENTRule()); - c.setLinewrap(0, 1, 1).after(f.getML_COMMENTRule()); - - // ... - } -} diff --git a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/scoping/StereotypeApplicationWithVSLScopeProvider.java b/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/scoping/StereotypeApplicationWithVSLScopeProvider.java deleted file mode 100644 index f6ea023e42d..00000000000 --- a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/scoping/StereotypeApplicationWithVSLScopeProvider.java +++ /dev/null @@ -1,155 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * 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: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.scoping; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.stereotypeApplicationWithVSL.StereotypeApplicationRule; -import org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.stereotypeApplicationWithVSL.TagSpecificationRule; -import org.eclipse.papyrus.marte.vsl.scoping.VSLScopeProvider; -import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementUtil; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Property; -import org.eclipse.uml2.uml.Stereotype; -import org.eclipse.xtext.resource.IEObjectDescription; -import org.eclipse.xtext.scoping.IScope; -import org.eclipse.xtext.scoping.Scopes; -import org.eclipse.xtext.scoping.impl.SimpleScope; - -/** - * This class contains custom scoping description. - * - * see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#scoping - * on how and when to use it - * - */ -public class StereotypeApplicationWithVSLScopeProvider extends VSLScopeProvider { - - /* **************************************************************** - * - * Custom scoping for StereotypeApplicationRule_stereotype - * - * *************************************************************** - */ - - public IScope scope_StereotypeApplicationRule_stereotype(StereotypeApplicationRule ctx, EReference ref) { - return create___StereotypeApplicationRule_stereotype___Scope(ctx); - } - - private IScope create___StereotypeApplicationRule_stereotype___Scope(StereotypeApplicationRule ctx) { - Element element = (Element) ContextElementUtil.getContextElement(ctx.eResource()); - if (element == null) { - return null; - } - List<Stereotype> applicableStereotypes = element.getApplicableStereotypes(); - Iterable<IEObjectDescription> visibleStereotypes = Scopes.scopedElementsFor(applicableStereotypes); - return new SimpleScope(visibleStereotypes); - } - - /* **************************************************************** - * - * Custom scoping for StereotypeApplicationRule_stereotype - * - * *************************************************************** - */ - - public IScope scope_TagSpecificationRule_property(TagSpecificationRule ctx, EReference ref) { - EObject context = ctx; - while (context != null && !(context instanceof StereotypeApplicationRule)) { - context = context.eContainer(); - } - if (context == null || !(context instanceof StereotypeApplicationRule) || ((StereotypeApplicationRule) context).getStereotype() == null) { - return null; - } - - return create___TagSpecificationRule_property___Scope((((StereotypeApplicationRule) context).getStereotype())); - } - - private IScope create___TagSpecificationRule_property___Scope(Stereotype stereotype) { - IScope result = null; - - // build the stereotype inheritance hierarchy - - List<Property> visibleProperties = new ArrayList<Property>(); - visibleProperties.addAll(stereotype.getAllAttributes()); - - // removes derived properties or those which name starts with "base_" - List<Property> filteredList = new ArrayList<Property>(stereotype.getAllAttributes()); - for (Property p : filteredList) { - if (p.getName() == null || p.getName().startsWith("base_") || p.isDerived()) { - visibleProperties.remove(p); - } - } - - // List<List<Stereotype>> inheritanceStructure = new ArrayList<List<Stereotype>>() ; - // List<Stereotype> tmpList = new ArrayList<Stereotype>() ; - // tmpList.add(stereotype) ; - // - // do { - // inheritanceStructure.add(tmpList) ; - // List<Stereotype> localStereotypeList = new ArrayList<Stereotype>() ; - // for (Stereotype currentStereotype : tmpList) { - // for (Classifier general : currentStereotype.getGenerals()) { - // if (general instanceof Stereotype) - // localStereotypeList.add((Stereotype)general) ; - // } - // } - // tmpList = new ArrayList<Stereotype>() ; - // tmpList.addAll(localStereotypeList) ; - // } while (!tmpList.isEmpty()); - // - // // builds the nested scope - // - // if (! inheritanceStructure.isEmpty()) { - // List<Property> visibleProperties = new ArrayList<Property>() ; - // List<Property> filteredProperties = new ArrayList<Property>() ; - // List<Stereotype> currentList = inheritanceStructure.get(inheritanceStructure.size() - 1) ; - // for (Stereotype currentStereotype : currentList) { - // visibleProperties.addAll(currentStereotype.getOwnedAttributes()) ; - // filteredProperties.addAll(currentStereotype.getOwnedAttributes()) ; - // for (Property p : filteredProperties) { - // if (p.getName() == null || - // p.getName().startsWith("base_") || - // p.isDerived()) - // visibleProperties.remove(p) ; - // } - // } - Iterable<IEObjectDescription> visiblePropertiesIterable = Scopes.scopedElementsFor(visibleProperties); - result = new SimpleScope(visiblePropertiesIterable); - // for (int i = inheritanceStructure.size() - 2 ; i >= 0 ; i--) { - // visibleProperties = new ArrayList<Property>() ; - // currentList = inheritanceStructure.get(i) ; - // filteredProperties = new ArrayList<Property>() ; - // for (Stereotype currentStereotype : currentList) { - // visibleProperties.addAll(currentStereotype.getOwnedAttributes()) ; - // filteredProperties.addAll(currentStereotype.getOwnedAttributes()) ; - // } - // for (Property p : filteredProperties) { - // if (p.getName() == null || - // p.getName().startsWith("base_") || - // p.isDerived()) - // visibleProperties.remove(p) ; - // } - // visiblePropertiesIterable = - // Scopes.scopedElementsFor(visibleProperties) ; - // result = new SimpleScope(result, visiblePropertiesIterable) ; - // } - // } - - return result; - } -} diff --git a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/validation/ContextUtil.java b/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/validation/ContextUtil.java deleted file mode 100644 index 090dd929e3c..00000000000 --- a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/validation/ContextUtil.java +++ /dev/null @@ -1,47 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- *
- * 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:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.validation;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.stereotypeApplicationWithVSL.TagSpecificationRule;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Type;
-
-public class ContextUtil {
- public static Type getExpectedType(EObject rule) {
- EObject context = rule;
- while (context != null && !(context instanceof TagSpecificationRule)) {
- context = context.eContainer();
- }
- if (context != null) {
- TagSpecificationRule tag = (TagSpecificationRule) context;
- if (tag.getProperty() != null) {
- return tag.getProperty().getType();
- }
- }
- return null;
- }
-
- public static Element getContextElement(EObject rule) {
- EObject context = rule;
- while (context != null && !(context instanceof TagSpecificationRule)) {
- context = context.eContainer();
- }
- if (context != null) {
- TagSpecificationRule tag = (TagSpecificationRule) context;
- return tag.getProperty();
- }
- return null;
- }
-}
diff --git a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/validation/StereotypeApplicationWithVSLJavaValidator.java b/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/validation/StereotypeApplicationWithVSLJavaValidator.java deleted file mode 100644 index 2cc4a4aa40b..00000000000 --- a/extraplugins/marte/textedit/org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext/src/org/eclipse/papyrus/marte/textedit/stereotypeapplicationwithvsl/xtext/validation/StereotypeApplicationWithVSLJavaValidator.java +++ /dev/null @@ -1,236 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA LIST. - * - * - * 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: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.validation; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.stereotypeApplicationWithVSL.ExpressionValueRule; -import org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.stereotypeApplicationWithVSL.StereotypeApplicationRule; -import org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.stereotypeApplicationWithVSL.StereotypeApplicationWithVSLPackage; -import org.eclipse.papyrus.marte.textedit.stereotypeapplicationwithvsl.xtext.stereotypeApplicationWithVSL.TagSpecificationRule; -import org.eclipse.papyrus.marte.vsl.extensions.VSLContextUtil; -import org.eclipse.papyrus.marte.vsl.vSL.CollectionOrTuple; -import org.eclipse.papyrus.marte.vsl.validation.VSLJavaValidator; -import org.eclipse.uml2.uml.Classifier; -import org.eclipse.uml2.uml.NamedElement; -import org.eclipse.uml2.uml.Property; -import org.eclipse.uml2.uml.Stereotype; -import org.eclipse.uml2.uml.Type; -import org.eclipse.xtext.validation.Check; - - -public class StereotypeApplicationWithVSLJavaValidator extends AbstractStereotypeApplicationWithVSLJavaValidator { - - private static boolean valid_Stereotype = true; - private static boolean valid_Expression = true; - - public static boolean validate() { - return valid_Stereotype && valid_Expression; - } - - // @Check - // public void checkGreetingStartsWithCapital(Greeting greeting) { - // if (!Character.isUpperCase(greeting.getName().charAt(0))) { - // warning("Name should start with a capital", MyDslPackage.GREETING__NAME); - // } - // } - - @Check - public void checkStereotypeApplicationRule_Stereotype(StereotypeApplicationRule stereotypeApplicationRule) { - Stereotype appliedStereotype = stereotypeApplicationRule.getStereotype(); - valid_Stereotype = true; - if (appliedStereotype != null) { - // checks if all the mandatory properties have been fixed - List<Property> mandatoryProperties = new ArrayList<Property>(); - for (Property p : appliedStereotype.getAllAttributes()) { - if (p.getLower() > 0 && !p.getName().startsWith("base_") && !p.isDerived() && !(p.getDefaultValue() == null)) { - mandatoryProperties.add(p); - } - } - if (mandatoryProperties.isEmpty()) {// not necessary to go further... - valid_Stereotype = true; - return; - } - // determines which mandatory properties have not been specified - List<Property> actuallySpecifiedProperties = new ArrayList<Property>(); - for (TagSpecificationRule tagSpec : stereotypeApplicationRule.getTagSpecification()) { - actuallySpecifiedProperties.add(tagSpec.getProperty()); - } - List<String> missingPropertyNames = new ArrayList<String>(); - for (Property mandatoryProperty : mandatoryProperties) { - if (!actuallySpecifiedProperties.contains(mandatoryProperty)) { - missingPropertyNames.add(mandatoryProperty.getName()); - } - } - if (missingPropertyNames.isEmpty()) {// not necessary to go further... - valid_Stereotype = true; - return; - } - // builds the error message - valid_Stereotype = false; - String errorMessage = (missingPropertyNames.size() > 1 ? "Properties " : "Property ") + missingPropertyNames.get(0); - for (int i = 1; i < missingPropertyNames.size(); i++) { - errorMessage += ", " + missingPropertyNames.get(i); - } - errorMessage += (missingPropertyNames.size() > 1 ? " are " : " is ") + " not optional."; - error(errorMessage, stereotypeApplicationRule, StereotypeApplicationWithVSLPackage.eINSTANCE.getStereotypeApplicationRule_Stereotype(), INSIGNIFICANT_INDEX); - } - } - - @Check - public void checkExpressionValueRule_Expression(ExpressionValueRule expressionValueRule) { - valid_Expression = true; - if (expressionValueRule != null && expressionValueRule.getExpression() != null) { - Property valuedProperty = ((TagSpecificationRule) expressionValueRule.eContainer()).getProperty(); - if (valuedProperty == null) { - valid_Expression = true; - return; - } - VSLJavaValidator.setExpectedType(valuedProperty.getType()); - // Type inferedType = new VSLTypeInferenceUtil(valuedProperty.getType()) - // .typeOfExpression(expressionValueRule.getExpression()) ; - // - // if (inferedType != valuedProperty.getType()) { - // String message = "" + - // (inferedType == null ? - // "Could not infer type of expression. " : - // "Found an expression of type " + inferedType.getName()+ ". "); - // message += "Expecting an expression of type " + valuedProperty.getType().getName() ; - // error(message, StereotypeApplicationWithVSLPackage.EXPRESSION_VALUE_RULE__EXPRESSION) ; - // } - - VSLValidationResult validationResult = VSLJavaValidator.eInstance.checkExpressionRule(expressionValueRule.getExpression()); - if (!validationResult.errorFound()) { - Type inferedType = validationResult.inferedType(); - if (VSLContextUtil.isAChoiceType((Classifier) valuedProperty.getType())) { - boolean found = false; - for (NamedElement n : VSLContextUtil.getChoiceAttribs((Classifier) valuedProperty.getType())) { - Property p = (Property) n; - // ScopingHelper scopingHelper = VSLScopeProvider.eInstance.new ScopingHelper(expressionValueRule.getExpression()) ; - // if (p.getType() != null && inferedType != null && inferedType.conformsTo(valuedProperty.getType())) { - if (p.getType() == inferedType || ((Classifier) inferedType).getGenerals().contains(p.getType())) { - found = true; - } - } - if (!found) { - String message = "" + - (inferedType == null ? - "Could not infer type of expression. " : - "Found an expression of type " + inferedType.getName() + ". "); - message += "Expecting an expression of type " + valuedProperty.getType().getName(); - error(message, StereotypeApplicationWithVSLPackage.eINSTANCE.getExpressionValueRule_Expression()); - valid_Expression = false; - } - else { - valid_Expression = true; - } - } - else if (VSLContextUtil.isAnIntervalType((Classifier) valuedProperty.getType())) { - boolean found = false; - Property p = (Property) VSLContextUtil.getIntervalAttrib((Classifier) valuedProperty.getType()); - if (p.getType() == inferedType || ((Classifier) inferedType).getGenerals().contains(p.getType())) { - found = true; - } - if (!found) { - String message = "" + - (inferedType == null ? - "Could not infer type of expression. " : - "Found an expression of type " + inferedType.getName() + ". "); - message += "Expecting an expression of type " + valuedProperty.getType().getName(); - error(message, StereotypeApplicationWithVSLPackage.eINSTANCE.getExpressionValueRule_Expression()); - valid_Expression = false; - } - else { - valid_Expression = true; - } - } - else if (inferedType != valuedProperty.getType()) { - if (!(valuedProperty.getType().getName().equals(inferedType.getName()) && (valuedProperty.getType().getName().equals("String") || - valuedProperty.getType().getName().equals("Integer") || - valuedProperty.getType().getName().equals("UnlimitedNatural") || valuedProperty.getType().getName().equals("Boolean")))) { - String message = "" + - (inferedType == null ? - "Could not infer type of expression. " : - "Found an expression of type " + inferedType.getName() + ". "); - message += "Expecting an expression of type " + valuedProperty.getType().getName(); - error(message, StereotypeApplicationWithVSLPackage.eINSTANCE.getExpressionValueRule_Expression()); - valid_Expression = false; - } - else { - valid_Expression = true; - } - } - if (valuedProperty.getUpper() > 1 || valuedProperty.getUpper() == -1) { - CollectionOrTuple cddColl = VSLJavaValidator.isACollection(expressionValueRule.getExpression()); - boolean errorFound = false; - int cardinality = 1; - if (cddColl == null) { - errorFound = true; - } - else { - cardinality = cddColl.getListOfValues() != null ? cddColl.getListOfValues().getValues().size() : 0; - errorFound = cardinality < valuedProperty.getLower(); - if (!errorFound && valuedProperty.getUpper() != -1) { - errorFound = cardinality > valuedProperty.getUpper(); - } - } - if (errorFound) { - String message = "The multiplicity of property " - + valuedProperty.getName() - + " is [" - + valuedProperty.getLower() - + ".." - + (valuedProperty.getUpper() == -1 ? "*" : valuedProperty.getUpper()) - + "]. "; - if (cddColl != null) { - message += "The expression doest not match the expected multiplicity (cardinality = " - + cardinality - + ")."; - } - else { - message += "The VSL syntax for collections must be used, i.e., '{'<EXPRESSION>(','<EXPRESSION>)*'}'"; - } - error(message, StereotypeApplicationWithVSLPackage.eINSTANCE.getExpressionValueRule_Expression()); - valid_Expression = false; - } - else { - valid_Expression = true; - } - } - else { - CollectionOrTuple cddColl = VSLJavaValidator.isACollection(expressionValueRule.getExpression()); - if (cddColl != null) { - String message = "The property " - + valuedProperty.getName() - + " is not a collection. The expression doest not match the expected multiplicity."; - error(message, StereotypeApplicationWithVSLPackage.eINSTANCE.getExpressionValueRule_Expression()); - valid_Expression = false; - } - else { - valid_Expression = true; - } - } - } - else { - error(validationResult.errorMessage(), - validationResult.validatedRule(), - validationResult.validatedFeature(), - INSIGNIFICANT_INDEX); - valid_Expression = false; - } - } - } - -} |