aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTamas Szabo2013-01-29 05:56:37 (EST)
committerIstvan Rath2013-01-29 05:56:37 (EST)
commit50502b59e387e17d6cef07445376b53f2fd0d0e3 (patch)
tree5d7d7aacaff60ddbc9c849df4844e7e807c9c0b3
parente200f4c973ef2b37eb183ad9677ba1e3ae135a54 (diff)
downloadorg.eclipse.incquery-50502b59e387e17d6cef07445376b53f2fd0d0e3.zip
org.eclipse.incquery-50502b59e387e17d6cef07445376b53f2fd0d0e3.tar.gz
org.eclipse.incquery-50502b59e387e17d6cef07445376b53f2fd0d0e3.tar.bz2
applied patch for [398635]
-rw-r--r--plugins/org.eclipse.incquery.patternlanguage.emf.ui/src/org/eclipse/incquery/patternlanguage/emf/ui/contentassist/ClassifierPrefixMatcher.java49
-rw-r--r--plugins/org.eclipse.incquery.patternlanguage.emf.ui/src/org/eclipse/incquery/patternlanguage/emf/ui/contentassist/EMFPatternLanguageProposalProvider.java53
-rw-r--r--plugins/org.eclipse.incquery.patternlanguage.emf.ui/src/org/eclipse/incquery/patternlanguage/emf/ui/contentassist/EnumPrefixMatcher.java44
3 files changed, 109 insertions, 37 deletions
diff --git a/plugins/org.eclipse.incquery.patternlanguage.emf.ui/src/org/eclipse/incquery/patternlanguage/emf/ui/contentassist/ClassifierPrefixMatcher.java b/plugins/org.eclipse.incquery.patternlanguage.emf.ui/src/org/eclipse/incquery/patternlanguage/emf/ui/contentassist/ClassifierPrefixMatcher.java
new file mode 100644
index 0000000..cacc3d0
--- /dev/null
+++ b/plugins/org.eclipse.incquery.patternlanguage.emf.ui/src/org/eclipse/incquery/patternlanguage/emf/ui/contentassist/ClassifierPrefixMatcher.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2012, Zoltan Ujhelyi, Istvan Rath and Daniel Varro
+ * 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:
+ * Zoltan Ujhelyi - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.incquery.patternlanguage.emf.ui.contentassist;
+
+import org.eclipse.xtext.naming.IQualifiedNameConverter;
+import org.eclipse.xtext.naming.QualifiedName;
+import org.eclipse.xtext.ui.editor.contentassist.PrefixMatcher;
+
+/**
+ * @author Zoltan Ujhelyi
+ *
+ */
+public class ClassifierPrefixMatcher extends PrefixMatcher {
+ private final PrefixMatcher delegate;
+
+ private final IQualifiedNameConverter qualifiedNameConverter;
+
+ public ClassifierPrefixMatcher(PrefixMatcher delegate, IQualifiedNameConverter qualifiedNameConverter) {
+ this.delegate = delegate;
+ this.qualifiedNameConverter = qualifiedNameConverter;
+ }
+
+ @Override
+ public boolean isCandidateMatchingPrefix(String name, String prefix) {
+ if (delegate.isCandidateMatchingPrefix(name, prefix))
+ return true;
+ QualifiedName qualifiedName = qualifiedNameConverter.toQualifiedName(name);
+ QualifiedName qualifiedPrefix = qualifiedNameConverter.toQualifiedName(prefix);
+ if (qualifiedName.getSegmentCount() > 1) {
+ if (qualifiedPrefix.getSegmentCount() == 1)
+ return delegate.isCandidateMatchingPrefix(qualifiedName.getSegment(1),
+ qualifiedPrefix.getFirstSegment());
+ if (!delegate.isCandidateMatchingPrefix(qualifiedName.getFirstSegment(),
+ qualifiedPrefix.getFirstSegment()))
+ return false;
+ return delegate.isCandidateMatchingPrefix(qualifiedName.getSegment(1), qualifiedPrefix.getSegment(1));
+ }
+ return false;
+ }
+
+}
diff --git a/plugins/org.eclipse.incquery.patternlanguage.emf.ui/src/org/eclipse/incquery/patternlanguage/emf/ui/contentassist/EMFPatternLanguageProposalProvider.java b/plugins/org.eclipse.incquery.patternlanguage.emf.ui/src/org/eclipse/incquery/patternlanguage/emf/ui/contentassist/EMFPatternLanguageProposalProvider.java
index a755c60..5f61027 100644
--- a/plugins/org.eclipse.incquery.patternlanguage.emf.ui/src/org/eclipse/incquery/patternlanguage/emf/ui/contentassist/EMFPatternLanguageProposalProvider.java
+++ b/plugins/org.eclipse.incquery.patternlanguage.emf.ui/src/org/eclipse/incquery/patternlanguage/emf/ui/contentassist/EMFPatternLanguageProposalProvider.java
@@ -38,7 +38,6 @@ import org.eclipse.xtext.Assignment;
import org.eclipse.xtext.EnumRule;
import org.eclipse.xtext.Keyword;
import org.eclipse.xtext.RuleCall;
-import org.eclipse.xtext.naming.IQualifiedNameConverter;
import org.eclipse.xtext.naming.QualifiedName;
import org.eclipse.xtext.nodemodel.ICompositeNode;
import org.eclipse.xtext.nodemodel.ILeafNode;
@@ -50,7 +49,6 @@ import org.eclipse.xtext.scoping.IScopeProvider;
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 org.eclipse.xtext.ui.editor.contentassist.PrefixMatcher;
import com.google.common.base.Function;
import com.google.common.base.Predicates;
@@ -69,36 +67,6 @@ public class EMFPatternLanguageProposalProvider extends AbstractEMFPatternLangua
@Inject
ReferenceProposalCreator crossReferenceProposalCreator;
- public static class ClassifierPrefixMatcher extends PrefixMatcher {
- private final PrefixMatcher delegate;
-
- private final IQualifiedNameConverter qualifiedNameConverter;
-
- public ClassifierPrefixMatcher(PrefixMatcher delegate, IQualifiedNameConverter qualifiedNameConverter) {
- this.delegate = delegate;
- this.qualifiedNameConverter = qualifiedNameConverter;
- }
-
- @Override
- public boolean isCandidateMatchingPrefix(String name, String prefix) {
- if (delegate.isCandidateMatchingPrefix(name, prefix))
- return true;
- QualifiedName qualifiedName = qualifiedNameConverter.toQualifiedName(name);
- QualifiedName qualifiedPrefix = qualifiedNameConverter.toQualifiedName(prefix);
- if (qualifiedName.getSegmentCount() > 1) {
- if (qualifiedPrefix.getSegmentCount() == 1)
- return delegate.isCandidateMatchingPrefix(qualifiedName.getSegment(1),
- qualifiedPrefix.getFirstSegment());
- if (!delegate.isCandidateMatchingPrefix(qualifiedName.getFirstSegment(),
- qualifiedPrefix.getFirstSegment()))
- return false;
- return delegate.isCandidateMatchingPrefix(qualifiedName.getSegment(1), qualifiedPrefix.getSegment(1));
- }
- return false;
- }
-
- }
-
/*
* (non-Javadoc)
*
@@ -106,7 +74,8 @@ public class EMFPatternLanguageProposalProvider extends AbstractEMFPatternLangua
* org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext,
* org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor)
*/
- @Override
+ @SuppressWarnings("restriction")
+ @Override
public void completeKeyword(Keyword keyword, ContentAssistContext contentAssistContext,
ICompletionProposalAcceptor acceptor) {
// ignore keywords in FILTERED set
@@ -128,9 +97,17 @@ public class EMFPatternLanguageProposalProvider extends AbstractEMFPatternLangua
if (typeClassifier instanceof EEnum) {
// In case of EEnums add Enum Literal constants
EEnum type = (EEnum) typeClassifier;
+
+ ContentAssistContext.Builder myContextBuilder = context.copy();
+ myContextBuilder.setMatcher(new EnumPrefixMatcher(type.getName()));
+
for (EEnumLiteral literal : type.getELiterals()) {
- acceptor.accept(createCompletionProposal("::" + literal.getName(), type.getName() + "::"
- + literal.getName(), null, context));
+ ICompletionProposal completionProposal =
+ createCompletionProposal("::" + literal.getName(),
+ type.getName() + "::" + literal.getName(),
+ null,
+ myContextBuilder.toContext());
+ acceptor.accept(completionProposal);
}
}
// XXX The following code re-specifies scoping instead of reusing the scope provider
@@ -193,7 +170,8 @@ public class EMFPatternLanguageProposalProvider extends AbstractEMFPatternLangua
}
}
- private void createClassifierProposals(PackageImport declaration, EObject model, ContentAssistContext context,
+ @SuppressWarnings("restriction")
+ private void createClassifierProposals(PackageImport declaration, EObject model, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {
// String alias = declaration.getAlias();
// QualifiedName prefix = (!Strings.isEmpty(alias))
@@ -230,7 +208,8 @@ public class EMFPatternLanguageProposalProvider extends AbstractEMFPatternLangua
return false;
}
- public void complete_RefType(PathExpressionElement model, RuleCall ruleCall, ContentAssistContext context,
+ @SuppressWarnings("restriction")
+ public void complete_RefType(PathExpressionElement model, RuleCall ruleCall, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {
IScope scope = scopeProvider.getScope(model.getTail(),
EMFPatternLanguagePackage.Literals.REFERENCE_TYPE__REFNAME);
diff --git a/plugins/org.eclipse.incquery.patternlanguage.emf.ui/src/org/eclipse/incquery/patternlanguage/emf/ui/contentassist/EnumPrefixMatcher.java b/plugins/org.eclipse.incquery.patternlanguage.emf.ui/src/org/eclipse/incquery/patternlanguage/emf/ui/contentassist/EnumPrefixMatcher.java
new file mode 100644
index 0000000..df144c2
--- /dev/null
+++ b/plugins/org.eclipse.incquery.patternlanguage.emf.ui/src/org/eclipse/incquery/patternlanguage/emf/ui/contentassist/EnumPrefixMatcher.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2012, Tamas Szabo, Istvan Rath and Daniel Varro
+ * 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:
+ * Tamas Szabo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.incquery.patternlanguage.emf.ui.contentassist;
+
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.xtext.ui.editor.contentassist.PrefixMatcher;
+
+/**
+ * A Prefix Matcher for {@link EEnum} types.
+ *
+ * @author Tamas Szabo
+ *
+ */
+public class EnumPrefixMatcher extends PrefixMatcher {
+
+ private String typeName;
+
+ public EnumPrefixMatcher(String typeName) {
+ this.typeName = typeName;
+ }
+
+ @Override
+ public boolean isCandidateMatchingPrefix(String name, String prefix) {
+ // candidate is matching the prefix if:
+ // (1) EEnum's type name starts with the prefix
+ // (2) the candidate name starts with the prefix
+ // The candidate name contains two ':' chars in the beginning, the written prefix may not
+
+ String fPrefix =
+ (prefix.length() >= 2 && prefix.charAt(0) != ':' && prefix.charAt(1) != ':') ?
+ "::"+prefix :
+ prefix
+ ;
+ return (typeName.startsWith(prefix) || name.startsWith(fPrefix));
+ }
+}