Author: scabanovich
Date: 2010-10-14 08:16:59 -0400 (Thu, 14 Oct 2010)
New Revision: 25822
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/DefaultJavaRelevanceCheck.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/IRelevanceCheck.java
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolver.java
Log:
JBIDE-7265
https://jira.jboss.org/browse/JBIDE-7265
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java 2010-10-14
11:51:09 UTC (rev 25821)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java 2010-10-14
12:16:59 UTC (rev 25822)
@@ -48,6 +48,7 @@
import org.jboss.tools.common.el.core.resolver.ELSegment;
import org.jboss.tools.common.el.core.resolver.ELSegmentImpl;
import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
+import org.jboss.tools.common.el.core.resolver.IRelevanceCheck;
import org.jboss.tools.common.el.core.resolver.IVariable;
import org.jboss.tools.common.el.core.resolver.JavaMemberELSegment;
import org.jboss.tools.common.el.core.resolver.JavaMemberELSegmentImpl;
@@ -115,6 +116,10 @@
return completions;
}
+ public IRelevanceCheck createRelevanceCheck(IJavaElement element) {
+ return new DefaultJavaRelevanceCheck(element);
+ }
+
/*
* (non-Javadoc)
* @see
org.jboss.tools.common.el.core.resolver.ELResolver#resolve(org.jboss.tools.common.el.core.resolver.ELContext,
org.jboss.tools.common.el.core.model.ELExpression)
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/DefaultJavaRelevanceCheck.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/DefaultJavaRelevanceCheck.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/DefaultJavaRelevanceCheck.java 2010-10-14
12:16:59 UTC (rev 25822)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.ca;
+
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMethod;
+import org.jboss.tools.common.el.core.resolver.IRelevanceCheck;
+
+public class DefaultJavaRelevanceCheck implements IRelevanceCheck {
+ String test1 = null;
+ String test2 = null;
+ String test3 = null;
+
+ public DefaultJavaRelevanceCheck(IJavaElement element) {
+ if(element == null) return;
+ test1 = element.getElementName();
+ if(element instanceof IMethod) {
+ if((test1.startsWith("get") || test1.startsWith("set")) &&
test1.length() > 3) { //$NON-NLS-1$ //$NON-NLS-2$
+ test2 = test1.substring(3, 4).toLowerCase() + test1.substring(4);
+ test3 = test1.substring(3);
+ } else if(test1.startsWith("is") && test1.length() > 2) {
//$NON-NLS-1$
+ test2 = test1.substring(2, 3).toLowerCase() + test1.substring(3);
+ test3 = test1.substring(2);
+ }
+ if(test3 != null && test3.equals(test2)) test3 = null;
+ }
+ }
+
+ public boolean isRelevant(String content) {
+ if(test1 != null && content.contains(test1)) return true;
+ if(test2 != null && content.contains(test2)) return true;
+ return false;
+ }
+
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/DefaultJavaRelevanceCheck.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolver.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolver.java 2010-10-14
11:51:09 UTC (rev 25821)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolver.java 2010-10-14
12:16:59 UTC (rev 25822)
@@ -12,6 +12,7 @@
import java.util.List;
+import org.eclipse.jdt.core.IJavaElement;
import org.jboss.tools.common.el.core.model.ELExpression;
import org.jboss.tools.common.el.core.parser.ELParserFactory;
import org.jboss.tools.common.text.TextProposal;
@@ -47,4 +48,13 @@
* @return EL parser factory
*/
ELParserFactory getParserFactory();
+
+ /**
+ * Creates object that will do fast check if resolution obtained from resolve method
+ * may include segments with this element
+ *
+ * @param element
+ * @return
+ */
+ IRelevanceCheck createRelevanceCheck(IJavaElement element);
}
\ No newline at end of file
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/IRelevanceCheck.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/IRelevanceCheck.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/IRelevanceCheck.java 2010-10-14
12:16:59 UTC (rev 25822)
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.resolver;
+
+public interface IRelevanceCheck {
+
+ public boolean isRelevant(String content);
+
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/IRelevanceCheck.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain