Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse')
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/VSLUiModule.java36
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/CopyOfVSLProposalProvider.java621
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/FeatureTree.java105
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/Tree.java52
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/VSLContentAssistProcessor.java31
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/VSLProposalProvider.java1540
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/VSLProposalUtils.java488
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/labeling/VSLDescriptionLabelProvider.java37
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/labeling/VSLLabelProvider.java44
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/outline/VSLOutlineNodeAdapterFactory.java32
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/outline/VSLTransformer.java24
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/quickfix/VSLQuickfixProvider.java32
12 files changed, 3042 insertions, 0 deletions
diff --git a/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/VSLUiModule.java b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/VSLUiModule.java
new file mode 100644
index 00000000000..2e9ec0cb3cf
--- /dev/null
+++ b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/VSLUiModule.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * 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.vsl.ui;
+
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.papyrus.marte.vsl.ui.contentassist.VSLContentAssistProcessor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalComparator;
+import org.eclipse.xtext.ui.editor.contentassist.XtextContentAssistProcessor;
+
+import com.google.inject.Binder;
+
+/**
+ * Use this class to register components to be used within the IDE.
+ */
+public class VSLUiModule extends org.eclipse.papyrus.marte.vsl.ui.AbstractVSLUiModule {
+ public VSLUiModule(AbstractUIPlugin plugin) {
+ super(plugin);
+ }
+
+ @Override
+ public Class<? extends IContentAssistProcessor> bindIContentAssistProcessor() {
+ return VSLContentAssistProcessor.class;
+ }
+}
diff --git a/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/CopyOfVSLProposalProvider.java b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/CopyOfVSLProposalProvider.java
new file mode 100644
index 00000000000..7dabcbf39d9
--- /dev/null
+++ b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/CopyOfVSLProposalProvider.java
@@ -0,0 +1,621 @@
+/*****************************************************************************
+ * 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.vsl.ui.contentassist;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.text.contentassist.CompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.papyrus.core.utils.DisplayUtils;
+import org.eclipse.papyrus.marte.vsl.extensions.VSLContextUtil;
+import org.eclipse.papyrus.marte.vsl.extensions.VSLTypeInferenceUtil;
+import org.eclipse.papyrus.marte.vsl.ui.contentassist.AbstractVSLProposalProvider;
+import org.eclipse.papyrus.marte.vsl.vSL.DataTypeName;
+import org.eclipse.papyrus.marte.vsl.vSL.DurationObsName;
+import org.eclipse.papyrus.marte.vsl.vSL.InstantObsName;
+import org.eclipse.papyrus.marte.vsl.vSL.ListOfValueNamePairs;
+import org.eclipse.papyrus.marte.vsl.vSL.NameOrChoiceOrBehaviorCall;
+import org.eclipse.papyrus.marte.vsl.vSL.OperationCallExpression;
+import org.eclipse.papyrus.marte.vsl.vSL.PrimaryExpression;
+import org.eclipse.papyrus.marte.vsl.vSL.PropertyCallExpression;
+import org.eclipse.papyrus.marte.vsl.vSL.QualifiedName;
+import org.eclipse.papyrus.marte.vsl.vSL.ValueNamePair;
+import org.eclipse.papyrus.marte.vsl.vSL.ValueSpecification;
+import org.eclipse.papyrus.marte.vsl.validation.VSLJavaValidator;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.DataType;
+import org.eclipse.uml2.uml.DurationObservation;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.EnumerationLiteral;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Namespace;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.TimeObservation;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.TypedElement;
+import org.eclipse.xtext.Assignment;
+import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext;
+import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor;
+
+/**
+ * see http://www.eclipse.org/Xtext/documentation/latest/xtext.html#contentAssist on how to customize content assistant
+ */
+public class CopyOfVSLProposalProvider extends AbstractVSLProposalProvider {
+
+ private ILabelProvider labelProvider = DisplayUtils.getLabelProvider() ;
+
+
+ /* *************************************************
+ *
+ * Private Utility method for creating a completion proposal
+ *
+ **************************************************/
+
+ protected ICompletionProposal createCompletionProposal(NamedElement namedElement,
+ String completionString,
+ String displayString,
+ ContentAssistContext context) {
+ String additionalProposalInfo = "" + namedElement.getQualifiedName() + "\n" + '(' + namedElement.eClass().getName() + ')' ;
+
+ ICompletionProposal completionProposal = new CompletionProposal(completionString, // String to be inserted
+ context.getOffset(), // Offset
+ context.getSelectedText().length(), // Replacement length
+ completionString.length(), // cursorPosition
+ labelProvider.getImage(namedElement) , // image
+ " " + displayString, // displayString
+ null , // contextInformation
+ additionalProposalInfo // additionalProposalInfo
+ );
+ return completionProposal ;
+ }
+
+ /* *************************************************
+ *
+ * Private utility method for sorting a list of NamedElement by kind and name
+ *
+ **************************************************/
+
+ protected List<NamedElement> sortByKindAndName(List<NamedElement> list) {
+ List<NamedElement> sortedList = new ArrayList<NamedElement>() ;
+ HashMap<EClass, List<NamedElement>> namedElementGroups = new HashMap<EClass, List<NamedElement>>() ;
+
+ for (NamedElement n : list) {
+ if (! namedElementGroups.containsKey(n.eClass())) {
+ List<NamedElement> group = new ArrayList<NamedElement>() ;
+ group.add(n) ;
+ namedElementGroups.put(n.eClass(), group) ;
+ }
+ else {
+ List<NamedElement> group = namedElementGroups.get(n.eClass()) ;
+ boolean inserted = false ;
+ for (int i = 0 ; inserted == false && i < group.size() ; i++) {
+ if (group.get(i).getName().compareTo(n.getName()) > 0) {
+ group.add(i, n) ;
+ inserted = true ;
+ }
+ }
+ if (!inserted) group.add(n) ;
+ namedElementGroups.put(n.eClass(), group) ;
+ }
+ }
+
+ for (EClass c : namedElementGroups.keySet()) {
+ List<NamedElement> group = namedElementGroups.get(c) ;
+ sortedList.addAll(group) ;
+ }
+
+ return sortedList ;
+ }
+
+
+ /* *************************************************
+ *
+ * Custom completion for qualified names
+ *
+ **************************************************/
+
+ @Override
+ public void completeQualifiedName_Path(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ QualifiedName rule = model instanceof QualifiedName ? (QualifiedName) model : null ;
+ List<NamedElement> visibleNamespaces = getVisibleNamespaces(rule) ;
+ visibleNamespaces = this.sortByKindAndName(visibleNamespaces) ;
+ for (EObject o : visibleNamespaces) {
+ NamedElement namespace = (NamedElement) o ;
+ if (namespace.getName().startsWith(context.getPrefix())) {
+ String completionString = namespace.getName().substring(context.getPrefix().length()) + "::" ;
+ String displayString = namespace.getName() ;
+ ICompletionProposal completionProposal = createCompletionProposal(namespace, completionString, displayString, context) ;
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+
+ private List<NamedElement> getVisibleNamespaces(QualifiedName ctx) {
+ List<NamedElement> allVisibleNamespaces = new ArrayList<NamedElement>() ;
+ if (ctx != null) {
+ Namespace nameSpace = ctx.getPath() ;
+ for (NamedElement elem : nameSpace.getOwnedMembers()) {
+ if (elem instanceof Classifier || elem instanceof Package)
+ allVisibleNamespaces.add(elem) ;
+ }
+ }
+ else {
+ allVisibleNamespaces.add(VSLJavaValidator.getModel()) ; // TODO: Handle/store the highest possible root somewhere?
+ }
+ return allVisibleNamespaces ;
+ }
+
+ /* *************************************************
+ *
+ * Custom completion for names
+ *
+ **************************************************/
+
+ @Override
+ public void completeNameOrChoiceOrBehaviorCall_Id(EObject model, Assignment assignment,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ NameOrChoiceOrBehaviorCall rule = model instanceof NameOrChoiceOrBehaviorCall ? (NameOrChoiceOrBehaviorCall) model : null ;
+ List<NamedElement> visibleNames = getVisibleNames(rule, VSLContextUtil.getExpectedType(model)) ;
+ visibleNames = this.sortByKindAndName(visibleNames) ;
+ for (EObject o : visibleNames) {
+ NamedElement namedElement = (NamedElement) o ;
+ if (namedElement.getName().startsWith(context.getPrefix())) {
+ String completionString = namedElement.getName().substring(context.getPrefix().length()) ;
+ String displayString = namedElement.getName() ;
+ if (namedElement instanceof TypedElement) {
+ TypedElement typedElement = (TypedElement) namedElement ;
+ displayString += typedElement.getType() != null ?
+ " : " + typedElement.getType().getName():
+ "" ;
+ }
+ ICompletionProposal completionProposal = createCompletionProposal(namedElement, completionString, displayString, context) ;
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+
+ private List<NamedElement> getVisibleNames(NameOrChoiceOrBehaviorCall ctx, Type expectedType) {
+ List<NamedElement> allVisibleNames = new ArrayList<NamedElement>() ;
+
+ if (ctx != null) {
+ QualifiedName qualifiedName = ctx.getPath() ;
+ if (qualifiedName != null) {
+ while (qualifiedName.getRemaining() !=null) {
+ qualifiedName = qualifiedName.getRemaining() ;
+ }
+ }
+ if (qualifiedName == null || qualifiedName.getPath() == null)
+ return allVisibleNames ;
+ for (NamedElement elem : qualifiedName.getPath().getOwnedMembers()) {
+ if (elem instanceof Property || elem instanceof EnumerationLiteral)
+ allVisibleNames.add(elem) ;
+ }
+ }
+ else {
+ List<Element> contextHierarchy = new ArrayList<Element>() ;
+ contextHierarchy.add(VSLJavaValidator.getContextElement()) ;
+ Element tmpContext = VSLJavaValidator.getContextElement().getOwner() ;
+ while (tmpContext != null) {
+ contextHierarchy.add(0, tmpContext) ;
+ tmpContext = tmpContext.getOwner() ;
+ }
+ for (Element currentContext : contextHierarchy) {
+ for (Element elem : currentContext.getOwnedElements()) {
+ if (elem instanceof Property || elem instanceof EnumerationLiteral)
+ allVisibleNames.add((NamedElement)elem) ;
+ }
+ }
+ if (expectedType instanceof Enumeration) {
+ allVisibleNames.addAll(((Enumeration)expectedType).getOwnedLiterals()) ;
+ }
+ //else if (expectedType.getAppliedStereotype("MARTE::MARTE_Annexes::VSL::DataTypes::ChoiceType") != null) {
+ // allVisibleNames.addAll(((Classifier)expectedType).getAllAttributes()) ;
+ //}
+ }
+ return allVisibleNames ;
+ }
+
+
+ /* *************************************************
+ *
+ * Custom completion for instant observation names
+ *
+ **************************************************/
+
+ @Override
+ public void completeInstantObsName_InstantId(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ InstantObsName rule = model instanceof InstantObsName ? (InstantObsName) model : null ;
+ List<NamedElement> visibleNames = getVisibleInstantObsNames(rule) ;
+ visibleNames = this.sortByKindAndName(visibleNames) ;
+ for (EObject o : visibleNames) {
+ NamedElement namedElement = (NamedElement) o ;
+ if (namedElement.getName().startsWith(context.getPrefix())) {
+ String completionString = namedElement.getName().substring(context.getPrefix().length()) ;
+ String displayString = namedElement.getName() ;
+ ICompletionProposal completionProposal = createCompletionProposal(namedElement, completionString, displayString, context) ;
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+
+ private List<NamedElement> getVisibleInstantObsNames(InstantObsName ctx) {
+ List<NamedElement> allVisibleNames = new ArrayList<NamedElement>() ;
+ if (ctx != null) {
+ QualifiedName qualifiedName = ctx.getPath() ;
+ if (qualifiedName != null) {
+ while (qualifiedName.getRemaining() !=null) {
+ qualifiedName = qualifiedName.getRemaining() ;
+ }
+ if (qualifiedName.getPath() == null)
+ return allVisibleNames ;
+ for (NamedElement elem : qualifiedName.getPath().getOwnedMembers()) {
+ if (elem instanceof TimeObservation)
+ allVisibleNames.add(elem) ;
+ }
+ }
+ else {
+ List<Element> contextHierarchy = new ArrayList<Element>() ;
+ contextHierarchy.add(ctx.getContextElement()) ;
+ Element tmpContext = ctx.getContextElement().getOwner() ;
+ while (tmpContext != null) {
+ contextHierarchy.add(0, tmpContext) ;
+ tmpContext = tmpContext.getOwner() ;
+ }
+ for (Element currentContext : contextHierarchy) {
+ for (Element elem : currentContext.getOwnedElements()) {
+ if (elem instanceof TimeObservation) {
+ allVisibleNames.add((NamedElement)elem) ;
+ }
+ }
+ }
+ }
+ }
+ else {
+ List<Element> contextHierarchy = new ArrayList<Element>() ;
+ contextHierarchy.add(VSLJavaValidator.getContextElement()) ;
+ Element tmpContext = VSLJavaValidator.getContextElement().getOwner() ;
+ while (tmpContext != null) {
+ contextHierarchy.add(0, tmpContext) ;
+ tmpContext = tmpContext.getOwner() ;
+ }
+ for (Element currentContext : contextHierarchy) {
+ for (Element elem : currentContext.getOwnedElements()) {
+ if (elem instanceof TimeObservation) {
+ allVisibleNames.add((NamedElement)elem) ;
+ }
+ }
+ }
+ }
+ return allVisibleNames ;
+ }
+
+ /* *************************************************
+ *
+ * Custom completion for duration observation names
+ *
+ **************************************************/
+
+ @Override
+ public void completeDurationObsName_DurationId(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ DurationObsName rule = model instanceof DurationObsName ? (DurationObsName) model : null ;
+ List<NamedElement> visibleNames = getVisibleDurationObsNames(rule) ;
+ visibleNames = this.sortByKindAndName(visibleNames) ;
+ for (EObject o : visibleNames) {
+ NamedElement namedElement = (NamedElement) o ;
+ if (namedElement.getName().startsWith(context.getPrefix())) {
+ String completionString = namedElement.getName().substring(context.getPrefix().length()) ;
+ String displayString = namedElement.getName() ;
+ ICompletionProposal completionProposal = createCompletionProposal(namedElement, completionString, displayString, context) ;
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+
+ private List<NamedElement> getVisibleDurationObsNames(DurationObsName ctx) {
+ List<NamedElement> allVisibleNames = new ArrayList<NamedElement>() ;
+ if (ctx != null) {
+ QualifiedName qualifiedName = ctx.getPath() ;
+ if (qualifiedName != null) {
+ while (qualifiedName.getRemaining() !=null) {
+ qualifiedName = qualifiedName.getRemaining() ;
+ }
+ if (qualifiedName.getPath() == null)
+ return allVisibleNames ;
+ for (NamedElement elem : qualifiedName.getPath().getOwnedMembers()) {
+ if (elem instanceof DurationObservation)
+ allVisibleNames.add(elem) ;
+ }
+ }
+ else {
+ List<Element> contextHierarchy = new ArrayList<Element>() ;
+ contextHierarchy.add(ctx.getContextElement()) ;
+ Element tmpContext = ctx.getContextElement().getOwner() ;
+ while (tmpContext != null) {
+ contextHierarchy.add(0, tmpContext) ;
+ tmpContext = tmpContext.getOwner() ;
+ }
+ for (Element currentContext : contextHierarchy) {
+ for (Element elem : currentContext.getOwnedElements()) {
+ if (elem instanceof DurationObservation) {
+ allVisibleNames.add((NamedElement)elem) ;
+ }
+ }
+ }
+ }
+ }
+ else {
+ List<Element> contextHierarchy = new ArrayList<Element>() ;
+ contextHierarchy.add(VSLJavaValidator.getContextElement()) ;
+ Element tmpContext = VSLJavaValidator.getContextElement().getOwner() ;
+ while (tmpContext != null) {
+ contextHierarchy.add(0, tmpContext) ;
+ tmpContext = tmpContext.getOwner() ;
+ }
+ for (Element currentContext : contextHierarchy) {
+ for (Element elem : currentContext.getOwnedElements()) {
+ if (elem instanceof DurationObservation) {
+ allVisibleNames.add((NamedElement)elem) ;
+ }
+ }
+ }
+ }
+ return allVisibleNames ;
+ }
+
+ /* *************************************************
+ *
+ * Custom completion for data type names (used to type local variables)
+ *
+ **************************************************/
+
+ @Override
+ public void completeDataTypeName_Type(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ DataTypeName rule = model instanceof DataTypeName ? (DataTypeName) model : null ;
+ List<NamedElement> visibleNamespaces = getVisibleDataTypes(rule) ;
+ visibleNamespaces = this.sortByKindAndName(visibleNamespaces) ;
+ for (EObject o : visibleNamespaces) {
+ NamedElement namespace = (NamedElement) o ;
+ if (namespace.getName().startsWith(context.getPrefix())) {
+ String completionString = namespace.getName().substring(context.getPrefix().length()) ;
+ String displayString = namespace.getName() ;
+ ICompletionProposal completionProposal = createCompletionProposal(namespace, completionString, displayString, context) ;
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+
+ private List<NamedElement> getVisibleDataTypes(DataTypeName ctx) {
+ List<NamedElement> allVisibleNames = new ArrayList<NamedElement>() ;
+ if (ctx != null) {
+ QualifiedName qualifiedName = ctx.getPath() ;
+ if (qualifiedName != null) {
+ while (qualifiedName.getRemaining() !=null) {
+ qualifiedName = qualifiedName.getRemaining() ;
+ }
+ if (qualifiedName.getPath() == null)
+ return allVisibleNames ;
+ for (NamedElement elem : qualifiedName.getPath().getOwnedMembers()) {
+ if (elem instanceof DataType)
+ allVisibleNames.add(elem) ;
+ }
+ }
+ else {
+ List<Element> contextHierarchy = new ArrayList<Element>() ;
+ contextHierarchy.add(ctx.getContextElement()) ;
+ Element tmpContext = ctx.getContextElement().getOwner() ;
+ while (tmpContext != null) {
+ contextHierarchy.add(0, tmpContext) ;
+ tmpContext = tmpContext.getOwner() ;
+ }
+ for (Element currentContext : contextHierarchy) {
+ for (Element elem : currentContext.getOwnedElements()) {
+ if (elem instanceof DataType) {
+ allVisibleNames.add((NamedElement)elem) ;
+ }
+ }
+ }
+ }
+ }
+ else {
+ List<Element> contextHierarchy = new ArrayList<Element>() ;
+ contextHierarchy.add(VSLJavaValidator.getContextElement()) ;
+ Element tmpContext = VSLJavaValidator.getContextElement().getOwner() ;
+ while (tmpContext != null) {
+ contextHierarchy.add(0, tmpContext) ;
+ tmpContext = tmpContext.getOwner() ;
+ }
+ for (Element currentContext : contextHierarchy) {
+ for (Element elem : currentContext.getOwnedElements()) {
+ if (elem instanceof DataType) {
+ allVisibleNames.add((NamedElement)elem) ;
+ }
+ }
+ }
+ }
+ return allVisibleNames ;
+ }
+
+ /* *************************************************
+ *
+ * Custom completion for property call expressions
+ *
+ **************************************************/
+
+ @Override
+ public void completePropertyCallExpression_Property(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+
+ List<NamedElement> visibleProperties = getVisibleProperties(model) ;
+ visibleProperties = this.sortByKindAndName(visibleProperties) ;
+ for (EObject o : visibleProperties) {
+ NamedElement namedElement = (NamedElement) o ;
+ if (namedElement.getName().startsWith(context.getPrefix())) {
+ String completionString = namedElement.getName().substring(context.getPrefix().length()) ;
+ String displayString = namedElement.getName() ;
+ if (namedElement instanceof TypedElement) {
+ TypedElement typedElement = (TypedElement) namedElement ;
+ displayString += typedElement.getType() != null ?
+ " : " + typedElement.getType().getName():
+ "" ;
+ }
+ ICompletionProposal completionProposal = createCompletionProposal(namedElement, completionString, displayString, context) ;
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+
+ private List<NamedElement> getVisibleProperties(EObject ctx) {
+
+ List<NamedElement> allVisibleProperties = new ArrayList<NamedElement>() ;
+
+ if (ctx instanceof PrimaryExpression) {
+ ValueSpecification contextValueSpecification = ((PrimaryExpression)ctx).getPrefix() ;
+ Type contextType = new VSLTypeInferenceUtil(null).typeOfValueSpecification(contextValueSpecification) ;
+ if (contextType != null) {
+ allVisibleProperties.addAll(((Classifier)contextType).getAllAttributes()) ; //TODO: Take inheritance into account for nested scopes
+ }
+ }
+ else if (ctx instanceof PropertyCallExpression) {
+ PropertyCallExpression parent = (PropertyCallExpression)ctx ;
+ Type contextType = parent.getProperty() != null ? parent.getProperty().getType() : null ;
+ if (contextType != null) {
+ allVisibleProperties.addAll(((Classifier)contextType).getAllAttributes()) ; //TODO: Take inheritance into account for nested scopes
+ }
+ }
+ else if (ctx instanceof OperationCallExpression) {
+ OperationCallExpression parent = (OperationCallExpression)ctx ;
+ Type contextType = parent.getOperation() != null ? parent.getOperation().getType() : null ;
+ if (contextType != null) {
+ allVisibleProperties.addAll(((Classifier)contextType).getAllAttributes()) ; //TODO: Take inheritance into account for nested scopes
+ }
+ }
+ return allVisibleProperties;
+ }
+
+ /* *************************************************
+ *
+ * Custom completion for operation call expressions
+ *
+ **************************************************/
+
+ @Override
+ public void completeOperationCallExpression_Operation(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+
+ List<NamedElement> visibleOperations = getVisibleOperations(model) ;
+ visibleOperations = this.sortByKindAndName(visibleOperations) ;
+ for (EObject o : visibleOperations) {
+ NamedElement namedElement = (NamedElement) o ;
+ if (namedElement.getName().startsWith(context.getPrefix())) {
+ Operation operation = (Operation) namedElement ;
+ String completionString = namedElement.getName().substring(context.getPrefix().length()) + "()" ;
+ String displayString = namedElement.getName() + "()" ; // TODO
+ displayString += operation.getType() != null ?
+ " : " + operation.getType().getName():
+ "" ;
+ ICompletionProposal completionProposal = createCompletionProposal(namedElement, completionString, displayString, context) ;
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+
+ private List<NamedElement> getVisibleOperations(EObject ctx) {
+
+ List<NamedElement> allVisibleOperations = new ArrayList<NamedElement>() ;
+
+ if (ctx instanceof PrimaryExpression) {
+ ValueSpecification contextValueSpecification = ((PrimaryExpression)ctx).getPrefix() ;
+ Type contextType = new VSLTypeInferenceUtil(null).typeOfValueSpecification(contextValueSpecification) ;
+ if (contextType != null) {
+ allVisibleOperations.addAll(((Classifier)contextType).getAllOperations()) ; //TODO: Take inheritance into account for nested scopes
+ }
+ }
+ else if (ctx instanceof PropertyCallExpression) {
+ PropertyCallExpression parent = (PropertyCallExpression)ctx ;
+ Type contextType = parent.getProperty() != null ? parent.getProperty().getType() : null ;
+ if (contextType != null) {
+ allVisibleOperations.addAll(((Classifier)contextType).getAllOperations()) ; //TODO: Take inheritance into account for nested scopes
+ }
+ }
+ else if (ctx instanceof OperationCallExpression) {
+ OperationCallExpression parent = (OperationCallExpression)ctx ;
+ Type contextType = parent.getOperation() != null ? parent.getOperation().getType() : null ;
+ if (contextType != null) {
+ allVisibleOperations.addAll(((Classifier)contextType).getAllOperations()) ; //TODO: Take inheritance into account for nested scopes
+ }
+ }
+ return allVisibleOperations;
+ }
+
+
+ /* *************************************************
+ *
+ * Custom completion for ValueNamePair_property
+ *
+ **************************************************/
+
+ @Override
+ public void completeValueNamePair_Property(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ Type expectedType = VSLContextUtil.getExpectedType(model) ;
+ List<NamedElement> filteredVisibleProperties = getVisiblePropertiesForValueNamePair(model, expectedType) ;
+ EObject tmpContext = model ;
+ while (tmpContext != null && !(tmpContext instanceof ListOfValueNamePairs)) {
+ tmpContext = tmpContext.eContainer() ;
+ }
+ if (tmpContext != null) {
+ for (ValueNamePair v : ((ListOfValueNamePairs)tmpContext).getValueNamePairs()) {
+ filteredVisibleProperties.remove(v.getProperty()) ;
+ }
+ }
+ filteredVisibleProperties = this.sortByKindAndName(filteredVisibleProperties) ;
+ for (EObject o : filteredVisibleProperties) {
+ NamedElement namespace = (NamedElement) o ;
+ if (namespace.getName().startsWith(context.getPrefix())) {
+ String completionString = namespace.getName().substring(context.getPrefix().length()) + " = ";
+ String displayString = namespace.getName() + " = ";
+ ICompletionProposal completionProposal = createCompletionProposal(namespace, completionString, displayString, context) ;
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+
+ private List<NamedElement> getVisiblePropertiesForValueNamePair(EObject rule, Type expectedType) {
+ List<NamedElement> visibleProperties = new ArrayList<NamedElement>() ;
+ if (expectedType.getAppliedStereotype("MARTE::MARTE_Annexes::VSL::DataTypes::TupleType") != null ||
+ expectedType.getAppliedStereotype("MARTE::MARTE_Foundations::NFPs::NfpType") != null) {
+ visibleProperties.addAll(((Classifier)expectedType).getAllAttributes()) ;
+ }
+ return visibleProperties ;
+ }
+}
diff --git a/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/FeatureTree.java b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/FeatureTree.java
new file mode 100644
index 00000000000..2f41e4f54b8
--- /dev/null
+++ b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/FeatureTree.java
@@ -0,0 +1,105 @@
+/*****************************************************************************
+ * 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.vsl.ui.contentassist;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Feature;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Property;
+
+public class FeatureTree extends Tree<Feature> {
+
+ private List<Classifier> typesCrossedToReachThisTree ;
+
+ public FeatureTree(Feature root) {
+ super(root);
+ typesCrossedToReachThisTree = new ArrayList<Classifier>() ;
+ }
+
+ public FeatureTree(Feature root, List<Classifier> typesCrossedToReachThisTree) {
+ this(root) ;
+ this.typesCrossedToReachThisTree.addAll(typesCrossedToReachThisTree) ;
+ buildTree() ;
+ }
+
+ @Override
+ public void buildTree() {
+ Classifier featureType = null ;
+ if (root instanceof Property) {
+ featureType = (Classifier)((Property)root).getType() ;
+ }
+ else if (root instanceof Operation) {
+ featureType = (Classifier)((Operation)root).getType() ;
+ }
+ if (featureType == null)
+ return ;
+ if (typesCrossedToReachThisTree.contains(featureType)) {
+ return ;
+ }
+ else {
+ typesCrossedToReachThisTree.add(featureType) ;
+ }
+ for (Feature property : featureType.getAllAttributes()) {
+ getChildren().add(new FeatureTree(property, typesCrossedToReachThisTree)) ;
+ }
+ for (Feature operation : featureType.getAllOperations()) {
+ getChildren().add(new FeatureTree(operation, typesCrossedToReachThisTree)) ;
+ }
+ }
+
+ public static List<FeatureTree> buildListOfFeatureTrees(Classifier classifier) {
+ List<FeatureTree> list = new ArrayList<FeatureTree>() ;
+ List<Classifier> typesCrossedToReachThisTree = new ArrayList<Classifier>() ;
+ typesCrossedToReachThisTree.add(classifier) ;
+ for (Feature property : classifier.getAllAttributes()) {
+ list.add(new FeatureTree(property, typesCrossedToReachThisTree)) ;
+ }
+ for (Feature operation : classifier.getAllOperations()) {
+ list.add(new FeatureTree(operation, typesCrossedToReachThisTree)) ;
+ }
+ return list ;
+ }
+
+ public static boolean canClassifierBeReached(List<FeatureTree> listOfFeatureTrees, Classifier classifier) {
+ boolean classifierReached = false ;
+ Iterator<FeatureTree> i = listOfFeatureTrees.iterator() ;
+ while (i.hasNext() && !classifierReached) {
+ classifierReached = i.next().canClassifierBeReached(classifier) ;
+ }
+ return classifierReached ;
+ }
+
+ public boolean canClassifierBeReached(Classifier classifier) {
+ for (Classifier type : typesCrossedToReachThisTree) {
+ if (classifier == type || type.conformsTo(classifier))
+ return true ;
+ else if (type.getName().equals(classifier.getName())
+ && (type.getName().equals("Integer")
+ || type.getName().equals("Integer")
+ || type.getName().equals("String"))) {
+ return true ;
+ }
+ }
+ boolean classifierReached = false ;
+ Iterator<Tree<Feature>> i = getChildren().iterator() ;
+ while (i.hasNext() && !classifierReached) {
+ classifierReached = ((FeatureTree)i.next()).canClassifierBeReached(classifier) ;
+ }
+ return classifierReached ;
+ }
+}
diff --git a/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/Tree.java b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/Tree.java
new file mode 100644
index 00000000000..7ff80f311db
--- /dev/null
+++ b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/Tree.java
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * 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.vsl.ui.contentassist;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class Tree<NodeType> {
+
+ protected NodeType root ;
+ protected NodeType parent ;
+ protected List<Tree<NodeType>> children ;
+
+ public Tree(NodeType root) {
+ this.root = root ;
+ }
+
+ public NodeType getRoot() {
+ return root ;
+ }
+
+ public NodeType getParent() {
+ return parent ;
+ }
+
+ public void setParent(NodeType parent) {
+ this.parent = parent ;
+ }
+
+ public List<Tree<NodeType>> getChildren() {
+ if (children == null)
+ children = new ArrayList<Tree<NodeType>>() ;
+ return children ;
+ }
+
+ public boolean isEmpty() {
+ return getChildren().isEmpty() ;
+ }
+
+ public abstract void buildTree() ;
+}
diff --git a/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/VSLContentAssistProcessor.java b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/VSLContentAssistProcessor.java
new file mode 100644
index 00000000000..02cc1afa556
--- /dev/null
+++ b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/VSLContentAssistProcessor.java
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * 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.vsl.ui.contentassist;
+
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.xtext.ui.editor.contentassist.XtextContentAssistProcessor;
+
+
+public class VSLContentAssistProcessor extends XtextContentAssistProcessor {
+
+ //@Inject(optional = true)
+ //private IContentProposalProvider contentProposalProvider;
+
+ @Override
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
+ return super.computeCompletionProposals(viewer, offset) ;
+ }
+
+}
diff --git a/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/VSLProposalProvider.java b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/VSLProposalProvider.java
new file mode 100644
index 00000000000..8bc1f682fa8
--- /dev/null
+++ b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/VSLProposalProvider.java
@@ -0,0 +1,1540 @@
+/*****************************************************************************
+ * 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.vsl.ui.contentassist;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.papyrus.marte.vsl.extensions.VSLContextUtil;
+import org.eclipse.papyrus.marte.vsl.scoping.VSLScopeProvider;
+import org.eclipse.papyrus.marte.vsl.scoping.visitors.ScopingVisitors;
+import org.eclipse.papyrus.marte.vsl.vSL.AdditiveExpression;
+import org.eclipse.papyrus.marte.vsl.vSL.AndOrXorExpression;
+import org.eclipse.papyrus.marte.vsl.vSL.CollectionOrTuple;
+import org.eclipse.papyrus.marte.vsl.vSL.ConditionalExpression;
+import org.eclipse.papyrus.marte.vsl.vSL.DurationObsName;
+import org.eclipse.papyrus.marte.vsl.vSL.EqualityExpression;
+import org.eclipse.papyrus.marte.vsl.vSL.InstantObsName;
+import org.eclipse.papyrus.marte.vsl.vSL.ListOfValueNamePairs;
+import org.eclipse.papyrus.marte.vsl.vSL.MultiplicativeExpression;
+import org.eclipse.papyrus.marte.vsl.vSL.NameOrChoiceOrBehaviorCall;
+import org.eclipse.papyrus.marte.vsl.vSL.OperationCallExpression;
+import org.eclipse.papyrus.marte.vsl.vSL.PrimaryExpression;
+import org.eclipse.papyrus.marte.vsl.vSL.QualifiedName;
+import org.eclipse.papyrus.marte.vsl.vSL.RelationalExpression;
+import org.eclipse.papyrus.marte.vsl.vSL.Tuple;
+import org.eclipse.papyrus.marte.vsl.vSL.UnaryExpression;
+import org.eclipse.papyrus.marte.vsl.vSL.VSLPackage;
+import org.eclipse.papyrus.marte.vsl.vSL.ValueNamePair;
+import org.eclipse.papyrus.marte.vsl.validation.VSLJavaValidator;
+import org.eclipse.papyrus.marte.vsl.validation.VSLJavaValidator.VSLValidationResult;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.DurationObservation;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Feature;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.ParameterDirectionKind;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.TimeObservation;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.xtext.Assignment;
+import org.eclipse.xtext.Keyword;
+import org.eclipse.xtext.RuleCall;
+import org.eclipse.xtext.gmf.glue.contentassist.CompletionProposalUtils;
+import org.eclipse.xtext.parsetree.AbstractNode;
+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;
+import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext;
+import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor;
+
+/**
+ * see http://www.eclipse.org/Xtext/documentation/latest/xtext.html#contentAssist on how to customize content assistant
+ */
+public class VSLProposalProvider extends AbstractVSLProposalProvider {
+
+ @Override
+ public void completeExpression_Exp(EObject model, Assignment assignment,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeExpression_Exp(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeAndOrXorExpression_Exp(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+
+ if (model instanceof AndOrXorExpression) {
+ AndOrXorExpression exp = (AndOrXorExpression)model ;
+ List<EqualityExpression> nestedExpressions = exp.getExp() ;
+ if (nestedExpressions.size() >= 2) {
+ VSLValidationResult validationResult = VSLJavaValidator.eInstance.checkEqualityExpression(nestedExpressions.get(nestedExpressions.size()-2)) ;
+ Classifier specifiedType = (Classifier)validationResult.inferedType() ;
+ String operator = exp.getOp().get(nestedExpressions.size()-2) ;
+ if (VSLJavaValidator.binaryOpTypeBinding.get(operator) != null && VSLJavaValidator.binaryOpTypeBinding.get(operator).get(specifiedType) != null) {
+ for (Type possibleType : VSLJavaValidator.binaryOpTypeBinding.get(operator).get(specifiedType)) {
+ Map<String,Element> allProposals = VSLProposalUtils.buildProposalForType((Classifier)possibleType) ;
+ for (String s : allProposals.keySet()) {
+ if (s.startsWith(context.getPrefix())) {
+ String completionString ;
+ String displayString ;
+ ICompletionProposal completionProposal = null ;
+ if (allProposals.get(s) == null) {
+ completionString = s.substring(context.getPrefix().length()) ;
+ displayString = s ;
+ completionProposal = CompletionProposalUtils.createCompletionProposal(completionString, displayString, context) ;
+ }
+ else {
+ if (! s.contains("|")) {
+ completionString = s ;
+ displayString = s ;
+ }
+ else {
+ completionString = s.substring(0, s.indexOf("|")) ;
+ displayString = s.substring(s.indexOf("|") + 1) ;
+ }
+ completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix(((allProposals.get(s) != null) && (allProposals.get(s) instanceof NamedElement)) ? (NamedElement)allProposals.get(s) : null, completionString, displayString, context) ;
+ }
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ super.completeAndOrXorExpression_Exp(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeAndOrXorExpression_Op(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeAndOrXorExpression_Op(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeEqualityExpression_Exp(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ if (model instanceof EqualityExpression) {
+ EqualityExpression exp = (EqualityExpression)model ;
+ List<RelationalExpression> nestedExpressions = exp.getExp() ;
+ if (nestedExpressions.size() >= 2) {
+ VSLValidationResult validationResult = VSLJavaValidator.eInstance.checkRelationalExpression(nestedExpressions.get(nestedExpressions.size()-2)) ;
+ Classifier specifiedType = (Classifier)validationResult.inferedType() ;
+ String operator = exp.getOp().get(nestedExpressions.size()-2) ;
+ if (VSLJavaValidator.binaryOpTypeBinding.get(operator) != null && VSLJavaValidator.binaryOpTypeBinding.get(operator).get(specifiedType) != null) {
+ for (Type possibleType : VSLJavaValidator.binaryOpTypeBinding.get(operator).get(specifiedType)) {
+ Map<String,Element> allProposals = VSLProposalUtils.buildProposalForType((Classifier)possibleType) ;
+ for (String s : allProposals.keySet()) {
+ if (s.startsWith(context.getPrefix())) {
+ String completionString ;
+ String displayString ;
+ ICompletionProposal completionProposal = null ;
+ if (allProposals.get(s) == null) {
+ completionString = s.substring(context.getPrefix().length()) ;
+ displayString = s ;
+ completionProposal = CompletionProposalUtils.createCompletionProposal(completionString, displayString, context) ;
+ }
+ else {
+ if (! s.contains("|")) {
+ completionString = s ;
+ displayString = s ;
+ }
+ else {
+ completionString = s.substring(0, s.indexOf("|")) ;
+ displayString = s.substring(s.indexOf("|") + 1) ;
+ }
+ completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix(((allProposals.get(s) != null) && (allProposals.get(s) instanceof NamedElement)) ? (NamedElement)allProposals.get(s) : null, completionString, displayString, context) ;
+ }
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ super.completeEqualityExpression_Exp(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeEqualityExpression_Op(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeEqualityExpression_Op(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeRelationalExpression_Exp(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ if (model instanceof RelationalExpression) {
+ RelationalExpression exp = (RelationalExpression)model ;
+ List<ConditionalExpression> nestedExpressions = exp.getExp() ;
+ if (nestedExpressions.size() >= 2) {
+ VSLValidationResult validationResult = VSLJavaValidator.eInstance.checkConditionalExpression(nestedExpressions.get(nestedExpressions.size()-2)) ;
+ Classifier specifiedType = (Classifier)validationResult.inferedType() ;
+ String operator = exp.getOp().get(nestedExpressions.size()-2) ;
+ if (VSLJavaValidator.binaryOpTypeBinding.get(operator) != null && VSLJavaValidator.binaryOpTypeBinding.get(operator).get(specifiedType) != null) {
+ for (Type possibleType : VSLJavaValidator.binaryOpTypeBinding.get(operator).get(specifiedType)) {
+ Map<String,Element> allProposals = VSLProposalUtils.buildProposalForType((Classifier)possibleType) ;
+ for (String s : allProposals.keySet()) {
+ if (s.startsWith(context.getPrefix())) {
+ String completionString ;
+ String displayString ;
+ ICompletionProposal completionProposal = null ;
+ if (allProposals.get(s) == null) {
+ completionString = s.substring(context.getPrefix().length()) ;
+ displayString = s ;
+ completionProposal = CompletionProposalUtils.createCompletionProposal(completionString, displayString, context) ;
+ }
+ else {
+ if (! s.contains("|")) {
+ completionString = s ;
+ displayString = s ;
+ }
+ else {
+ completionString = s.substring(0, s.indexOf("|")) ;
+ displayString = s.substring(s.indexOf("|") + 1) ;
+ }
+ completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix(((allProposals.get(s) != null) && (allProposals.get(s) instanceof NamedElement)) ? (NamedElement)allProposals.get(s) : null, completionString, displayString, context) ;
+ }
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ super.completeRelationalExpression_Exp(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeRelationalExpression_Op(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeRelationalExpression_Op(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeConditionalExpression_Exp(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeConditionalExpression_Exp(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeConditionalExpression_Op(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeConditionalExpression_Op(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeAdditiveExpression_Exp(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ if (model instanceof AdditiveExpression) {
+ AdditiveExpression exp = (AdditiveExpression)model ;
+ List<MultiplicativeExpression> nestedExpressions = exp.getExp() ;
+ if (nestedExpressions.size() >= 2) {
+ VSLValidationResult validationResult = VSLJavaValidator.eInstance.checkMultiplicativeExpression(nestedExpressions.get(nestedExpressions.size()-2)) ;
+ Classifier specifiedType = (Classifier)validationResult.inferedType() ;
+ String operator = exp.getOp().get(nestedExpressions.size()-2) ;
+ if (VSLJavaValidator.binaryOpTypeBinding.get(operator) != null && VSLJavaValidator.binaryOpTypeBinding.get(operator).get(specifiedType) != null) {
+ for (Type possibleType : VSLJavaValidator.binaryOpTypeBinding.get(operator).get(specifiedType)) {
+ Map<String,Element> allProposals = VSLProposalUtils.buildProposalForType((Classifier)possibleType) ;
+ for (String s : allProposals.keySet()) {
+ if (s.startsWith(context.getPrefix())) {
+ String completionString ;
+ String displayString ;
+ ICompletionProposal completionProposal = null ;
+ if (allProposals.get(s) == null) {
+ completionString = s.substring(context.getPrefix().length()) ;
+ displayString = s ;
+ completionProposal = CompletionProposalUtils.createCompletionProposal(completionString, displayString, context) ;
+ }
+ else {
+ if (! s.contains("|")) {
+ completionString = s ;
+ displayString = s ;
+ }
+ else {
+ completionString = s.substring(0, s.indexOf("|")) ;
+ displayString = s.substring(s.indexOf("|") + 1) ;
+ }
+ completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix(((allProposals.get(s) != null) && (allProposals.get(s) instanceof NamedElement)) ? ((allProposals.get(s) != null) && (allProposals.get(s) instanceof NamedElement)) ? (NamedElement)allProposals.get(s) : null : null, completionString, displayString, context) ;
+ }
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ super.completeAdditiveExpression_Exp(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeAdditiveExpression_Op(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeAdditiveExpression_Op(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeMultiplicativeExpression_Exp(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ if (model instanceof MultiplicativeExpression) {
+ MultiplicativeExpression exp = (MultiplicativeExpression)model ;
+ List<UnaryExpression> nestedExpressions = exp.getExp() ;
+ if (nestedExpressions.size() >= 1) {
+ VSLValidationResult validationResult = VSLJavaValidator.eInstance.checkUnaryExpression(nestedExpressions.get(nestedExpressions.size()-1)) ;
+ Classifier specifiedType = (Classifier)validationResult.inferedType() ;
+ String operator = exp.getOp().get(exp.getOp().size() == 0 ? 0 : nestedExpressions.size()-1) ;
+ for (Type possibleType : VSLJavaValidator.binaryOpTypeBinding.get(operator).get(specifiedType)) {
+ Map<String,Element> allProposals = VSLProposalUtils.buildProposalForType((Classifier)possibleType) ;
+ for (String s : allProposals.keySet()) {
+ if (s.startsWith(context.getPrefix())) {
+ String completionString ;
+ String displayString ;
+ ICompletionProposal completionProposal = null ;
+ if (allProposals.get(s) == null) {
+ completionString = s.substring(context.getPrefix().length()) ;
+ displayString = s ;
+ completionProposal = CompletionProposalUtils.createCompletionProposal(completionString, displayString, context) ;
+ }
+ else {
+ if (! s.contains("|")) {
+ completionString = s ;
+ displayString = s ;
+ }
+ else {
+ completionString = s.substring(0, s.indexOf("|")) ;
+ displayString = s.substring(s.indexOf("|") + 1) ;
+ }
+ completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix(((allProposals.get(s) != null) && (allProposals.get(s) instanceof NamedElement)) ? (NamedElement)allProposals.get(s) : null, completionString, displayString, context) ;
+ }
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+ }
+ }
+ else
+ super.completeMultiplicativeExpression_Exp(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeMultiplicativeExpression_Op(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeMultiplicativeExpression_Op(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeUnaryExpression_Op(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.completeUnaryExpression_Op(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeUnaryExpression_Unary(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.completeUnaryExpression_Unary(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeUnaryExpression_Exp(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.completeUnaryExpression_Exp(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completePrimaryExpression_Prefix(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completePrimaryExpression_Prefix(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completePrimaryExpression_Suffix(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completePrimaryExpression_Suffix(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completePropertyCallExpression_Property(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ Classifier classifierForScoping ;
+ if (model instanceof PrimaryExpression) {
+ classifierForScoping = VSLScopeProvider.eInstance.new ScopingHelper(((PrimaryExpression)model).getPrefix()).getClassifierForScoping() ;
+ }
+ else {
+ classifierForScoping = VSLScopeProvider.eInstance.new ScopingHelper(model).getClassifierForScoping() ;
+ }
+ List<Property> allProperties = new ArrayList<Property>() ;
+ if (classifierForScoping != null) {
+ for (Feature f : classifierForScoping.allFeatures()) {
+ if (f instanceof Property)
+ allProperties.add((Property)f) ;
+ }
+ }
+ Iterable<IEObjectDescription> iterableIEobjectDescription = Scopes.scopedElementsFor(allProperties) ;
+ IScope scope = new SimpleScope(iterableIEobjectDescription) ;
+ for (IEObjectDescription eobjectDescription : scope.getAllContents()) {
+ if (eobjectDescription.getName().toLowerCase().contains(context.getPrefix().toLowerCase())) {
+ String displayString = eobjectDescription.getName() + " : " + (((Property)eobjectDescription.getEObjectOrProxy()).getType() != null ? ((Property)eobjectDescription.getEObjectOrProxy()).getType().getName() : "<Undefined>") ;
+ String completionString = eobjectDescription.getName() ;
+ ICompletionProposal completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix((NamedElement)eobjectDescription.getEObjectOrProxy(), completionString, displayString, context) ;
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+
+ @Override
+ public void completePropertyCallExpression_Suffix(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completePropertyCallExpression_Suffix(model, assignment, context,
+ acceptor);
+ }
+
+ @Override
+ public void completeOperationCallExpression_Operation(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ Classifier classifierForScoping ;
+ if (model instanceof PrimaryExpression) {
+ classifierForScoping = VSLScopeProvider.eInstance.new ScopingHelper(((PrimaryExpression)model).getPrefix()).getClassifierForScoping() ;
+ }
+ else {
+ classifierForScoping = VSLScopeProvider.eInstance.new ScopingHelper(model).getClassifierForScoping() ;
+ }
+ List<Operation> allOperations = new ArrayList<Operation>() ;
+ if (classifierForScoping != null) {
+ for (Feature f : classifierForScoping.allFeatures()) {
+ if (f instanceof Operation) {
+ Operation o = (Operation)f ;
+ if (o.getType() != null &&
+ !(o.getName().equals("<")
+ || o.getName().equals(">")
+ || o.getName().equals("<=")
+ || o.getName().equals(">=")
+ || o.getName().equals("==")
+ || o.getName().equals("<>")
+ || o.getName().equals("+")
+ || o.getName().equals("-")
+ || o.getName().equals("*")
+ || o.getName().equals("/")
+ || o.getName().equals("^"))) {
+ allOperations.add(o) ;
+ }
+ }
+ }
+ }
+ Iterable<IEObjectDescription> iterableIEobjectDescription = Scopes.scopedElementsFor(allOperations) ;
+ IScope scope = new SimpleScope(iterableIEobjectDescription) ;
+ for (IEObjectDescription eobjectDescription : scope.getAllContents()) {
+ if (eobjectDescription.getName().toLowerCase().contains(context.getPrefix().toLowerCase())) {
+ Operation calledOperation = (Operation)eobjectDescription.getEObjectOrProxy() ;
+ String displayString = VSLProposalUtils.buildDisplayStringForOperationCall(calledOperation) ;
+ String completionString = VSLProposalUtils.buildCompletionStringForOperationCall(calledOperation) ;
+ ICompletionProposal completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix((NamedElement)eobjectDescription.getEObjectOrProxy(), completionString, displayString, context) ;
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+
+ @Override
+ public void completeOperationCallExpression_Arguments(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+
+ if (! (model instanceof OperationCallExpression))
+ return ;
+
+ Operation calledOperation = ((OperationCallExpression)model).getOperation() ;
+ if (calledOperation != null) {
+ Parameter firstParameter = null ;
+ Iterator<Parameter> allParameters = calledOperation.getOwnedParameters().iterator() ;
+ while (allParameters.hasNext() && firstParameter == null) {
+ Parameter currentParam = allParameters.next() ;
+ if (currentParam.getDirection() != ParameterDirectionKind.RETURN_LITERAL)
+ firstParameter = currentParam ;
+ }
+ if (firstParameter != null) {
+ Classifier expectedType = (Classifier)firstParameter.getType() ;
+ Map<String, Element> allProposals = VSLProposalUtils.buildProposalForType(expectedType) ;
+ for (String s : allProposals.keySet()) {
+ if (s.startsWith(context.getPrefix())) {
+ String completionString ;
+ String displayString ;
+ ICompletionProposal completionProposal = null ;
+ if (allProposals.get(s) == null) {
+ completionString = s.substring(context.getPrefix().length()) ;
+ displayString = s ;
+ completionProposal = CompletionProposalUtils.createCompletionProposal(completionString, displayString, context) ;
+ }
+ else {
+ if (! s.contains("|")) {
+ completionString = s ;
+ displayString = s ;
+ }
+ else {
+ completionString = s.substring(0, s.indexOf("|")) ;
+ displayString = s.substring(s.indexOf("|") + 1) ;
+ }
+ completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix(((allProposals.get(s) != null) && (allProposals.get(s) instanceof NamedElement)) ? (NamedElement)allProposals.get(s) : null, completionString, displayString, context) ;
+ }
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void completeOperationCallExpression_Suffix(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.completeOperationCallExpression_Suffix(model, assignment, context,
+ acceptor);
+ }
+
+ @Override
+ public void completeNameOrChoiceOrBehaviorCall_Path(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.completeNameOrChoiceOrBehaviorCall_Path(model, assignment, context,
+ acceptor);
+ }
+
+ @Override
+ public void completeNameOrChoiceOrBehaviorCall_Id(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ if (model instanceof NameOrChoiceOrBehaviorCall && ((NameOrChoiceOrBehaviorCall)model).getPath() != null) {
+ IScope scope = VSLScopeProvider.eInstance.scope_NameOrChoiceOrBehaviorCall_id((NameOrChoiceOrBehaviorCall)model, VSLPackage.eINSTANCE.getNameOrChoiceOrBehaviorCall_Id()) ;
+ for (IEObjectDescription eobjectDescription : scope.getAllContents()) {
+ if (eobjectDescription.getName().toLowerCase().contains(context.getPrefix().toLowerCase())) {
+ boolean goOn = true;
+ if (eobjectDescription.getEObjectOrProxy() instanceof Behavior) {
+ Behavior behavior = (Behavior)eobjectDescription.getEObjectOrProxy() ;
+ boolean behaviorHasAReturnType = false ;
+ for (Parameter p : behavior.getOwnedParameters()) {
+ if (p.getDirection() == ParameterDirectionKind.RETURN_LITERAL)
+ behaviorHasAReturnType = true ;
+ }
+ goOn = behaviorHasAReturnType ;
+ }
+ if (goOn) {
+ String displayString = eobjectDescription.getName() ;
+ String completionString = eobjectDescription.getName() ;
+ if (eobjectDescription.getEObjectOrProxy() instanceof Behavior) {
+ displayString = VSLProposalUtils.buildDisplayStringForBehaviorCall((Behavior)eobjectDescription.getEObjectOrProxy()) ;
+ completionString = VSLProposalUtils.buildCompletionStringForBehaviorCall((Behavior)eobjectDescription.getEObjectOrProxy()) ;
+ }
+ ICompletionProposal completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix((NamedElement)eobjectDescription.getEObjectOrProxy(), completionString, displayString, context) ;
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+ }
+ else {
+ // ignore. Already handled by other rules.
+ }
+ }
+
+ @Override
+ public void completeNameOrChoiceOrBehaviorCall_Arguments(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ if (! (model instanceof NameOrChoiceOrBehaviorCall))
+ return ;
+
+ NamedElement cddBehavior = ((NameOrChoiceOrBehaviorCall)model).getId() ;
+ if (cddBehavior == null || !(cddBehavior instanceof Behavior))
+ return ;
+ Behavior calledBehavior = (Behavior)cddBehavior ;
+
+ if (calledBehavior != null) {
+ Parameter firstParameter = null ;
+ Iterator<Parameter> allParameters = calledBehavior.getOwnedParameters().iterator() ;
+ while (allParameters.hasNext() && firstParameter == null) {
+ Parameter currentParam = allParameters.next() ;
+ if (currentParam.getDirection() != ParameterDirectionKind.RETURN_LITERAL)
+ firstParameter = currentParam ;
+ }
+ if (firstParameter != null) {
+ Classifier expectedType = (Classifier)firstParameter.getType() ;
+ Map<String, Element> allProposals = VSLProposalUtils.buildProposalForType(expectedType) ;
+ for (String s : allProposals.keySet()) {
+ if (s.startsWith(context.getPrefix())) {
+ String completionString ;
+ String displayString ;
+ ICompletionProposal completionProposal = null ;
+ if (allProposals.get(s) == null) {
+ completionString = s.substring(context.getPrefix().length()) ;
+ displayString = s ;
+ completionProposal = CompletionProposalUtils.createCompletionProposal(completionString, displayString, context) ;
+ }
+ else {
+ if (! s.contains("|")) {
+ completionString = s ;
+ displayString = s ;
+ }
+ else {
+ completionString = s.substring(0, s.indexOf("|")) ;
+ displayString = s.substring(s.indexOf("|") + 1) ;
+ }
+ completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix(((allProposals.get(s) != null) && (allProposals.get(s) instanceof NamedElement)) ? (NamedElement)allProposals.get(s) : null, completionString, displayString, context) ;
+ }
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void completeQualifiedName_Path(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // ignore. Treated by qualifiedName_Remaining, or the context rule.
+
+ }
+
+ @Override
+ public void completeQualifiedName_Remaining(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ if (model instanceof QualifiedName) {
+ IScope scope = VSLScopeProvider.eInstance.scope_QualifiedName_remaining((QualifiedName)model, VSLPackage.eINSTANCE.getQualifiedName_Remaining()) ;
+ for (IEObjectDescription eobjectDescription : scope.getAllContents()) {
+ if (eobjectDescription.getName().toLowerCase().contains(context.getPrefix().toLowerCase())) {
+ String displayString = eobjectDescription.getName() + "::";
+ String completionString = eobjectDescription.getName() + "::";
+ ICompletionProposal completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix((NamedElement)eobjectDescription.getEObjectOrProxy(), completionString, displayString, context) ;
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+ else {
+ // ignore. Should already be treated by the context rule
+ }
+ }
+
+ @Override
+ public void completeInterval_IsLowerIncluded(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ //super.completeInterval_IsLowerIncluded(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeInterval_Lower(EObject model, Assignment assignment,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.completeInterval_Lower(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeInterval_Upper(EObject model, Assignment assignment,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.completeInterval_Upper(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeInterval_IsUpperIncluded(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ //super.completeInterval_IsUpperIncluded(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeCollectionOrTuple_ListOfValues(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.completeCollectionOrTuple_ListOfValues(model, assignment, context,
+ acceptor);
+ }
+
+ @Override
+ public void completeTuple_ListOfValueNamePairs(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.completeTuple_ListOfValueNamePairs(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeListOfValues_Values(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ if (model instanceof OperationCallExpression || model instanceof NameOrChoiceOrBehaviorCall || model instanceof CollectionOrTuple)
+ return ; // already treated by other cases
+
+ AbstractNode node = context.getCurrentNode() ;
+ IDocument document = context.getViewer().getDocument() ;
+ char startChar = ' ' ;
+ char openingListChar = ' ';
+ int rule = -1 ; // 0 => OperationCall, 1 => BehaviorCall, 2 => CollectionOrTuple
+ if (model.eContainer() instanceof OperationCallExpression) {
+ startChar = '.' ;
+ openingListChar = '(' ;
+ rule = 0 ;
+ }
+ else if (model.eContainer() instanceof NameOrChoiceOrBehaviorCall) {
+ startChar = ' ' ;
+ openingListChar = '(' ;
+ rule = 1 ;
+ }
+ else if (model.eContainer() instanceof CollectionOrTuple) {
+ startChar = ' ' ;
+ openingListChar = '{' ;
+ rule = 2 ;
+ }
+ try {
+ Classifier expectedType = null ;
+ char[] completePrefix = document.get(0, node.getOffset()).toCharArray() ;
+ boolean dotCallFound = false ;
+ boolean openingListCharFound = false ;
+ int i = completePrefix.length - 1 ;
+ int positionInTheList = 0 ;
+ int closingCharacters = 0 ;
+ while (i > 0 && !dotCallFound) {
+ char currentChar = completePrefix[i] ;
+ if (currentChar == '(' || currentChar == '{') {
+ if (closingCharacters != 0)
+ closingCharacters-- ;
+ else
+ openingListCharFound = true ;
+ }
+ else if (currentChar == ')' || currentChar == '}')
+ closingCharacters ++ ;
+ else if (currentChar == ',') {
+ //if ()
+ if (closingCharacters == 0)
+ positionInTheList ++ ;
+ }
+ else if (currentChar == startChar && openingListCharFound) {
+ dotCallFound = true ;
+ }
+ i-- ;
+ }
+ if (openingListCharFound) {
+ switch (rule) {
+ case 0: // OperationCall
+ OperationCallExpression callOp = (OperationCallExpression) model.eContainer() ;
+ if (callOp.getOperation() == null || callOp.getOperation().getOwnedParameters() == null)
+ return ;
+ List<Parameter> operationParameters = new ArrayList<Parameter>() ;
+ for (Parameter p : callOp.getOperation().getOwnedParameters()) {
+ if (p.getDirection() != ParameterDirectionKind.RETURN_LITERAL)
+ operationParameters.add(p) ;
+ }
+ if (positionInTheList < operationParameters.size()) {
+ expectedType = (Classifier)operationParameters.get(positionInTheList).getType() ;
+ }
+ break;
+ case 1: // BehaviorCall
+ NameOrChoiceOrBehaviorCall callBehav = (NameOrChoiceOrBehaviorCall) model.eContainer() ;
+ NamedElement cddBehavior = callBehav.getId() ;
+ if (cddBehavior instanceof Behavior) {
+ Behavior behavior = (Behavior)cddBehavior ;
+ if (behavior.getOwnedParameters()== null)
+ return ;
+ List<Parameter> behaviorParameters = new ArrayList<Parameter>() ;
+ for (Parameter p : behavior.getOwnedParameters()) {
+ if (p.getDirection() != ParameterDirectionKind.RETURN_LITERAL)
+ behaviorParameters.add(p) ;
+ }
+ if (positionInTheList < behaviorParameters.size()) {
+ expectedType = (Classifier)behaviorParameters.get(positionInTheList).getType() ;
+ }
+ }
+ break;
+ case 2: // CollectionOrTuple
+ // TODO
+ break;
+ default:
+ break;
+ }
+ if (expectedType != null) {
+ Map<String, Element> allProposals = VSLProposalUtils.buildProposalForType(expectedType) ;
+ for (String s : allProposals.keySet()) {
+ if (s.startsWith(context.getPrefix())) {
+ String completionString ;
+ String displayString ;
+ ICompletionProposal completionProposal = null ;
+ if (allProposals.get(s) == null) {
+ completionString = s.substring(context.getPrefix().length()) ;
+ displayString = s ;
+ completionProposal = CompletionProposalUtils.createCompletionProposal(completionString, displayString, context) ;
+ }
+ else {
+ if (! s.contains("|")) {
+ completionString = s ;
+ displayString = s ;
+ }
+ else {
+ completionString = s.substring(0, s.indexOf("|")) ;
+ displayString = s.substring(s.indexOf("|") + 1) ;
+ }
+ completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix(((allProposals.get(s) != null) && (allProposals.get(s) instanceof NamedElement)) ? (NamedElement)allProposals.get(s) : null, completionString, displayString, context) ;
+ }
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+ }
+ }
+ catch (Exception exception) {
+ exception.printStackTrace() ;
+ }
+ //super.completeListOfValues_Values(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeListOfValueNamePairs_ValueNamePairs(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.completeListOfValueNamePairs_ValueNamePairs(model, assignment, context,
+ acceptor);
+ }
+
+ @Override
+ public void completeValueNamePair_Property(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // First retrieves all the properties available for the context type, in the case where the context type is a tuple or nfp type
+ Classifier classifierForScoping = VSLScopeProvider.eInstance.new ScopingHelper(model).getClassifierForScoping() ;
+ if (! VSLContextUtil.isATupleType(classifierForScoping))
+ // TMP solution. Forces the classifier for scoping to be nfp_duration
+ classifierForScoping = (Classifier)VSLJavaValidator._nfp_duration;
+ List<Property> allProperties = new ArrayList<Property>() ;
+ for (Feature f : classifierForScoping.allFeatures()) {
+ if (f instanceof Property)
+ allProperties.add((Property)f) ;
+ }
+
+ // Removes already specified properties from the context ListOfValueNamePairs
+ List<Property> allReadySpecifiedProperties = new ArrayList<Property>() ;
+ EObject cddContextListOfValueNamePairs = model ;
+ if (cddContextListOfValueNamePairs instanceof Tuple) {
+ cddContextListOfValueNamePairs = ((Tuple)cddContextListOfValueNamePairs).getListOfValueNamePairs() ;
+ }
+ while (cddContextListOfValueNamePairs != null && ! (cddContextListOfValueNamePairs instanceof ListOfValueNamePairs)) {
+ cddContextListOfValueNamePairs = cddContextListOfValueNamePairs.eContainer() ;
+ }
+ if (cddContextListOfValueNamePairs != null) {
+ ListOfValueNamePairs listOfValueNamePairs = (ListOfValueNamePairs)cddContextListOfValueNamePairs ;
+ for (ValueNamePair valueNamePair : listOfValueNamePairs.getValueNamePairs()) {
+ if (valueNamePair.getProperty() != null)
+ allReadySpecifiedProperties.add(valueNamePair.getProperty()) ;
+ }
+ }
+ allProperties.removeAll(allReadySpecifiedProperties) ;
+
+ // Then builds the proposal list
+ Iterable<IEObjectDescription> iterableIEobjectDescription = Scopes.scopedElementsFor(allProperties) ;
+ IScope scope = new SimpleScope(iterableIEobjectDescription) ;
+ for (IEObjectDescription eobjectDescription : scope.getAllContents()) {
+ if (eobjectDescription.getName().toLowerCase().contains(context.getPrefix().toLowerCase())) {
+ String displayString = eobjectDescription.getName() + " = ";
+ String completionString = eobjectDescription.getName() + " = ";
+ ICompletionProposal completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix((NamedElement)eobjectDescription.getEObjectOrProxy(), completionString, displayString, context) ;
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ //super.completeValueNamePair_Property(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeValueNamePair_Value(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ if (model == null || !(model instanceof ValueNamePair))
+ return ;
+ ValueNamePair valueNamePairRuleRule = (ValueNamePair)model ;
+
+ if (valueNamePairRuleRule.getProperty() == null || valueNamePairRuleRule.getProperty().getType() == null)
+ return ;
+
+ Property p = valueNamePairRuleRule.getProperty() ;
+
+ Map<String,Element> allProposals = VSLProposalUtils.buildProposalForType((Classifier)p.getType()) ;
+ for (String s : allProposals.keySet()) {
+ if (s.startsWith(context.getPrefix())) {
+ String completionString ;
+ String displayString ;
+ ICompletionProposal completionProposal = null ;
+ if (allProposals.get(s) == null) {
+ completionString = s.substring(context.getPrefix().length()) ;
+ displayString = s ;
+ completionProposal = CompletionProposalUtils.createCompletionProposal(completionString, displayString, context) ;
+ }
+ else {
+ if (! s.contains("|")) {
+ completionString = s ;
+ displayString = s ;
+ }
+ else {
+ completionString = s.substring(0, s.indexOf("|")) ;
+ displayString = s.substring(s.indexOf("|") + 1) ;
+ }
+ completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix(((allProposals.get(s) != null) && (allProposals.get(s) instanceof NamedElement)) ? (NamedElement)allProposals.get(s) : null, completionString, displayString, context) ;
+ }
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+
+ @Override
+ public void completeInstantObsExpression_Id(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ for (Element e : ScopingVisitors.recursivelyownedAndImportedInstantObservations.visit(VSLJavaValidator.getModel())) {
+ TimeObservation t = (TimeObservation)e ;
+ if (t.getName().toLowerCase().contains((context.getPrefix().toLowerCase()))) {
+ String displayString = t.getQualifiedName() ;
+ String completionString = CompletionProposalUtils.getQualifiedNameLabelWithSufficientDepth(t, VSLJavaValidator.getModel()) ;
+ ICompletionProposal proposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix(t, completionString, displayString, context) ;
+ acceptor.accept(proposal) ;
+ }
+ }
+ }
+
+ @Override
+ public void completeInstantObsExpression_Index(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeInstantObsExpression_Index(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeInstantObsExpression_Condition(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeInstantObsExpression_Condition(model, assignment, context,
+ acceptor);
+ }
+
+ @Override
+ public void completeInstantObsName_Path(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // ignore. already treated by InstantObsExpression
+ }
+
+ @Override
+ public void completeInstantObsName_InstantId(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ if (model instanceof InstantObsName) {
+ IScope scope = VSLScopeProvider.eInstance.scope_InstantObsName_instantId((InstantObsName)model, VSLPackage.eINSTANCE.getInstantObsName_InstantId()) ;
+ for (IEObjectDescription eobjectDescription : scope.getAllContents()) {
+ if (eobjectDescription.getName().toLowerCase().contains(context.getPrefix().toLowerCase())) {
+ String displayString = eobjectDescription.getName() ;
+ String completionString = eobjectDescription.getName() ;
+ ICompletionProposal completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix((NamedElement)eobjectDescription.getEObjectOrProxy(), completionString, displayString, context) ;
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+ else {
+ // ignore. Already treated by rule InstantObsExpression_ID
+ }
+ }
+
+ @Override
+ public void completeDurationObsExpression_Id(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ for (Element e : ScopingVisitors.recursivelyownedAndImportedDurationObservations.visit(VSLJavaValidator.getModel())) {
+ DurationObservation d = (DurationObservation)e ;
+ if (d.getName().toLowerCase().contains((context.getPrefix().toLowerCase()))) {
+ String displayString = d.getQualifiedName() ;
+ String completionString = CompletionProposalUtils.getQualifiedNameLabelWithSufficientDepth(d, VSLJavaValidator.getModel()) ;
+ ICompletionProposal proposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix(d, completionString, displayString, context) ;
+ acceptor.accept(proposal) ;
+ }
+ }
+ }
+
+ @Override
+ public void completeDurationObsExpression_Index(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeDurationObsExpression_Index(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeDurationObsExpression_Condition(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeDurationObsExpression_Condition(model, assignment, context,
+ acceptor);
+ }
+
+ @Override
+ public void completeDurationObsName_Path(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeDurationObsName_Path(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeDurationObsName_DurationId(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ if (model instanceof DurationObsName) {
+ IScope scope = VSLScopeProvider.eInstance.scope_DurationObsName_durationId((DurationObsName)model, VSLPackage.eINSTANCE.getDurationObsName_DurationId()) ;
+ for (IEObjectDescription eobjectDescription : scope.getAllContents()) {
+ if (eobjectDescription.getName().toLowerCase().contains(context.getPrefix().toLowerCase())) {
+ String displayString = eobjectDescription.getName() ;
+ String completionString = eobjectDescription.getName() ;
+ ICompletionProposal completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix((NamedElement)eobjectDescription.getEObjectOrProxy(), completionString, displayString, context) ;
+ acceptor.accept(completionProposal) ;
+ }
+ }
+ }
+ else {
+ // ignore. Already treated by rule DurationObsExpression_ID
+ }
+ }
+
+ @Override
+ public void completeJitterExp_FirstInstant(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ if (!context.getPrefix().equals("@")) {
+ String displayString = "@" ;
+ String completionString = "@" ;
+ ICompletionProposal completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix(null, completionString, displayString, context) ;
+ acceptor.accept(completionProposal) ;
+ }
+ }
+
+ @Override
+ public void completeJitterExp_SecondInstant(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ if (!context.getPrefix().equals("@")) {
+ String displayString = "@" ;
+ String completionString = "@" ;
+ ICompletionProposal completionProposal = CompletionProposalUtils.createCompletionProposalWithReplacementOfPrefix(null, completionString, displayString, context) ;
+ acceptor.accept(completionProposal) ;
+ }
+ }
+
+ @Override
+ public void completeVariableDeclaration_VariableDeclaration(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.completeVariableDeclaration_VariableDeclaration(model, assignment,
+ context, acceptor);
+ }
+
+ @Override
+ public void completeVariableDeclaration_Name(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.completeVariableDeclaration_Name(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeVariableDeclaration_Type(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.completeVariableDeclaration_Type(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeVariableDeclaration_InitValue(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.completeVariableDeclaration_InitValue(model, assignment, context,
+ acceptor);
+ }
+
+ @Override
+ public void completeDataTypeName_Path(EObject model, Assignment assignment,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.completeDataTypeName_Path(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeDataTypeName_Type(EObject model, Assignment assignment,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.completeDataTypeName_Type(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeIntegerLiteralRule_Value(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeIntegerLiteralRule_Value(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeUnlimitedLiteralRule_Value(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeUnlimitedLiteralRule_Value(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeRealLiteralRule_Value(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeRealLiteralRule_Value(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeDateTimeLiteralRule_Value(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeDateTimeLiteralRule_Value(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeBooleanLiteralRule_Value(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeBooleanLiteralRule_Value(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeNullLiteralRule_Value(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeNullLiteralRule_Value(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeDefaultLiteralRule_Value(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeDefaultLiteralRule_Value(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void completeStringLiteralRule_Value(EObject model,
+ Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.completeStringLiteralRule_Value(model, assignment, context, acceptor);
+ }
+
+ @Override
+ public void complete_Expression(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.complete_Expression(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_AndOrXorExpression(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.complete_AndOrXorExpression(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_EqualityExpression(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // Auto-generated method stub
+ super.complete_EqualityExpression(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_RelationalExpression(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_RelationalExpression(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_ConditionalExpression(EObject model,
+ RuleCall ruleCall, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_ConditionalExpression(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_AdditiveExpression(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_AdditiveExpression(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_MultiplicativeExpression(EObject model,
+ RuleCall ruleCall, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_MultiplicativeExpression(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_UnaryExpression(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_UnaryExpression(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_PrimaryExpression(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_PrimaryExpression(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_ValueSpecification(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_ValueSpecification(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_SuffixExpression(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_SuffixExpression(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_PropertyCallExpression(EObject model,
+ RuleCall ruleCall, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_PropertyCallExpression(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_OperationCallExpression(EObject model,
+ RuleCall ruleCall, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_OperationCallExpression(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_Literal(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_Literal(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_NameOrChoiceOrBehaviorCall(EObject model,
+ RuleCall ruleCall, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ //super.complete_NameOrChoiceOrBehaviorCall(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_QualifiedName(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_QualifiedName(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_Interval(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_Interval(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_CollectionOrTuple(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_CollectionOrTuple(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_Tuple(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_Tuple(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_ListOfValues(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_ListOfValues(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_ListOfValueNamePairs(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_ListOfValueNamePairs(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_ValueNamePair(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_ValueNamePair(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_TimeExpression(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_TimeExpression(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_InstantObsExpression(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_InstantObsExpression(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_InstantObsName(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+
+ super.complete_InstantObsName(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_DurationObsExpression(EObject model,
+ RuleCall ruleCall, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_DurationObsExpression(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_DurationObsName(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_DurationObsName(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_JitterExp(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_JitterExp(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_VariableDeclaration(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_VariableDeclaration(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_VariableDirectionKind(EObject model,
+ RuleCall ruleCall, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_VariableDirectionKind(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_DataTypeName(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_DataTypeName(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_NumberLiteralRule(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_NumberLiteralRule(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_IntegerLiteralRule(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_IntegerLiteralRule(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_IntegerLiteral(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_IntegerLiteral(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_UnlimitedLiteralRule(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_UnlimitedLiteralRule(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_RealLiteralRule(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_RealLiteralRule(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_RealLiteral(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_RealLiteral(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_DateTimeLiteralRule(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_DateTimeLiteralRule(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_DateTimeLiteral(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_DateTimeLiteral(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_BooleanLiteralRule(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_BooleanLiteralRule(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_BooleanLiteral(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_BooleanLiteral(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_NullLiteralRule(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_NullLiteralRule(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_NullLiteral(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_NullLiteral(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_DefaultLiteralRule(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_DefaultLiteralRule(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void complete_StringLiteralRule(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ super.complete_StringLiteralRule(model, ruleCall, context, acceptor);
+ }
+
+ @Override
+ public void completeKeyword(Keyword keyword,
+ ContentAssistContext contentAssistContext,
+ ICompletionProposalAcceptor acceptor) {
+ // TODO Auto-generated method stub
+ if (!contentAssistContext.getPrefix().equals("")) {
+ if (keyword.getValue().startsWith(contentAssistContext.getPrefix()))
+ super.completeKeyword(keyword, contentAssistContext, acceptor);
+ }
+ }
+
+ @Override
+ public void complete_STRING(EObject model, RuleCall ruleCall,
+ ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ // super.complete_STRING(model, ruleCall, context, acceptor);
+ }
+
+}
diff --git a/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/VSLProposalUtils.java b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/VSLProposalUtils.java
new file mode 100644
index 00000000000..d4575572419
--- /dev/null
+++ b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/contentassist/VSLProposalUtils.java
@@ -0,0 +1,488 @@
+/*****************************************************************************
+ * 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.vsl.ui.contentassist;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.marte.vsl.extensions.VSLContextUtil;
+import org.eclipse.papyrus.marte.vsl.scoping.VSLScopeProvider;
+import org.eclipse.papyrus.marte.vsl.scoping.visitors.ScopingVisitors;
+import org.eclipse.papyrus.marte.vsl.validation.VSLJavaValidator;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.EnumerationLiteral;
+import org.eclipse.uml2.uml.MultiplicityElement;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Namespace;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.ParameterDirectionKind;
+import org.eclipse.uml2.uml.PrimitiveType;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.xtext.scoping.IScope;
+
+public class VSLProposalUtils {
+
+ public static Map<String, Element> buildProposalForType(Classifier classifier, MultiplicityElement elem) {
+ Map<String, Element> allProposals = buildProposalForType(classifier) ;
+ if (elem.upperBound() == 1)
+ return allProposals ;
+ Map<String, Element> allProposalsWithAccountForMultiplicity = new HashMap<String, Element>() ;
+ for (String s : allProposals.keySet()) {
+ String displayString ;
+ if (! s.contains("|")) {
+ displayString = s ;
+ }
+ else {
+ String[] splitted = s.split("|") ;
+ displayString = splitted[0] ;
+ }
+
+ String newProposal = "{" + displayString + "/* , " + displayString + " */ }" ;
+ allProposalsWithAccountForMultiplicity.put(newProposal, allProposals.get(s)) ;
+ }
+ return allProposalsWithAccountForMultiplicity ;
+ }
+
+ public static Map<String, Element> buildProposalForType(Classifier classifier) {
+ Map<String, Element> allProposals = new HashMap<String, Element>() ;
+
+ if (VSLContextUtil.isATupleType(classifier)) {
+ allProposals.putAll(buildProposalForTupleType(classifier)) ;
+ }
+ else if (VSLContextUtil.isAChoiceType(classifier)) {
+ allProposals.putAll(buildProposalForChoiceType(classifier)) ;
+ }
+ else if (VSLContextUtil.isACollectionType(classifier)) {
+ allProposals.putAll(buildProposalForCollectionType(classifier)) ;
+ }
+ else if (classifier instanceof Enumeration) {
+ allProposals.putAll(buildProposalForEnumeration(classifier)) ;
+ }
+ else if (classifier instanceof PrimitiveType) {
+ allProposals.putAll(buildProposalForPrimitiveType(classifier)) ;
+ }
+ else if (classifier instanceof Stereotype) {
+ allProposals.putAll(buildProposalForStereotype(classifier)) ;
+ }
+ else if (classifier instanceof org.eclipse.uml2.uml.Class) {
+ allProposals.putAll(buildProposalForMetaclass(classifier)) ;
+ }
+ else {
+ allProposals.put("/* " + classifier.getName() + "*/", null) ;
+ }
+
+ Map<String, Element> crossReferences = new HashMap<String, Element>() ;
+ crossReferences.putAll(buildProposalForMetaclass(UMLPackage.eINSTANCE.getBehavior())) ;
+
+ List<String> proposalsToBeRemoved = new ArrayList<String>() ;
+ for (String key : crossReferences.keySet()) {
+ Type behaviorReturnType = null ;
+ Behavior behavior = (Behavior)crossReferences.get(key); ;
+ for (Parameter p : behavior.getOwnedParameters()) {
+ if (p.getDirection() == ParameterDirectionKind.RETURN_LITERAL)
+ behaviorReturnType = p.getType() ;
+ }
+ if (behaviorReturnType == null)
+ proposalsToBeRemoved.add(key) ;
+ else if ((classifier.getName().equals("Integer") || classifier.getName().equals("Boolean") || classifier.getName().equals("String"))
+ && !behaviorReturnType.getName().equals(classifier.getName())) {
+ proposalsToBeRemoved.add(key) ;
+ }
+ else if (! behaviorReturnType.conformsTo(classifier))
+ proposalsToBeRemoved.add(key) ;
+ }
+
+ for (String key : proposalsToBeRemoved)
+ crossReferences.remove(key) ;
+
+ for (String key : crossReferences.keySet()) {
+ Behavior calledBehavior = (Behavior)crossReferences.get(key) ;
+ allProposals.put(buildCompletionStringForBehaviorCall(calledBehavior) + "|" + buildDisplayStringForBehaviorCall(calledBehavior), calledBehavior) ;
+ }
+
+ // if the global context element is nested inside a classifier:
+ // - retrieves the classifier, and gets all its owned and inherited attributes
+ Element context = VSLJavaValidator.getContextElement() ;
+ while (context != null && !(context instanceof Classifier)) {
+ context = context.getOwner();
+ }
+ if (context != null && context instanceof Classifier) {
+ List<Property> allProperties = ((Classifier)context).getAllAttributes() ;
+ for (Property p : allProperties) {
+ List<Classifier> classifiers = new ArrayList<Classifier>() ;
+ //classifiers.add((Classifier)p.getType()) ;
+ FeatureTree tree = new FeatureTree(p, classifiers) ;
+ if (tree.canClassifierBeReached(classifier)) {
+ allProposals.put(p.getName(),p ) ;
+ }
+ }
+ }
+
+ return allProposals ;
+ }
+
+ protected static Map<String, Element> buildProposalForTupleType(Classifier classifier) {
+ Map<String, Element> allProposals = new HashMap<String, Element>() ;
+ String proposal = "" ;
+ proposal += "{" ;
+ Property p = null ;
+ Property propertyValue = null ;
+ Property propertyUnit = null ;
+ boolean first = true ;
+ for (NamedElement n : VSLContextUtil.getTupleAttribs(classifier)) {
+ p = (Property)n ;
+ if (p.getType() != null && !p.getType().getName().equalsIgnoreCase("VSL_Expression")) {
+ if (! first)
+ proposal += ", " ;
+ else
+ first = false ;
+ proposal += p.getName() + " = /" ;
+ if (p.getName().equals("value"))
+ propertyValue = p ;
+ else if (p.getName().equals("unit"))
+ propertyUnit = p ;
+ }
+ }
+ if (propertyUnit != null && propertyValue != null) {
+ // This is a nfp type. Builds a short proposal with only value and unit, since these properties are more commonly used
+ String shortProposal = "{unit = /, value = /}" ;
+ allProposals.put(shortProposal, null) ;
+ }
+ proposal += "}" ;
+ allProposals.put(proposal, null) ;
+ return allProposals ;
+ }
+
+ protected static Map<String, Element> buildProposalForChoiceType(Classifier classifier) {
+ Map<String, Element> allProposals = new HashMap<String, Element>() ;
+ Property p = null ;
+ for (NamedElement n : VSLContextUtil.getChoiceAttribs(classifier)) {
+ p = (Property)n ;
+ String choiceProposal = p.getName() + "(" ;
+ Map<String, Element> nestedProposals = buildProposalForType((Classifier)p.getType()) ;
+ for (String nestedProposal : nestedProposals.keySet()) {
+ allProposals.put(choiceProposal + nestedProposal + ")", null) ;
+ }
+ }
+ return allProposals ;
+ }
+
+ protected static Map<String, Element> buildProposalForCollectionType(Classifier classifier) {
+ Map<String, Element> allProposals = new HashMap<String, Element>() ;
+ Property p = null ;
+ if (VSLContextUtil.getCollectionAttrib(classifier) != null)
+ p = (Property) VSLContextUtil.getCollectionAttrib(classifier);
+ if (p.getType() != null) {
+ Map<String, Element> nestedProposals = buildProposalForType((Classifier)p.getType()) ;
+ for (String nestedProposal : nestedProposals.keySet()) {
+ allProposals.put("{" + nestedProposal + "}", null) ;
+ }
+ }
+ return allProposals ;
+ }
+
+ protected static Map<String, Element> buildProposalForEnumeration(Classifier classifier) {
+ HashMap<String, Element> allProposals = new HashMap<String, Element>() ;
+ for (EnumerationLiteral n : ((Enumeration)classifier).getOwnedLiterals()) {
+ allProposals.put(n.getName(), n) ;
+ }
+ return allProposals ;
+ }
+
+ protected static Map<String, Element> buildProposalForPrimitiveType(Classifier classifier) {
+ Map<String, Element> allProposals = new HashMap<String, Element>() ;
+ if (classifier.getName().contains("Integer")) {
+ allProposals.put("1", null) ;
+ }
+ else if (classifier.getName().contains("Real")) {
+ allProposals.put("1.0", null) ;
+ }
+ else if (classifier.getName().contains("Natural")) {
+ allProposals.put("*", null) ;
+ }
+ else if (classifier.getName().contains("DateTime")) {
+ Date currentDate = new Date() ;
+ String year = "" + (currentDate.getYear()+1900) ;
+ String month = "" + currentDate.getMonth() ; if (month.length() == 1) month = "0" + month ;
+ String day = "" ;
+ switch (currentDate.getDay()) {
+ case 0:
+ day += "Sun" ;
+ break;
+ case 1:
+ day += "Mon" ;
+ break;
+ case 2:
+ day += "Tue" ;
+ break;
+ case 3:
+ day += "Wed" ;
+ break;
+ case 4:
+ day += "Thu" ;
+ break;
+ case 5:
+ day += "Fri" ;
+ break;
+ default:
+ day += "Sat" ;
+ break;
+ }
+ String dayOfMonth = "" + currentDate.getDate() ; if (dayOfMonth.length() == 1) dayOfMonth = "0" + dayOfMonth ;
+ String hour = "" + currentDate.getHours() ; if (hour.length() == 1) hour = "0" + hour ;
+ String minute = "" + currentDate.getMinutes() ; if (minute.length() == 1) minute = "0" + minute ;
+ String second = "" + currentDate.getSeconds() ; if (second.length() == 1) second = "0" + second ;
+ String centi = "00" ;
+
+ String dateString = year + "/" + month + "/" + dayOfMonth ; // opt1
+ String dateString_dayString = dateString + " " + day ; // opt2
+ String timeString = hour + ":" + minute + ":" + second ; // opt3
+ String timeString_dateString_dayString = timeString + " " + dateString + " " + day ; //opt4
+ String timeString_dayString = timeString + " " + day ; //opt5
+ String timeString_dateString = timeString + " " + dateString ; //opt6
+ String dayString = day ; //opt7
+
+ allProposals.put(timeString_dateString_dayString, null) ;
+ allProposals.put(timeString_dayString, null) ;
+ allProposals.put(timeString_dateString, null) ;
+ allProposals.put(timeString, null) ;
+ allProposals.put(dateString_dayString, null) ;
+ allProposals.put(dateString, null) ;
+ allProposals.put(dayString, null) ;
+
+// <datetime-literal> ::= (<date-string> [<daystring>] ) | ( <time-string> [<datestring>]
+// [<day-string>] ) | ( <day-string> )
+// <time-string> ::= <hr> [':' <min> [':' <sec> [':' <centisec>] ] ]
+// <hr> ::= '00'..'23'
+// <min> ::= '00'..'59'
+// <sec> ::= '00'..'59'
+// <centisec> ::= '00'..'99'
+// <date-string> ::= <year> '/' <mon> '/' <day-of-mon>
+// <year> ::= '0000'..'9999'
+// <mon> ::= '01'..'12'
+// <day-of-mon> ::= '01'..'31'
+// <day-string> ::= 'Mon' | 'Tue' | 'Wed' | 'Thr' | 'Fri' | 'Sat' | 'Sun'
+ }
+ else if (classifier.getName().contains("Boolean")) {
+ allProposals.put("true", null) ;
+ allProposals.put("false", null) ;
+ }
+ else if (classifier.getName().contains("String")) {
+ allProposals.put("\"value\"", null) ;
+ }
+ return allProposals ;
+ }
+
+ protected static Map<String, Element> buildProposalForStereotype(Classifier classifier) {
+ List<Element> allElements = new ArrayList<Element>() ;
+ Map<String, Element> allProposals = new HashMap<String, Element>() ;
+ allElements.addAll(new ScopingVisitors.Visitor_GetRecursivelyOwnedAndImportedStereotypeInstances().visit(VSLJavaValidator.getModel(), (Stereotype)classifier)) ;
+ for (Element c : allElements) {
+ if (c instanceof NamedElement) {
+ allProposals.put(getNameLabel((NamedElement)c), c);
+ }
+ }
+ return allProposals ;
+ }
+
+ protected static Map<String, Element> buildProposalForMetaclass(Classifier classifier) {
+ List<Element> allElements = new ArrayList<Element>() ;
+ Map<String, Element> allProposals = new HashMap<String, Element>() ;
+ allElements.addAll(new ScopingVisitors.Visitor_GetRecursivelyOwnedAndImportedMetaclassInstances().visit(VSLJavaValidator.getModel(), (org.eclipse.uml2.uml.Class)classifier)) ;
+ for (Element c : allElements) {
+ if (c instanceof NamedElement) {
+ allProposals.put(getNameLabel((NamedElement)c), c);
+ }
+ }
+ return allProposals ;
+ }
+
+ protected static Map<String, Element> buildProposalForMetaclass(EClass metaclass) {
+ List<Element> allElements = new ArrayList<Element>() ;
+ Map<String, Element> allProposals = new HashMap<String, Element>() ;
+ allElements.addAll(new ScopingVisitors.Visitor_GetRecursivelyOwnedAndImportedMetaclassInstances().visit(VSLJavaValidator.getModel(), metaclass)) ;
+ for (Element c : allElements) {
+ if (c instanceof NamedElement) {
+ allProposals.put(getNameLabel((NamedElement)c), c);
+ }
+ }
+ return allProposals ;
+ }
+
+ public static String getNameLabel(NamedElement elem) {
+ String label = "" ;
+
+ Namespace model = VSLJavaValidator.getModel() ;
+ List<Package> importedPackages = new ArrayList<Package>(model.getImportedPackages()) ;
+
+ List<Namespace> visitedNamespaces = new ArrayList<Namespace>() ;
+ Namespace currentNamespace = elem.getNamespace() ;
+
+ boolean rootFound = false ;
+
+ while (currentNamespace != null && !rootFound) {
+ visitedNamespaces.add(currentNamespace) ;
+ if (importedPackages.contains(currentNamespace) || currentNamespace == model) {
+ rootFound = true ;
+ }
+ Element owner = currentNamespace.getOwner() ;
+
+ currentNamespace = owner != null ? (Namespace)owner : null ;
+ }
+
+ for (int i = visitedNamespaces.size() - 1 ; i >= 0 ; i--) {
+ label += visitedNamespaces.get(i).getName() + "::" ;
+ }
+
+ return label + elem.getName() ;
+ }
+
+ public static String buildDisplayStringForBehaviorCall(Behavior calledBehavior) {
+ String label = calledBehavior.getName() + "(" ;
+ String returnTypeName = "" ;
+ List<String> parameterLabels = new ArrayList<String>() ;
+ for (Parameter p : calledBehavior.getOwnedParameters()) {
+ if (p.getDirection() == ParameterDirectionKind.RETURN_LITERAL) {
+ returnTypeName = p.getType().getName() ;
+ }
+ else {
+ String parameterLabel = "" ;
+ switch (p.getDirection()) {
+ case IN_LITERAL:
+ parameterLabel += "in " ;
+ break;
+ case OUT_LITERAL:
+ parameterLabel += "out " ;
+ break;
+ case INOUT_LITERAL:
+ parameterLabel += "inout " ;
+ break;
+ default:
+ break;
+ }
+ parameterLabel += p.getName() + " : " + p.getType().getName() ;
+ parameterLabels.add(parameterLabel) ;
+ }
+ }
+ boolean first = true ;
+ for (String parameterLabel : parameterLabels) {
+ if (!first)
+ label += ", " ;
+ else
+ first = false ;
+ label += parameterLabel ;
+ }
+
+ return label + ") : " + returnTypeName ;
+ }
+
+ public static String buildCompletionStringForBehaviorCall(Behavior calledBehavior) {
+ String label = calledBehavior.getName() + "(" ;
+ List<String> parameterLabels = new ArrayList<String>() ;
+ for (Parameter p : calledBehavior.getOwnedParameters()) {
+ if (p.getDirection() == ParameterDirectionKind.RETURN_LITERAL) {
+ // ignore
+ }
+ else {
+ parameterLabels.add(p.getName()) ;
+ }
+ }
+ boolean first = true ;
+ for (String parameterLabel : parameterLabels) {
+ if (!first)
+ label += ", " ;
+ else
+ first = false ;
+ label += parameterLabel ;
+ }
+
+ return label + ")" ;
+ }
+
+ public static String buildDisplayStringForOperationCall(Operation calledOperation) {
+ String label = calledOperation.getName() + "(" ;
+ String returnTypeName = "" ;
+ List<String> parameterLabels = new ArrayList<String>() ;
+ for (Parameter p : calledOperation.getOwnedParameters()) {
+ if (p.getDirection() == ParameterDirectionKind.RETURN_LITERAL) {
+ returnTypeName = p.getType().getName() ;
+ }
+ else {
+ String parameterLabel = "" ;
+ switch (p.getDirection()) {
+ case IN_LITERAL:
+ parameterLabel += "in " ;
+ break;
+ case OUT_LITERAL:
+ parameterLabel += "out " ;
+ break;
+ case INOUT_LITERAL:
+ parameterLabel += "inout " ;
+ break;
+ default:
+ break;
+ }
+ parameterLabel += p.getName() + " : " + p.getType().getName() ;
+ parameterLabels.add(parameterLabel) ;
+ }
+ }
+ boolean first = true ;
+ for (String parameterLabel : parameterLabels) {
+ if (!first)
+ label += ", " ;
+ else
+ first = false ;
+ label += parameterLabel ;
+ }
+
+ return label + ") : " + returnTypeName ;
+ }
+
+ public static String buildCompletionStringForOperationCall(Operation calledOperation) {
+ String label = calledOperation.getName() + "(" ;
+ List<String> parameterLabels = new ArrayList<String>() ;
+ for (Parameter p : calledOperation.getOwnedParameters()) {
+ if (p.getDirection() == ParameterDirectionKind.RETURN_LITERAL) {
+ // ignore
+ }
+ else {
+ parameterLabels.add(p.getName()) ;
+ }
+ }
+ boolean first = true ;
+ for (String parameterLabel : parameterLabels) {
+ if (!first)
+ label += ", " ;
+ else
+ first = false ;
+ label += parameterLabel ;
+ }
+
+ return label + ")" ;
+ }
+}
diff --git a/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/labeling/VSLDescriptionLabelProvider.java b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/labeling/VSLDescriptionLabelProvider.java
new file mode 100644
index 00000000000..72b8eb50837
--- /dev/null
+++ b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/labeling/VSLDescriptionLabelProvider.java
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * 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.vsl.ui.labeling;
+
+import org.eclipse.xtext.ui.label.DefaultDescriptionLabelProvider;
+
+/**
+ * Provides labels for a IEObjectDescriptions and IResourceDescriptions.
+ *
+ * see http://www.eclipse.org/Xtext/documentation/latest/xtext.html#labelProvider
+ */
+public class VSLDescriptionLabelProvider extends DefaultDescriptionLabelProvider {
+
+/*
+ //Labels and icons can be computed like this:
+
+ String text(IEObjectDescription ele) {
+ return "my "+ele.getName();
+ }
+
+ String image(IEObjectDescription ele) {
+ return ele.getEClass().getName() + ".gif";
+ }
+*/
+
+}
diff --git a/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/labeling/VSLLabelProvider.java b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/labeling/VSLLabelProvider.java
new file mode 100644
index 00000000000..2e16fef41fd
--- /dev/null
+++ b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/labeling/VSLLabelProvider.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * 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.vsl.ui.labeling;
+
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider;
+
+import com.google.inject.Inject;
+
+/**
+ * Provides labels for a EObjects.
+ *
+ * see http://www.eclipse.org/Xtext/documentation/latest/xtext.html#labelProvider
+ */
+public class VSLLabelProvider extends DefaultEObjectLabelProvider {
+
+ @Inject
+ public VSLLabelProvider(AdapterFactoryLabelProvider delegate) {
+ super(delegate);
+ }
+
+/*
+ //Labels and icons can be computed like this:
+
+ String text(MyModel ele) {
+ return "my "+ele.getName();
+ }
+
+ String image(MyModel ele) {
+ return "MyModel.gif";
+ }
+*/
+}
diff --git a/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/outline/VSLOutlineNodeAdapterFactory.java b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/outline/VSLOutlineNodeAdapterFactory.java
new file mode 100644
index 00000000000..d414eae2a1d
--- /dev/null
+++ b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/outline/VSLOutlineNodeAdapterFactory.java
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ * 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.vsl.ui.outline;
+
+import org.eclipse.xtext.ui.editor.outline.actions.DefaultContentOutlineNodeAdapterFactory;
+
+public class VSLOutlineNodeAdapterFactory extends DefaultContentOutlineNodeAdapterFactory {
+
+ private static final Class<?>[] types = {
+ // provide list of classes to adapt to, e.g.:
+ // Entity.class
+ // Service.class
+ };
+
+ @Override
+ public Class<?>[] getAdapterList() {
+ return types;
+ }
+
+}
+
diff --git a/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/outline/VSLTransformer.java b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/outline/VSLTransformer.java
new file mode 100644
index 00000000000..1aae69f8698
--- /dev/null
+++ b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/outline/VSLTransformer.java
@@ -0,0 +1,24 @@
+/*****************************************************************************
+ * 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.vsl.ui.outline;
+
+import org.eclipse.xtext.ui.editor.outline.transformer.AbstractDeclarativeSemanticModelTransformer;
+
+/**
+ * customization of the default outline structure
+ *
+ */
+public class VSLTransformer extends AbstractDeclarativeSemanticModelTransformer {
+
+}
diff --git a/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/quickfix/VSLQuickfixProvider.java b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/quickfix/VSLQuickfixProvider.java
new file mode 100644
index 00000000000..099e20d73ef
--- /dev/null
+++ b/extraplugins/marte/org.eclipse.papyrus.marte.vsl.ui/src/org/eclipse/papyrus/marte/vsl/ui/quickfix/VSLQuickfixProvider.java
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ * 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.vsl.ui.quickfix;
+
+import org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider;
+
+public class VSLQuickfixProvider extends DefaultQuickfixProvider {
+
+// @Fix(MyJavaValidator.INVALID_NAME)
+// public void capitalizeName(final Issue issue, IssueResolutionAcceptor acceptor) {
+// acceptor.accept(issue, "Capitalize name", "Capitalize the name.", "upcase.png", new IModification() {
+// public void apply(IModificationContext context) throws BadLocationException {
+// IXtextDocument xtextDocument = context.getXtextDocument();
+// String firstLetter = xtextDocument.get(issue.getOffset(), 1);
+// xtextDocument.replace(issue.getOffset(), 1, firstLetter.toUpperCase());
+// }
+// });
+// }
+
+}

Back to the top