diff options
Diffstat (limited to 'subprojects/language-ide/src/main/java')
-rw-r--r-- | subprojects/language-ide/src/main/java/tools/refinery/language/ide/contentassist/ProblemCrossrefProposalProvider.java | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/subprojects/language-ide/src/main/java/tools/refinery/language/ide/contentassist/ProblemCrossrefProposalProvider.java b/subprojects/language-ide/src/main/java/tools/refinery/language/ide/contentassist/ProblemCrossrefProposalProvider.java index 8c787dfd..27e936a1 100644 --- a/subprojects/language-ide/src/main/java/tools/refinery/language/ide/contentassist/ProblemCrossrefProposalProvider.java +++ b/subprojects/language-ide/src/main/java/tools/refinery/language/ide/contentassist/ProblemCrossrefProposalProvider.java | |||
@@ -11,6 +11,7 @@ import org.eclipse.emf.ecore.EObject; | |||
11 | import org.eclipse.emf.ecore.EReference; | 11 | import org.eclipse.emf.ecore.EReference; |
12 | import org.eclipse.emf.ecore.util.EcoreUtil; | 12 | import org.eclipse.emf.ecore.util.EcoreUtil; |
13 | import org.eclipse.xtext.CrossReference; | 13 | import org.eclipse.xtext.CrossReference; |
14 | import org.eclipse.xtext.EcoreUtil2; | ||
14 | import org.eclipse.xtext.GrammarUtil; | 15 | import org.eclipse.xtext.GrammarUtil; |
15 | import org.eclipse.xtext.ide.editor.contentassist.ContentAssistContext; | 16 | import org.eclipse.xtext.ide.editor.contentassist.ContentAssistContext; |
16 | import org.eclipse.xtext.ide.editor.contentassist.IdeCrossrefProposalProvider; | 17 | import org.eclipse.xtext.ide.editor.contentassist.IdeCrossrefProposalProvider; |
@@ -105,14 +106,45 @@ public class ProblemCrossrefProposalProvider extends IdeCrossrefProposalProvider | |||
105 | return true; | 106 | return true; |
106 | } | 107 | } |
107 | 108 | ||
109 | var candidateEObjectOrProxy = candidate.getEObjectOrProxy(); | ||
110 | |||
111 | if (eReference.equals(ProblemPackage.Literals.REFERENCE_DECLARATION__OPPOSITE) && | ||
112 | candidateEObjectOrProxy instanceof ReferenceDeclaration candidateReferenceDeclaration) { | ||
113 | return oppositeShouldBeVisible(candidateReferenceDeclaration, context); | ||
114 | } | ||
115 | |||
108 | var builtinSymbolsOption = desugarer.getBuiltinSymbols(context.getRootModel()); | 116 | var builtinSymbolsOption = desugarer.getBuiltinSymbols(context.getRootModel()); |
109 | if (builtinSymbolsOption.isEmpty()) { | 117 | if (builtinSymbolsOption.isEmpty()) { |
110 | return true; | 118 | return true; |
111 | } | 119 | } |
112 | var builtinSymbols = builtinSymbolsOption.get(); | 120 | var builtinSymbols = builtinSymbolsOption.get(); |
113 | 121 | ||
114 | var candidateEObjectOrProxy = candidate.getEObjectOrProxy(); | 122 | return builtinSymbolAwareShouldBeVisible(candidate, context, eReference, builtinSymbols, |
123 | candidateEObjectOrProxy); | ||
124 | } | ||
125 | |||
126 | private static boolean oppositeShouldBeVisible(ReferenceDeclaration candidateReferenceDeclaration, | ||
127 | ContentAssistContext context) { | ||
128 | var referenceDeclaration = EcoreUtil2.getContainerOfType(context.getCurrentModel(), | ||
129 | ReferenceDeclaration.class); | ||
130 | if (referenceDeclaration == null) { | ||
131 | return true; | ||
132 | } | ||
133 | var classDeclaration = EcoreUtil2.getContainerOfType(referenceDeclaration, ClassDeclaration.class); | ||
134 | if (classDeclaration == null) { | ||
135 | return true; | ||
136 | } | ||
137 | var oppositeType = candidateReferenceDeclaration.getReferenceType(); | ||
138 | if (oppositeType == null) { | ||
139 | return true; | ||
140 | } | ||
141 | var resolvedOppositeType = EcoreUtil.resolve(oppositeType, candidateReferenceDeclaration); | ||
142 | return classDeclaration.equals(resolvedOppositeType); | ||
143 | } | ||
115 | 144 | ||
145 | private boolean builtinSymbolAwareShouldBeVisible( | ||
146 | IEObjectDescription candidate, ContentAssistContext context, EReference eReference, | ||
147 | BuiltinSymbols builtinSymbols, EObject candidateEObjectOrProxy) { | ||
116 | if (eReference.equals(ProblemPackage.Literals.REFERENCE_DECLARATION__REFERENCE_TYPE) && | 148 | if (eReference.equals(ProblemPackage.Literals.REFERENCE_DECLARATION__REFERENCE_TYPE) && |
117 | context.getCurrentModel() instanceof ReferenceDeclaration referenceDeclaration && | 149 | context.getCurrentModel() instanceof ReferenceDeclaration referenceDeclaration && |
118 | (referenceDeclaration.getKind() == ReferenceKind.CONTAINMENT || | 150 | (referenceDeclaration.getKind() == ReferenceKind.CONTAINMENT || |