Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/contentassist/BaseProposalProvider.java24
-rw-r--r--plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/base/util/ImportHelpers.java14
-rw-r--r--plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/contentassist/ConfigProposalProvider.java9
-rw-r--r--plugins/org.eclipse.etrice.core.etmap.ui/src/org/eclipse/etrice/core/etmap/ui/contentassist/ETMapProposalProvider.java10
-rw-r--r--plugins/org.eclipse.etrice.core.etphys.ui/src/org/eclipse/etrice/core/etphys/ui/contentassist/ETPhysProposalProvider.java9
-rw-r--r--plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/contentassist/RoomProposalProvider.java10
6 files changed, 68 insertions, 8 deletions
diff --git a/plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/contentassist/BaseProposalProvider.java b/plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/contentassist/BaseProposalProvider.java
index fc1860849..ec053babd 100644
--- a/plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/contentassist/BaseProposalProvider.java
+++ b/plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/contentassist/BaseProposalProvider.java
@@ -14,17 +14,24 @@
*******************************************************************************/
package org.eclipse.etrice.core.common.ui.contentassist;
+import java.util.Arrays;
+
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.etrice.core.common.base.util.ImportHelpers;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.xtext.RuleCall;
import org.eclipse.xtext.naming.IQualifiedNameConverter;
import org.eclipse.xtext.naming.QualifiedName;
import org.eclipse.xtext.resource.IEObjectDescription;
+import org.eclipse.xtext.scoping.IScope;
import org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal;
import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext;
import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor;
import com.google.common.base.Function;
+import com.google.inject.Inject;
/**
* see http://www.eclipse.org/Xtext/documentation.html#contentAssist on how to
@@ -32,6 +39,8 @@ import com.google.common.base.Function;
*/
public class BaseProposalProvider extends org.eclipse.etrice.core.common.ui.contentassist.AbstractBaseProposalProvider {
+ @Inject protected ImportHelpers importHelpers;
+
@Override
public void complete_TIME(EObject model, RuleCall ruleCall, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {
@@ -55,6 +64,21 @@ public class BaseProposalProvider extends org.eclipse.etrice.core.common.ui.cont
super.complete_TIME(model, ruleCall, context, acceptor);
}
+ /**
+ * Creates content assist proposals for imported namespaces that match the given type and filter.
+ */
+ protected void lookupImportedNamespace(EObject model, ContentAssistContext context, ICompletionProposalAcceptor acceptor,
+ EClass... types) {
+ IScope scope = importHelpers.getVisibleScope(model.eResource(), EcorePackage.eINSTANCE.getEObject(),
+ eod -> Arrays.stream(types).anyMatch(t -> t.isSuperTypeOf(eod.getEClass())));
+ DefaultProposalCreator proposalCreator = new DefaultProposalCreator(context, null, getQualifiedNameConverter());
+ for (IEObjectDescription candidate : scope.getAllElements()) {
+ if (!acceptor.canAcceptMoreProposals())
+ return;
+ acceptor.accept(proposalCreator.apply(candidate));
+ }
+ }
+
@Override
protected Function<IEObjectDescription, ICompletionProposal> getProposalFactory(String ruleName,
ContentAssistContext contentAssistContext) {
diff --git a/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/base/util/ImportHelpers.java b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/base/util/ImportHelpers.java
index 0dc81ce52..42300e5f6 100644
--- a/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/base/util/ImportHelpers.java
+++ b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/base/util/ImportHelpers.java
@@ -84,17 +84,23 @@ public class ImportHelpers {
* Returns current visible/imported scope of given resource.
*/
public IScope getVisibleScope(Resource context) {
- return getVisibleScope(context, null);
+ return getVisibleScope(context, EOBJECT);
}
/**
* Returns current visible/imported scope of given resource.
*/
public IScope getVisibleScope(Resource context, EClass type) {
+ return getVisibleScope(context, type, Predicates.alwaysTrue());
+ }
+
+ /**
+ * Returns current imported scope of given resource.
+ */
+ public IScope getVisibleScope(Resource context, EClass type, Predicate<IEObjectDescription> filter) {
EReference reference = EcoreFactory.eINSTANCE.createEReference();
- reference.setEType((type != null) ? type : EOBJECT);
-
- return globalScope.getScope(context, reference, Predicates.alwaysTrue());
+ reference.setEType((type != null) ? type : EOBJECT);
+ return globalScope.getScope(context, reference, filter);
}
/**
diff --git a/plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/contentassist/ConfigProposalProvider.java b/plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/contentassist/ConfigProposalProvider.java
index 585afa7f5..87f63e456 100644
--- a/plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/contentassist/ConfigProposalProvider.java
+++ b/plugins/org.eclipse.etrice.core.config.ui/src/org/eclipse/etrice/core/ui/contentassist/ConfigProposalProvider.java
@@ -35,6 +35,7 @@ import org.eclipse.etrice.core.room.DataType;
import org.eclipse.etrice.core.room.EnumLiteral;
import org.eclipse.etrice.core.room.EnumerationType;
import org.eclipse.etrice.core.room.PrimitiveType;
+import org.eclipse.etrice.core.room.RoomPackage;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.xtext.Assignment;
import org.eclipse.xtext.Keyword;
@@ -58,12 +59,18 @@ public class ConfigProposalProvider extends AbstractConfigProposalProvider {
private ConfigUtil configUtil;
@Override
+ public void completeImport_ImportedNamespace(EObject model, Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ lookupImportedNamespace(model, context, acceptor, RoomPackage.eINSTANCE.getRoomClass());
+ }
+
+ @Override
public void completeImport_ImportURI(EObject model, Assignment assignment,
final ContentAssistContext context,
final ICompletionProposalAcceptor acceptor) {
ImportModelAssist.addPaths(this, context, acceptor, ".room");
}
-
+
@Override
public void completeActorInstanceConfig_Path(EObject model,
Assignment assignment, ContentAssistContext context,
diff --git a/plugins/org.eclipse.etrice.core.etmap.ui/src/org/eclipse/etrice/core/etmap/ui/contentassist/ETMapProposalProvider.java b/plugins/org.eclipse.etrice.core.etmap.ui/src/org/eclipse/etrice/core/etmap/ui/contentassist/ETMapProposalProvider.java
index 1d91477c5..b2b0d1918 100644
--- a/plugins/org.eclipse.etrice.core.etmap.ui/src/org/eclipse/etrice/core/etmap/ui/contentassist/ETMapProposalProvider.java
+++ b/plugins/org.eclipse.etrice.core.etmap.ui/src/org/eclipse/etrice/core/etmap/ui/contentassist/ETMapProposalProvider.java
@@ -16,6 +16,8 @@ package org.eclipse.etrice.core.etmap.ui.contentassist;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.etrice.core.common.ui.contentassist.ImportModelAssist;
+import org.eclipse.etrice.core.etphys.eTPhys.ETPhysPackage;
+import org.eclipse.etrice.core.room.RoomPackage;
import org.eclipse.xtext.Assignment;
import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext;
import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor;
@@ -26,11 +28,17 @@ import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor;
public class ETMapProposalProvider extends AbstractETMapProposalProvider {
@Override
+ public void completeImport_ImportedNamespace(EObject model, Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ lookupImportedNamespace(model, context, acceptor, RoomPackage.eINSTANCE.getLogicalSystem(), ETPhysPackage.eINSTANCE.getPhysicalSystem());
+ }
+
+ @Override
public void completeImport_ImportURI(EObject model, Assignment assignment,
final ContentAssistContext context,
final ICompletionProposalAcceptor acceptor) {
ImportModelAssist.addPaths(this, context, acceptor, ".room");
ImportModelAssist.addPaths(this, context, acceptor, ".etphys");
}
-
+
}
diff --git a/plugins/org.eclipse.etrice.core.etphys.ui/src/org/eclipse/etrice/core/etphys/ui/contentassist/ETPhysProposalProvider.java b/plugins/org.eclipse.etrice.core.etphys.ui/src/org/eclipse/etrice/core/etphys/ui/contentassist/ETPhysProposalProvider.java
index d7596a05f..e40e0edcb 100644
--- a/plugins/org.eclipse.etrice.core.etphys.ui/src/org/eclipse/etrice/core/etphys/ui/contentassist/ETPhysProposalProvider.java
+++ b/plugins/org.eclipse.etrice.core.etphys.ui/src/org/eclipse/etrice/core/etphys/ui/contentassist/ETPhysProposalProvider.java
@@ -14,6 +14,7 @@ package org.eclipse.etrice.core.etphys.ui.contentassist;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.etrice.core.common.ui.contentassist.ImportModelAssist;
+import org.eclipse.etrice.core.etphys.eTPhys.ETPhysPackage;
import org.eclipse.xtext.Assignment;
import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext;
import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor;
@@ -22,6 +23,12 @@ 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 ETPhysProposalProvider extends AbstractETPhysProposalProvider {
+
+ @Override
+ public void completeImport_ImportedNamespace(EObject model, Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ lookupImportedNamespace(model, context, acceptor, ETPhysPackage.eINSTANCE.getNodeClass(), ETPhysPackage.eINSTANCE.getRuntimeClass());
+ }
@Override
public void completeImport_ImportURI(EObject model, Assignment assignment,
@@ -29,5 +36,5 @@ public class ETPhysProposalProvider extends AbstractETPhysProposalProvider {
final ICompletionProposalAcceptor acceptor) {
ImportModelAssist.addPaths(this, context, acceptor, ".etphys");
}
-
+
}
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/contentassist/RoomProposalProvider.java b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/contentassist/RoomProposalProvider.java
index 433722e3a..02058a6fb 100644
--- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/contentassist/RoomProposalProvider.java
+++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/contentassist/RoomProposalProvider.java
@@ -23,6 +23,7 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.etrice.core.common.base.AnnotationType;
+import org.eclipse.etrice.core.common.base.BasePackage;
import org.eclipse.etrice.core.common.ui.contentassist.ImportModelAssist;
import org.eclipse.etrice.core.fsm.fSM.DetailCode;
import org.eclipse.etrice.core.naming.RoomNameProvider;
@@ -35,6 +36,7 @@ import org.eclipse.etrice.core.room.DataClass;
import org.eclipse.etrice.core.room.Operation;
import org.eclipse.etrice.core.room.RefPath;
import org.eclipse.etrice.core.room.RoomAnnotationTargetEnum;
+import org.eclipse.etrice.core.room.RoomPackage;
import org.eclipse.etrice.core.room.StandardOperation;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.core.services.RoomGrammarAccess;
@@ -131,12 +133,18 @@ public class RoomProposalProvider extends AbstractRoomProposalProvider {
}
@Override
+ public void completeImport_ImportedNamespace(EObject model, Assignment assignment, ContentAssistContext context,
+ ICompletionProposalAcceptor acceptor) {
+ lookupImportedNamespace(model, context, acceptor, RoomPackage.eINSTANCE.getRoomClass(), BasePackage.eINSTANCE.getAnnotationType());
+ }
+
+ @Override
public void completeImport_ImportURI(EObject model, Assignment assignment,
final ContentAssistContext context,
final ICompletionProposalAcceptor acceptor) {
ImportModelAssist.addPaths(this, context, acceptor, ".room");
}
-
+
@Override
public void completeActorInstanceMapping_Path(EObject model,
Assignment assignment, ContentAssistContext context,

Back to the top