aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/language/src/main/java
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2023-11-06 01:04:02 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2023-11-17 12:41:34 +0100
commit57c9a71b6004b9fc0ed6cc3c87f4d62141fc6d62 (patch)
tree5972c4da810817e3edbf9acfd858260fb8dbcc39 /subprojects/language/src/main/java
parentfeat: predicates as reference types (diff)
downloadrefinery-57c9a71b6004b9fc0ed6cc3c87f4d62141fc6d62.tar.gz
refinery-57c9a71b6004b9fc0ed6cc3c87f4d62141fc6d62.tar.zst
refinery-57c9a71b6004b9fc0ed6cc3c87f4d62141fc6d62.zip
refactor(language): opposite content assist
Only show references that may plausibly appear in an opposite declaration.
Diffstat (limited to 'subprojects/language/src/main/java')
-rw-r--r--subprojects/language/src/main/java/tools/refinery/language/scoping/ProblemScopeProvider.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/subprojects/language/src/main/java/tools/refinery/language/scoping/ProblemScopeProvider.java b/subprojects/language/src/main/java/tools/refinery/language/scoping/ProblemScopeProvider.java
index cf099aba..a4437ba6 100644
--- a/subprojects/language/src/main/java/tools/refinery/language/scoping/ProblemScopeProvider.java
+++ b/subprojects/language/src/main/java/tools/refinery/language/scoping/ProblemScopeProvider.java
@@ -44,7 +44,7 @@ public class ProblemScopeProvider extends AbstractProblemScopeProvider {
44 return getVariableScope(context, scope); 44 return getVariableScope(context, scope);
45 } 45 }
46 if (reference == ProblemPackage.Literals.REFERENCE_DECLARATION__OPPOSITE) { 46 if (reference == ProblemPackage.Literals.REFERENCE_DECLARATION__OPPOSITE) {
47 return getOppositeScope(context, scope); 47 return getOppositeScope(context);
48 } 48 }
49 return scope; 49 return scope;
50 } 50 }
@@ -96,16 +96,19 @@ public class ProblemScopeProvider extends AbstractProblemScopeProvider {
96 } 96 }
97 } 97 }
98 98
99 protected IScope getOppositeScope(EObject context, IScope delegateScope) { 99 protected IScope getOppositeScope(EObject context) {
100 var referenceDeclaration = EcoreUtil2.getContainerOfType(context, ReferenceDeclaration.class); 100 var referenceDeclaration = EcoreUtil2.getContainerOfType(context, ReferenceDeclaration.class);
101 if (referenceDeclaration == null) { 101 if (referenceDeclaration == null) {
102 return delegateScope; 102 return IScope.NULLSCOPE;
103 } 103 }
104 var relation = referenceDeclaration.getReferenceType(); 104 var relation = referenceDeclaration.getReferenceType();
105 if (!(relation instanceof ClassDeclaration classDeclaration)) { 105 if (!(relation instanceof ClassDeclaration classDeclaration)) {
106 return delegateScope; 106 return IScope.NULLSCOPE;
107 } 107 }
108 var referenceDeclarations = desugarer.getAllReferenceDeclarations(classDeclaration); 108 var referenceDeclarations = classDeclaration.getFeatureDeclarations()
109 return Scopes.scopeFor(referenceDeclarations, delegateScope); 109 .stream()
110 .filter(ReferenceDeclaration.class::isInstance)
111 .toList();
112 return Scopes.scopeFor(referenceDeclarations);
110 } 113 }
111} 114}