Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdolfo SBH2016-09-27 18:07:46 +0000
committerEd Willink2016-10-22 14:16:27 +0000
commit1feb8e4fd812df97853e6d1a361ee7b9d1284c89 (patch)
treeedaacbd443047f6592872cac568c7c532d39fe99
parent24a62bb4347cea76d98f83ce62a5a160ea36fbf9 (diff)
downloadorg.eclipse.qvtd-1feb8e4fd812df97853e6d1a361ee7b9d1284c89.tar.gz
org.eclipse.qvtd-1feb8e4fd812df97853e6d1a361ee7b9d1284c89.tar.xz
org.eclipse.qvtd-1feb8e4fd812df97853e6d1a361ee7b9d1284c89.zip
[cs2as] - Adding a basic proposal provider
-rw-r--r--doc/org.eclipse.qvtd.doc.minioclcs.xtext.ui/META-INF/MANIFEST.MF3
-rw-r--r--doc/org.eclipse.qvtd.doc.minioclcs.xtext.ui/src/org/eclipse/qvtd/doc/ui/contentassist/ContentAssitLookupEnvironment.java55
-rw-r--r--doc/org.eclipse.qvtd.doc.minioclcs.xtext.ui/src/org/eclipse/qvtd/doc/ui/contentassist/MiniOCLCSProposalProvider.xtend45
3 files changed, 102 insertions, 1 deletions
diff --git a/doc/org.eclipse.qvtd.doc.minioclcs.xtext.ui/META-INF/MANIFEST.MF b/doc/org.eclipse.qvtd.doc.minioclcs.xtext.ui/META-INF/MANIFEST.MF
index 469c9a211..6493cd061 100644
--- a/doc/org.eclipse.qvtd.doc.minioclcs.xtext.ui/META-INF/MANIFEST.MF
+++ b/doc/org.eclipse.qvtd.doc.minioclcs.xtext.ui/META-INF/MANIFEST.MF
@@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.qvtd.doc.minioclcs.xtext,
org.eclipse.xtext.builder,
org.eclipse.xtend.lib;resolution:=optional,
org.eclipse.xtext.xbase.lib,
- org.eclipse.qvtd.doc.miniocl;bundle-version="0.13.0"
+ org.eclipse.qvtd.doc.miniocl;bundle-version="0.13.0",
+ org.eclipse.ocl.pivot;bundle-version="[1.3.0,2.0.0)"
Import-Package: org.apache.log4j
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.qvtd.doc.minioclcs.xtext.ui.internal,
diff --git a/doc/org.eclipse.qvtd.doc.minioclcs.xtext.ui/src/org/eclipse/qvtd/doc/ui/contentassist/ContentAssitLookupEnvironment.java b/doc/org.eclipse.qvtd.doc.minioclcs.xtext.ui/src/org/eclipse/qvtd/doc/ui/contentassist/ContentAssitLookupEnvironment.java
new file mode 100644
index 000000000..2a70a80b0
--- /dev/null
+++ b/doc/org.eclipse.qvtd.doc.minioclcs.xtext.ui/src/org/eclipse/qvtd/doc/ui/contentassist/ContentAssitLookupEnvironment.java
@@ -0,0 +1,55 @@
+package org.eclipse.qvtd.doc.ui.contentassist;
+
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.ocl.pivot.evaluation.Executor;
+import org.eclipse.ocl.pivot.internal.library.ecore.EcoreExecutorManager;
+import org.eclipse.ocl.pivot.internal.library.executor.ExecutorStandardLibrary;
+import org.eclipse.qvtd.doc.miniocl.NamedElement;
+import org.eclipse.qvtd.doc.miniocl.lookup.LookupEnvironment;
+import org.eclipse.qvtd.doc.miniocl.lookup.impl.LookupEnvironmentImpl;
+
+
+public class ContentAssitLookupEnvironment extends LookupEnvironmentImpl {
+
+ private EcoreExecutorManager executor;
+
+ public ContentAssitLookupEnvironment(EObject object) {
+ executor = new EcoreExecutorManager(object, new ExecutorStandardLibrary()); // FIXME
+ }
+
+
+ @Override
+ public LookupEnvironment addElements( NamedElement namedElement) {
+ if (namedElement != null) {
+ EList<NamedElement> elements = getNamedElements();
+ if (!elements.contains(namedElement)) { // FIXME use a set ?
+ elements.add(namedElement);
+ }
+ }
+ return this;
+ }
+
+ @Override
+ public <NE extends NamedElement > LookupEnvironment addElements(Collection<NE> namedElements) {
+ if (namedElements != null) {
+ for (NamedElement namedElement : namedElements) {
+ addElements(namedElement);
+ }
+ }
+ return this;
+ }
+
+ @Override
+ public boolean hasFinalResult() {
+ return false; // So all the possible results are gathered
+ }
+
+ @Override
+ public Executor getExecutor() {
+ return executor;
+ }
+}
diff --git a/doc/org.eclipse.qvtd.doc.minioclcs.xtext.ui/src/org/eclipse/qvtd/doc/ui/contentassist/MiniOCLCSProposalProvider.xtend b/doc/org.eclipse.qvtd.doc.minioclcs.xtext.ui/src/org/eclipse/qvtd/doc/ui/contentassist/MiniOCLCSProposalProvider.xtend
index fea1e7d0a..c5699e46b 100644
--- a/doc/org.eclipse.qvtd.doc.minioclcs.xtext.ui/src/org/eclipse/qvtd/doc/ui/contentassist/MiniOCLCSProposalProvider.xtend
+++ b/doc/org.eclipse.qvtd.doc.minioclcs.xtext.ui/src/org/eclipse/qvtd/doc/ui/contentassist/MiniOCLCSProposalProvider.xtend
@@ -3,10 +3,55 @@
*/
package org.eclipse.qvtd.doc.ui.contentassist
+import org.eclipse.emf.ecore.EObject
+import org.eclipse.xtext.RuleCall
+import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext
+import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor
+import org.eclipse.qvtd.doc.miniocl.util.Visitable
+import org.eclipse.qvtd.doc.miniocl.lookup.LookupEnvironment
+import org.eclipse.qvtd.doc.miniocl.NamedElement
+import org.eclipse.qvtd.doc.miniocl.util.MiniOCLUnqualifiedClassLookupVisitor
+import org.eclipse.qvtd.doc.minioclcs.CSTrace
/**
* See https://www.eclipse.org/Xtext/documentation/304_ide_concepts.html#content-assist
* on how to customize the content assistant.
*/
class MiniOCLCSProposalProvider extends AbstractMiniOCLCSProposalProvider {
+
+
+ override complete_PathElementCS(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+ var asElement = getVisitableElement(model);
+ if (asElement != null ) {
+ var ContentAssitLookupEnvironment lookupEnv = new ContentAssitLookupEnvironment(asElement as EObject);
+ var MiniOCLUnqualifiedClassLookupVisitor visitor = new MiniOCLUnqualifiedClassLookupVisitor(lookupEnv);
+ createProposals(asElement.accept(visitor), context, acceptor);
+ }
+ super.complete_PathElementCS(model, ruleCall, context, acceptor)
+ }
+
+
+
+ def Visitable getVisitableElement(EObject model) {
+
+ var sElement = model;
+ while (sElement != null) {
+ if (sElement instanceof CSTrace) {
+ var EObject asElement = sElement.ast;
+ if (asElement instanceof Visitable) {
+ return asElement;
+ }
+ }
+ sElement = sElement.eContainer;
+ }
+ return null;
+ }
+
+ def void createProposals(LookupEnvironment lookupEnv, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+
+ for (NamedElement namedElement : lookupEnv.namedElements) {
+ acceptor.accept(createCompletionProposal(namedElement.name, context))
+ }
+ }
+
}

Back to the top