Author: vrubezhny
Date: 2011-05-05 12:30:01 -0400 (Thu, 05 May 2011)
New Revision: 31106
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFFuncsELCompletionEngine.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/ELCompletionEngine.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/ElVarSearcherTest.java
trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSF2CCAttrsELCompletionEngine.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFELCompletionEngine.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFImplicitObjectELResolver.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/JspELCompletionProposalComputer.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/JspTagCompletionProposalComputer.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamBeanHyperlinkPartitioner.java
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamComponentHyperlinkDetector.java
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamELInJavaStringHyperlinkDetector.java
Log:
JBIDE-5436
Code assist for JSF functions in EL.
Issue is fixed
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 2011-05-05
15:56:12 UTC (rev 31105)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Copyright (c) 2007-2011 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,
@@ -103,7 +103,7 @@
ELResolutionImpl resolution;
try {
- resolution = resolveELOperand(context.getResource(), parseOperand(el), false, vars,
new ElVarSearcher(context.getResource(), this));
+ resolution = resolveELOperand(context.getResource(), parseOperand(el), false, vars,
new ElVarSearcher(context.getResource(), this), offset);
if(resolution!=null) {
completions.addAll(resolution.getProposals());
}
@@ -132,7 +132,7 @@
}
ELResolutionImpl resolution = null;
try {
- resolution = resolveELOperand(context.getResource(), operand, true, vars, new
ElVarSearcher(context.getResource(), this));
+ resolution = resolveELOperand(context.getResource(), operand, true, vars, new
ElVarSearcher(context.getResource(), this), offset);
if(resolution != null)
resolution.setContext(context);
} catch (StringIndexOutOfBoundsException e) {
@@ -158,7 +158,7 @@
vars.add(array[i]);
}
try {
- return resolveELOperand(context.getResource(), operand, returnEqualedVariablesOnly,
vars, new ElVarSearcher(context.getResource(), this));
+ return resolveELOperand(context.getResource(), operand, returnEqualedVariablesOnly,
vars, new ElVarSearcher(context.getResource(), this), offset);
} catch (StringIndexOutOfBoundsException e) {
log(e);
} catch (BadLocationException e) {
@@ -201,7 +201,7 @@
*/
public ELResolutionImpl resolveELOperand(IFile file,
ELExpression operand, boolean returnEqualedVariablesOnly,
- List<Var> vars, ElVarSearcher varSearcher)
+ List<Var> vars, ElVarSearcher varSearcher, int offset)
throws BadLocationException, StringIndexOutOfBoundsException {
if(operand == null) {
//TODO
@@ -215,7 +215,7 @@
boolean isArray = false;
ELResolution varELResolution = null;
if(var!=null) {
- varELResolution = resolveEL(file, var.getElToken(), true);
+ varELResolution = resolveEL(file, var.getElToken(), true, offset);
if(varELResolution!=null && varELResolution.isResolved()) {
ELSegment segment = varELResolution.getLastSegment();
if(segment instanceof JavaMemberELSegment) {
@@ -254,7 +254,7 @@
: parseOperand(newEl))
: operand;
- ELResolutionImpl resolution = resolveELOperand(file, newOperand,
returnEqualedVariablesOnly, prefixWasChanged);
+ ELResolutionImpl resolution = resolveELOperand(file, newOperand,
returnEqualedVariablesOnly, prefixWasChanged, offset);
if(resolution==null) {
return null;
}
@@ -302,12 +302,12 @@
resolution.setSegments(resultSegments);
var.resolveValue("#{" + var.getElToken().getText() + suffix +
"}"); //$NON-NLS-1$ //$NON-NLS-2$
- ELResolutionImpl oldElResolution = resolveELOperand(file, operand,
returnEqualedVariablesOnly, false);
+ ELResolutionImpl oldElResolution = resolveELOperand(file, operand,
returnEqualedVariablesOnly, false, offset);
if(oldElResolution!=null) {
resolution.getProposals().addAll(oldElResolution.getProposals());
}
} else {
- resolution = resolveELOperand(file, operand, returnEqualedVariablesOnly, false);
+ resolution = resolveELOperand(file, operand, returnEqualedVariablesOnly, false,
offset);
}
}
@@ -321,7 +321,7 @@
for (Var v : vars) {
String prefix = operand.toString();
if(v.getName().startsWith(prefix)) {
- ELResolution r = resolveEL(file, v.getElToken(), true, vars, varSearcher);
+ ELResolution r = resolveEL(file, v.getElToken(), true, vars, varSearcher, offset);
if(r==null) {
continue;
}
@@ -375,27 +375,28 @@
* @throws BadLocationException
* @throws StringIndexOutOfBoundsException
*/
- public ELResolution resolveEL(IFile file, ELExpression operand, boolean varIsUsed)
throws BadLocationException, StringIndexOutOfBoundsException {
+ public ELResolution resolveEL(IFile file, ELExpression operand, boolean varIsUsed, int
offset) throws BadLocationException, StringIndexOutOfBoundsException {
if(!(operand instanceof ELInvocationExpression)) return null;
- return resolveELOperand(file, operand, true, varIsUsed);
+ return resolveELOperand(file, operand, true, varIsUsed, offset);
}
/**
* Returns ELResolution for EL.
- * @param seamProject
* @param file
* @param operand EL without #{}
+ * @param offset TODO
+ * @param seamProject
* @return ELResolution for EL.
* @throws BadLocationException
* @throws StringIndexOutOfBoundsException
*/
- public ELResolution resolveEL(IFile file, ELExpression operand, boolean
returnEqualedVariablesOnly, List<Var> vars, ElVarSearcher varSearcher) throws
BadLocationException, StringIndexOutOfBoundsException {
+ public ELResolution resolveEL(IFile file, ELExpression operand, boolean
returnEqualedVariablesOnly, List<Var> vars, ElVarSearcher varSearcher, int offset)
throws BadLocationException, StringIndexOutOfBoundsException {
if(!(operand instanceof ELInvocationExpression)) return null;
- return resolveELOperand(file, operand, returnEqualedVariablesOnly, vars, varSearcher);
+ return resolveELOperand(file, operand, returnEqualedVariablesOnly, vars, varSearcher,
offset);
}
public ELResolutionImpl resolveELOperand(IFile file, ELExpression operand,
- boolean returnEqualedVariablesOnly, boolean varIsUsed) throws BadLocationException,
StringIndexOutOfBoundsException {
+ boolean returnEqualedVariablesOnly, boolean varIsUsed, int offset) throws
BadLocationException, StringIndexOutOfBoundsException {
if(!(operand instanceof ELInvocationExpression) || file == null) {
return null;
}
@@ -414,18 +415,18 @@
if (expr.getLeft() != null && isArgument) {
left = expr.getLeft();
resolvedVariables = resolveVariables(file, left, false,
- true); // is Final and equal names are because of
+ true, offset); // is Final and equal names are because of
// we have no more to resolve the parts of expression,
// but we have to resolve arguments of probably a message component
} else if (expr.getLeft() == null && isIncomplete) {
resolvedVariables = resolveVariables(file, expr, true,
- returnEqualedVariablesOnly);
+ returnEqualedVariablesOnly, offset);
} else {
while(left != null) {
List<V>resolvedVars = new ArrayList<V>();
resolvedVars = resolveVariables(file,
left, left == expr,
- returnEqualedVariablesOnly);
+ returnEqualedVariablesOnly, offset);
if (resolvedVars != null && !resolvedVars.isEmpty()) {
resolvedVariables = resolvedVars;
resolution.setLastResolvedToken(left);
@@ -441,7 +442,7 @@
isIncomplete) {
// no vars are resolved
// the tokens are the part of var name ended with a separator (.)
- resolvedVariables = resolveVariables(file, expr, true,
returnEqualedVariablesOnly);
+ resolvedVariables = resolveVariables(file, expr, true, returnEqualedVariablesOnly,
offset);
Set<TextProposal> proposals = new
TreeSet<TextProposal>(TextProposal.KB_PROPOSAL_ORDER);
JavaMemberELSegmentImpl segment = new JavaMemberELSegmentImpl();
@@ -453,7 +454,7 @@
if(varName.startsWith(operand.getText())) {
// JBIDE-512, JBIDE-2541 related changes ===>>>
- MemberInfo member = getMemberInfoByVariable(var, true);
+ MemberInfo member = getMemberInfoByVariable(var, true, offset);
String sourceTypeName = member == null ? null :
member.getDeclaringTypeQualifiedName();
if (sourceTypeName != null && sourceTypeName.indexOf('.') != -1)
@@ -502,10 +503,10 @@
for (V var : resolvedVariables) {
if(isSingularAttribute(var)) {
- bijectedAttribute = getMemberInfoByVariable(var, true);
+ bijectedAttribute = getMemberInfoByVariable(var, true, offset);
}
- MemberInfo member = getMemberInfoByVariable(var, true);
+ MemberInfo member = getMemberInfoByVariable(var, true, offset);
String sourceTypeName = member == null ? null :
member.getDeclaringTypeQualifiedName();
if (sourceTypeName != null && sourceTypeName.indexOf('.') != -1)
sourceTypeName = Signature.getSimpleName(sourceTypeName);
@@ -556,7 +557,7 @@
JavaMemberELSegmentImpl segment = new JavaMemberELSegmentImpl();
segment.setToken(expr.getFirstToken());
for (V var : resolvedVariables) {
- TypeInfoCollector.MemberInfo member = getMemberInfoByVariable(var,
returnEqualedVariablesOnly);
+ TypeInfoCollector.MemberInfo member = getMemberInfoByVariable(var,
returnEqualedVariablesOnly, offset);
if (member != null && !members.contains(member)) {
members.add(member);
segment.setMemberInfo(member);
@@ -607,9 +608,9 @@
return resolution;
}
- abstract public List<V> resolveVariables(IFile file, ELInvocationExpression expr,
boolean isFinal, boolean onlyEqualNames);
+ abstract public List<V> resolveVariables(IFile file, ELInvocationExpression expr,
boolean isFinal, boolean onlyEqualNames, int offset);
- abstract protected TypeInfoCollector.MemberInfo getMemberInfoByVariable(V var, boolean
onlyEqualNames);
+ abstract protected TypeInfoCollector.MemberInfo getMemberInfoByVariable(V var, boolean
onlyEqualNames, int offset);
abstract protected boolean isStaticMethodsCollectingEnabled();
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELCompletionEngine.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELCompletionEngine.java 2011-05-05
15:56:12 UTC (rev 31105)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELCompletionEngine.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-2011 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,
@@ -19,5 +19,5 @@
public interface ELCompletionEngine extends ELResolver {
public ELResolution resolveELOperand(IFile file, ELExpression operand,
- boolean returnEqualedVariablesOnly, List<Var> vars, ElVarSearcher varSearcher)
throws BadLocationException, StringIndexOutOfBoundsException;
+ boolean returnEqualedVariablesOnly, List<Var> vars, ElVarSearcher varSearcher,
int offset) throws BadLocationException, StringIndexOutOfBoundsException;
}
\ No newline at end of file
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java 2011-05-05
15:56:12 UTC (rev 31105)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-2011 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,
@@ -308,7 +308,7 @@
if(resolvedToken==null && parentVar.getElToken()!=null) {
try {
// Initialize parent vars.
- engine.resolveELOperand(file, var.getElToken(), true, parentVars, this);
+ engine.resolveELOperand(file, var.getElToken(), true, parentVars, this,
(var.getRegion() == null ? 0 : var.getRegion().getOffset()));
resolvedToken = parentVar.getResolvedElToken();
} catch (StringIndexOutOfBoundsException e) {
ELCorePlugin.getPluginLog().logError(e);
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java 2011-05-05
15:56:12 UTC (rev 31105)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Copyright (c) 2007-2011 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,
@@ -35,6 +35,7 @@
import org.eclipse.jdt.core.Signature;
import org.jboss.tools.common.el.core.ELCorePlugin;
import org.jboss.tools.common.el.core.ca.preferences.ELContentAssistPreferences;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector.MemberInfo;
import org.jboss.tools.common.model.util.EclipseJavaUtil;
import org.jboss.tools.common.util.BeanUtil;
@@ -341,6 +342,77 @@
abstract public IJavaElement getJavaElement();
}
+ public static class ArtificialTypeInfo extends TypeInfo {
+ private IType fType;
+ private IMethod fMethod;
+ private String fMethodName;
+
+ public ArtificialTypeInfo (IType type, IMethod method, String methodName) throws
JavaModelException {
+ super(type, null, false);
+ this.fType = type;
+ this.fMethod = method;
+ this.fMethodName = methodName;
+ }
+
+ @Override
+ public IJavaElement getJavaElement() {
+ return fType;
+ }
+
+ @Override
+ public TypeInfoCollector getTypeCollector(boolean varIsUsed,
+ boolean includeStaticMethods) {
+ return new TypeInfoCollector(this, varIsUsed, true) {
+
+ @Override
+ public List<MemberInfo> getMethods() {
+ // Do not filter the static methods here, just return all the artificial methods
+ List<MemberInfo> methods = new ArrayList<MemberInfo>();
+ methods.addAll(fMethods);
+ return methods;
+ }
+
+ @Override
+ public List<MemberInfo> getProperties() {
+ // No properties are allowed here, just return an empty list here
+ return new ArrayList<MemberInfo>();
+ }
+
+ @Override
+ public void collectInfo(boolean var) {
+ if (fMethods == null) {
+ fMethods = new ArrayList<MethodInfo>();
+ } else {
+ fMethods.clear();
+ }
+
+ if (fFields == null) {
+ fFields = new ArrayList<FieldInfo>();
+ } else {
+ fFields.clear();
+ }
+
+ if (fType == null) {
+ return;
+ }
+ try {
+ IType binType = fType;
+ if(fMember instanceof TypeInfo) {
+ fTypeInfo = (TypeInfo)fMember;
+ } else {
+ fTypeInfo = new TypeInfo(binType, fMember, fMember.isDataModel());
+ }
+ TypeInfo parent = fTypeInfo;
+ MethodInfo info = new MethodInfo(fMethod, fMethodName, fTypeInfo, parent, false);
+ fMethods.add(info);
+ } catch (JavaModelException e) {
+ ELCorePlugin.getPluginLog().logError(e);
+ }
+ }
+ };
+ }
+ }
+
public static class TypeInfo extends MemberInfo {
private IType fType;
private TypeInfo superType;
@@ -529,6 +601,23 @@
setParameterNames(parameterNames);
}
+ public MethodInfo(IMethod method, String name, TypeInfo parentMember, TypeInfo
declaratedType, boolean dataModel) throws JavaModelException {
+ super(method.getDeclaringType(),
+ (method.getDeclaringType() == null ? null :
method.getDeclaringType().getFullyQualifiedName()),
+ name,
+ method.getFlags(),
+ parentMember,
+ declaratedType,
+ dataModel,
+ new Type(method.getReturnType(),
+ method.getDeclaringType()));
+ fJavaElement = method;
+ setParameterNames(method.getParameterNames());
+ setParameterTypeNames(resolveSignatures(method.getDeclaringType(),
method.getParameterTypes()));
+ setParametersNamesOfDeclaringType(getTypeErasureFromSignatureArray(method.getDeclaringType().getTypeParameterSignatures()));
+ }
+
+
public MethodInfo(IMethod method, TypeInfo parentMember, TypeInfo declaratedType,
boolean dataModel) throws JavaModelException {
super(method.getDeclaringType(),
(method.getDeclaringType() == null ? null :
method.getDeclaringType().getFullyQualifiedName()),
@@ -867,7 +956,7 @@
false));
}
- private static IType getSuperclass(IType type) throws JavaModelException {
+ public static IType getSuperclass(IType type) throws JavaModelException {
String superclassName = type.getSuperclassName();
if(superclassName!=null) {
String fullySuperclassName = EclipseJavaUtil.resolveType(type, superclassName);
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/ElVarSearcherTest.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/ElVarSearcherTest.java 2011-05-05
15:56:12 UTC (rev 31105)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/ElVarSearcherTest.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -44,7 +44,7 @@
private static class FakeELCompletionEngine implements ELCompletionEngine {
public ELResolution resolveELOperand(IFile file,
ELExpression operand, boolean returnEqualedVariablesOnly,
- List<Var> vars, ElVarSearcher varSearcher)
+ List<Var> vars, ElVarSearcher varSearcher, int offset)
throws BadLocationException, StringIndexOutOfBoundsException {
return new ELResolutionImpl(operand);
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml 2011-05-05 15:56:12 UTC (rev 31105)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml 2011-05-05 16:30:01 UTC (rev 31106)
@@ -473,6 +473,13 @@
resolver-class="org.jboss.tools.jsf.model.JSF2CCAttrsELCompletionEngine"/>
</el-resolver>
</extension>
+ <extension
+ point="org.jboss.tools.common.el.core.elResolver">
+ <el-resolver id="jsfFuncsELResolver">
+ <project-nature id="org.jboss.tools.jsf.jsfnature"
+
resolver-class="org.jboss.tools.jsf.model.JSFFuncsELCompletionEngine"/>
+ </el-resolver>
+ </extension>
<extension
point="org.jboss.tools.jst.web.kb.elValidationDelegate">
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSF2CCAttrsELCompletionEngine.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSF2CCAttrsELCompletionEngine.java 2011-05-05
15:56:12 UTC (rev 31105)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSF2CCAttrsELCompletionEngine.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-2011 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,
@@ -123,7 +123,7 @@
public ELResolution resolve(ELContext context, ELExpression operand, int offset) {
if(context instanceof IXmlContext) {
if(((IXmlContext)context).getURIs().contains(COMPOSITE_URI)) {
- ELResolutionImpl resolution = resolveELOperand(operand, context, true);
+ ELResolutionImpl resolution = resolveELOperand(operand, context, true, offset);
if(resolution != null)
resolution.setContext(context);
return resolution;
@@ -133,9 +133,9 @@
}
public ELResolutionImpl resolveELOperand(ELExpression operand,
- ELContext context, boolean returnEqualedVariablesOnly) {
+ ELContext context, boolean returnEqualedVariablesOnly, int offset) {
try {
- return resolveELOperand(context.getResource(), operand, returnEqualedVariablesOnly);
+ return resolveELOperand(context.getResource(), operand, returnEqualedVariablesOnly,
offset);
} catch (StringIndexOutOfBoundsException e) {
log(e);
} catch (BadLocationException e) {
@@ -148,7 +148,7 @@
int position, boolean returnEqualedVariablesOnly) throws BadLocationException,
StringIndexOutOfBoundsException {
List<TextProposal> completions = new ArrayList<TextProposal>();
- ELResolutionImpl status = resolveELOperand(file, parseOperand("" + prefix),
returnEqualedVariablesOnly); //$NON-NLS-1$
+ ELResolutionImpl status = resolveELOperand(file, parseOperand("" + prefix),
returnEqualedVariablesOnly, position); //$NON-NLS-1$
if(status!=null) {
completions.addAll(status.getProposals());
}
@@ -157,7 +157,7 @@
}
public ELResolutionImpl resolveELOperand(IFile file,
- ELExpression operand, boolean returnEqualedVariablesOnly)
+ ELExpression operand, boolean returnEqualedVariablesOnly, int offset)
throws BadLocationException, StringIndexOutOfBoundsException {
if(!(operand instanceof ELInvocationExpression) || file == null) {
return null;
@@ -273,7 +273,7 @@
}
if(!resolvedVariables.isEmpty() && resolvedVariables.iterator().next()
instanceof IJSFVariable) {
- return buildJavaResolution(resolution, left, expr, operand, resolvedVariables,
returnEqualedVariablesOnly);
+ return buildJavaResolution(resolution, left, expr, operand, resolvedVariables,
returnEqualedVariablesOnly, offset);
}
//process segments one by one
@@ -303,14 +303,14 @@
//Method content copies code from the end AbstractELCompletionEngine.resolveELOperand
ELResolutionImpl buildJavaResolution(ELResolutionImpl resolution, ELInvocationExpression
left, ELInvocationExpression expr,
- ELExpression operand, List<IVariable> resolvedVariables, boolean
returnEqualedVariablesOnly) {
+ ELExpression operand, List<IVariable> resolvedVariables, boolean
returnEqualedVariablesOnly, int offset) {
boolean varIsUsed = false;
// First segment is found - proceed with next tokens
List<TypeInfoCollector.MemberInfo> members = new
ArrayList<TypeInfoCollector.MemberInfo>();
JavaMemberELSegmentImpl segment = new JavaMemberELSegmentImpl();
segment.setToken(expr.getFirstToken());
for (IVariable var : resolvedVariables) {
- TypeInfoCollector.MemberInfo member = getMemberInfoByVariable(var,
returnEqualedVariablesOnly);
+ TypeInfoCollector.MemberInfo member = getMemberInfoByVariable(var,
returnEqualedVariablesOnly, offset);
if (member != null && !members.contains(member)) {
members.add(member);
segment.setMemberInfo(member);
@@ -625,7 +625,7 @@
*/
@Override
protected MemberInfo getMemberInfoByVariable(IVariable var,
- boolean onlyEqualNames) {
+ boolean onlyEqualNames, int offset) {
if(var instanceof IJSFVariable) {
return TypeInfoCollector.createMemberInfo(((IJSFVariable)var).getSourceMember());
}
@@ -638,7 +638,7 @@
*/
@Override
public List<IVariable> resolveVariables(IFile file,
- ELInvocationExpression expr, boolean isFinal, boolean onlyEqualNames) {
+ ELInvocationExpression expr, boolean isFinal, boolean onlyEqualNames, int offset) {
return resolveVariablesInternal(file, expr, isFinal, onlyEqualNames);
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFELCompletionEngine.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFELCompletionEngine.java 2011-05-05
15:56:12 UTC (rev 31105)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFELCompletionEngine.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-2011 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,
@@ -71,10 +71,10 @@
* (non-Javadoc)
* @see
org.jboss.tools.jst.web.kb.el.AbstractELCompletionEngine#resolveVariables(org.eclipse.core.resources.IFile,
org.jboss.tools.common.el.core.model.ELInvocationExpression, boolean, boolean)
*/
- public List<IJSFVariable> resolveVariables(IFile file, ELInvocationExpression
expr, boolean isFinal, boolean onlyEqualNames) {
+ public List<IJSFVariable> resolveVariables(IFile file, ELInvocationExpression
expr, boolean isFinal, boolean onlyEqualNames, int offset) {
IModelNature project = EclipseResourceUtil.getModelNature(file.getProject());
- return resolveVariables(file, project, expr, isFinal, onlyEqualNames);
+ return resolveVariables(file, project, expr, isFinal, onlyEqualNames, offset);
}
/**
@@ -85,7 +85,7 @@
* @param onlyEqualNames
* @return
*/
- public List<IJSFVariable> resolveVariables(IFile file, IModelNature project,
ELInvocationExpression expr, boolean isFinal, boolean onlyEqualNames) {
+ public List<IJSFVariable> resolveVariables(IFile file, IModelNature project,
ELInvocationExpression expr, boolean isFinal, boolean onlyEqualNames, int offset) {
List<IJSFVariable>resolvedVars = new ArrayList<IJSFVariable>();
if (project == null)
@@ -94,7 +94,7 @@
String varName = expr.toString();
if (varName != null) {
- resolvedVars = resolveVariables(project, varName, onlyEqualNames);
+ resolvedVars = resolveVariables(project, varName, onlyEqualNames, offset);
}
if (resolvedVars != null && !resolvedVars.isEmpty()) {
List<IJSFVariable> newResolvedVars = new ArrayList<IJSFVariable>();
@@ -132,7 +132,7 @@
return new ArrayList<IJSFVariable>();
}
- protected List<IJSFVariable> resolveVariables(IModelNature project, String
varName, boolean onlyEqualNames) {
+ protected List<IJSFVariable> resolveVariables(IModelNature project, String
varName, boolean onlyEqualNames, int offset) {
if(project == null) return null;
List<IJSFVariable> beans = new
JSFPromptingProvider().getVariables(project.getModel());
List<IJSFVariable> resolvedVariables = new ArrayList<IJSFVariable>();
@@ -155,7 +155,7 @@
* (non-Javadoc)
* @see
org.jboss.tools.jst.web.kb.el.AbstractELCompletionEngine#getMemberInfoByVariable(org.jboss.tools.jst.web.kb.el.AbstractELCompletionEngine.IVariable,
boolean)
*/
- protected TypeInfoCollector.MemberInfo getMemberInfoByVariable(IJSFVariable var, boolean
onlyEqualNames) {
+ protected TypeInfoCollector.MemberInfo getMemberInfoByVariable(IJSFVariable var, boolean
onlyEqualNames, int offset) {
return TypeInfoCollector.createMemberInfo(((IJSFVariable)var).getSourceMember());
}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFFuncsELCompletionEngine.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFFuncsELCompletionEngine.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFFuncsELCompletionEngine.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -0,0 +1,259 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.model;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jdt.core.Flags;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.Signature;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.el.core.ELCorePlugin;
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
+import org.jboss.tools.common.el.core.resolver.ELContext;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector.ArtificialTypeInfo;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jsf.JSFModelPlugin;
+import org.jboss.tools.jst.web.kb.PageContextFactory;
+import org.jboss.tools.jst.web.kb.internal.XmlContextImpl;
+import org.jboss.tools.jst.web.kb.taglib.IELFunction;
+import org.jboss.tools.jst.web.kb.taglib.IFunctionLibrary;
+import org.jboss.tools.jst.web.kb.taglib.INameSpace;
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
+import org.jboss.tools.jst.web.kb.taglib.TagLibraryManager;
+
+public class JSFFuncsELCompletionEngine extends JSFELCompletionEngine {
+ private static final Image JSF_EL_PROPOSAL_IMAGE =
JSFModelPlugin.getDefault().getImage(JSFModelPlugin.CA_JSF_EL_IMAGE_PATH);
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.common.el.core.ca.AbstractELCompletionEngine#getELProposalImage()
+ */
+ public Image getELProposalImage() {
+ return JSF_EL_PROPOSAL_IMAGE;
+ }
+
+ public JSFFuncsELCompletionEngine() {}
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.jst.web.kb.el.AbstractELCompletionEngine#getMemberInfoByVariable(org.jboss.tools.jst.web.kb.el.AbstractELCompletionEngine.IVariable,
boolean)
+ */
+ protected TypeInfoCollector.MemberInfo getMemberInfoByVariable(IJSFVariable var, boolean
onlyEqualNames, int offset) {
+ // Need to create artificial member info based on the Source Member type, but having
only method named after the func's name
+ if (!(var instanceof Variable))
+ return null;
+
+ Variable variable = (Variable)var;
+ IType sourceMember = (IType)variable.getSourceMember();
+
+ if (variable.funcResolvedMethod == null)
+ return null;
+
+ TypeInfoCollector.MemberInfo result = null;
+
+ try {
+ result = new ArtificialTypeInfo(sourceMember,
+ variable.funcResolvedMethod,
+ variable.funcName);
+ } catch (JavaModelException e) {
+ ELCorePlugin.getPluginLog().logError(e);
+ }
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.common.el.core.ca.AbstractELCompletionEngine#resolveVariables(org.eclipse.core.resources.IFile,
org.jboss.tools.common.el.core.model.ELInvocationExpression, boolean, boolean)
+ */
+ @Override
+ public List<IJSFVariable> resolveVariables(IFile file,
+ ELInvocationExpression expr, boolean isFinal, boolean onlyEqualNames, int offset) {
+ return resolveVariablesInternal(file, expr, isFinal, onlyEqualNames, offset);
+ }
+
+ public List<IJSFVariable> resolveVariablesInternal(IFile file,
ELInvocationExpression expr, boolean isFinal, boolean onlyEqualNames, int offset) {
+ ELContext context = PageContextFactory.createPageContext(file);
+
+ if (!(context instanceof XmlContextImpl)) {
+ return null;
+ }
+
+ ITagLibrary[] libraries = TagLibraryManager.getLibraries(file.getProject());
+ if (libraries == null)
+ return null;
+
+ List<IJSFVariable> result = new ArrayList<IJSFVariable>();
+
+
+ String varName = expr.toString();
+
+ // AbstractELCompletionEngine sets up a current offset in beginning of each ELResolver
method (if it has appropriate parameter)
+ // but if resolve variables is called (because it is public) from somewhere outside,
then we'll use all the namespaces we could find
+ Map<String, List<INameSpace>> namespacesByOffset =
((XmlContextImpl)context).getNameSpaces(offset);
+
+ for (ITagLibrary l : libraries) {
+ if (l instanceof IFunctionLibrary) {
+ String uri = l.getURI();
+ Collection<INameSpace> namespaces = namespacesByOffset.get(uri);
+ if (namespaces != null) {
+ for (INameSpace ns : namespaces) {
+ String name = ns.getPrefix();
+ if(!isFinal || onlyEqualNames) {
+ if(!name.equals(varName)) continue;
+ }
+ if(!name.startsWith(varName)) continue;
+ if(varName.lastIndexOf('.') > name.length()) continue; //It is the java
variable case
+ IELFunction[] functions = ((IFunctionLibrary)l).getFunctions();
+ if (functions == null) continue;
+ for (IELFunction f : functions) {
+ String funcClass = f.getFunctionClass();
+ String funcSignature = f.getFunctionSignature();
+ String funcName = f.getName();
+ Variable v = new Variable(name, file,funcName, funcClass, funcSignature);
+ result.add(v);
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ protected void setImage(TextProposal kbProposal) {
+ kbProposal.setImage(getELProposalImage());
+ }
+
+ static class Variable implements IJSFVariable {
+ IFile f;
+ String name;
+ String funcName;
+ String funcClass;
+ String funcSignature;
+ IMethod funcResolvedMethod;
+ IType funcSourceMember;
+
+ public Variable(String name, IFile f, String funcName, String funcClass, String
funcSignature) {
+ this.name = name;
+ this.f = f;
+ this.funcName = funcName;
+ this.funcClass = funcClass;
+ this.funcSignature = funcSignature;
+ this.funcResolvedMethod = null;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Collection<String> getKeys() {
+ List<String> result = new ArrayList<String>();
+
+ if (funcResolvedMethod != null)
+ return result;
+
+ if (f == null || f.getProject() == null)
+ return result;
+
+ funcSourceMember = EclipseResourceUtil.getValidType(f.getProject(), funcClass);
+ if (funcSourceMember == null)
+ return result;
+
+
+ IType currentType = funcSourceMember;
+ try {
+ while (currentType != null) {
+ IMethod[] binMethods = currentType.getMethods();
+ if (binMethods != null) {
+ for (IMethod method : binMethods) {
+ if (method.isConstructor() || (method.getFlags() & Flags.AccStatic) == 0) {
+ continue;
+ }
+
+ String methodName = method.getElementName();
+ String methodReturnType = method.getReturnType();
+ String methodReturnTypeSimple = methodReturnType;
+ if (Signature.getTypeSignatureKind(methodReturnType) ==
Signature.BASE_TYPE_SIGNATURE) {
+ methodReturnType = Signature.toString(methodReturnType);
+ methodReturnTypeSimple = methodReturnType;
+ } else {
+ methodReturnType = EclipseJavaUtil.resolveTypeAsString(currentType,
methodReturnType);
+ methodReturnTypeSimple = Signature.getSimpleName(methodReturnType);
+ }
+
+ String[] methodParamTypes = method.getParameterTypes();
+ int paramTypesCount = methodParamTypes == null ? 0 : methodParamTypes.length;
+ int startParamIndex = funcSignature.indexOf('(');
+ int endParamIndex = funcSignature.indexOf(')');
+ if (startParamIndex == -1 || endParamIndex == -1 || startParamIndex >
endParamIndex)
+ continue;
+ String paramsString = funcSignature.substring(startParamIndex + 1, endParamIndex);
+ String[] params = paramsString.split(",");
+ if (!(funcSignature.substring(0, startParamIndex).contains(methodReturnType) ||
funcSignature.substring(0, startParamIndex).contains(methodReturnTypeSimple)))
+ continue;
+ if (!funcSignature.substring(0, startParamIndex).contains(methodName))
+ continue;
+ int paramsCount = params == null ? 0 : params.length;
+ if (paramTypesCount != paramsCount)
+ continue;
+ boolean paramsAreEqual = true;
+ for (int i = 0; methodParamTypes != null && i < methodParamTypes.length;
i++) {
+ String methodParamType = methodParamTypes[i];
+ String methodParamTypeSimple = methodParamType;
+ if (Signature.getTypeSignatureKind(methodParamType) ==
Signature.BASE_TYPE_SIGNATURE) {
+ methodParamType = Signature.toString(methodParamType);
+ methodReturnTypeSimple = methodParamType;
+ } else {
+ methodParamType = EclipseJavaUtil.resolveTypeAsString(currentType,
methodParamType);
+ methodParamTypeSimple = Signature.getSimpleName(methodParamType);
+ }
+
+ if (params[i] == null || (!params[i].trim().equals(methodParamType) &&
!params[i].trim().equals(methodParamTypeSimple))) {
+ paramsAreEqual = false;
+ break;
+ }
+ }
+
+ if (!paramsAreEqual)
+ continue;
+
+ funcResolvedMethod = method;
+ result.add(funcName);
+ break;
+ }
+ }
+ currentType = TypeInfoCollector.getSuperclass(currentType);
+ }
+ } catch (JavaModelException e) {
+ JSFModelPlugin.log("An error occurred while retrieving methods for type
'" + funcClass + "'", e);
+ }
+
+ return result;
+ }
+
+ public IMember getSourceMember() {
+ getKeys(); // Initialize source member
+ return funcSourceMember;
+ }
+ }
+}
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFFuncsELCompletionEngine.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFImplicitObjectELResolver.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFImplicitObjectELResolver.java 2011-05-05
15:56:12 UTC (rev 31105)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFImplicitObjectELResolver.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
+ * Copyright (c) 2009-2011 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,
@@ -65,17 +65,17 @@
* (non-Javadoc)
* @see
org.jboss.tools.jst.web.kb.el.AbstractELCompletionEngine#resolveVariables(org.eclipse.core.resources.IFile,
org.jboss.tools.common.el.core.model.ELInvocationExpression, boolean, boolean)
*/
- public List<IJSFVariable> resolveVariables(IFile file, ELInvocationExpression
expr, boolean isFinal, boolean onlyEqualNames) {
+ public List<IJSFVariable> resolveVariables(IFile file, ELInvocationExpression
expr, boolean isFinal, boolean onlyEqualNames, int offset) {
this.file = file;
- return super.resolveVariables(file, expr, isFinal, onlyEqualNames);
+ return super.resolveVariables(file, expr, isFinal, onlyEqualNames, offset);
}
/*
* (non-Javadoc)
- * @see
org.jboss.tools.jsf.model.JSFELCompletionEngine#resolveVariables(org.jboss.tools.common.model.project.IModelNature,
java.lang.String, boolean)
+ * @see
org.jboss.tools.jsf.model.JSFELCompletionEngine#resolveVariables(org.jboss.tools.common.model.project.IModelNature,
java.lang.String, boolean, int)
*/
@Override
- protected List<IJSFVariable> resolveVariables(IModelNature project, String
varName, boolean onlyEqualNames) {
+ protected List<IJSFVariable> resolveVariables(IModelNature project, String
varName, boolean onlyEqualNames, int offset) {
if(file.getProject() == null) {
return null;
}
@@ -103,7 +103,7 @@
for (String var : elVars) {
try {
- ELResolution resolution = resolveEL(file, IMPLICT_OBJECTS_ELS.get(var), false);
+ ELResolution resolution = resolveEL(file, IMPLICT_OBJECTS_ELS.get(var), false,
offset);
if(resolution!=null && resolution.isResolved()) {
ELSegment segment = resolution.getLastSegment();
if(segment instanceof JavaMemberELSegment) {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java 2011-05-05
15:56:12 UTC (rev 31105)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -643,7 +643,7 @@
*/
@Override
protected MemberInfo getMemberInfoByVariable(IVariable var,
- boolean onlyEqualNames) {
+ boolean onlyEqualNames, int offset) {
return null;
}
@@ -653,7 +653,7 @@
*/
@Override
public List<IVariable> resolveVariables(IFile file,
- ELInvocationExpression expr, boolean isFinal, boolean onlyEqualNames) {
+ ELInvocationExpression expr, boolean isFinal, boolean onlyEqualNames, int offset) {
return null;
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2011-05-05
15:56:12 UTC (rev 31105)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
+ * Copyright (c) 2009-2011 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,
@@ -232,7 +232,7 @@
public ELResolution resolveELOperand(IFile file,
ELExpression operand, boolean returnEqualedVariablesOnly,
- List<Var> vars, ElVarSearcher varSearcher)
+ List<Var> vars, ElVarSearcher varSearcher, int offset)
throws BadLocationException, StringIndexOutOfBoundsException {
return new ELResolutionImpl(operand);
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/JspELCompletionProposalComputer.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/JspELCompletionProposalComputer.java 2011-05-05
15:56:12 UTC (rev 31105)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/JspELCompletionProposalComputer.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2010 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2010-2011 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.jsp.contentassist.computers;
@@ -102,7 +102,7 @@
public ELResolution resolveELOperand(IFile file,
ELExpression operand, boolean returnEqualedVariablesOnly,
- List<Var> vars, ElVarSearcher varSearcher)
+ List<Var> vars, ElVarSearcher varSearcher, int offset)
throws BadLocationException, StringIndexOutOfBoundsException {
return new ELResolutionImpl(operand);
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/JspTagCompletionProposalComputer.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/JspTagCompletionProposalComputer.java 2011-05-05
15:56:12 UTC (rev 31105)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/JspTagCompletionProposalComputer.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2010 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2010-2011 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.jsp.contentassist.computers;
@@ -126,7 +126,7 @@
public ELResolution resolveELOperand(IFile file,
ELExpression operand, boolean returnEqualedVariablesOnly,
- List<Var> vars, ElVarSearcher varSearcher)
+ List<Var> vars, ElVarSearcher varSearcher, int offset)
throws BadLocationException, StringIndexOutOfBoundsException {
return new ELResolutionImpl(operand);
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2011-05-05
15:56:12 UTC (rev 31105)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-2011 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,
@@ -148,14 +148,14 @@
}
@Override
- public List<ISeamContextVariable> resolveVariables(IFile file,
ELInvocationExpression expr, boolean isFinal, boolean onlyEqualNames) {
+ public List<ISeamContextVariable> resolveVariables(IFile file,
ELInvocationExpression expr, boolean isFinal, boolean onlyEqualNames, int offset) {
ISeamProject project = SeamCorePlugin.getSeamProject(file.getProject(), true);
// ScopeType scope = getScope(project, file);
return resolveVariables(project, file, expr, isFinal, onlyEqualNames);
}
- protected TypeInfoCollector.MemberInfo getMemberInfoByVariable(ISeamContextVariable var,
boolean onlyEqualNames) {
- return SeamExpressionResolver.getMemberInfoByVariable(var, true, this);
+ protected TypeInfoCollector.MemberInfo getMemberInfoByVariable(ISeamContextVariable var,
boolean onlyEqualNames, int offset) {
+ return SeamExpressionResolver.getMemberInfoByVariable(var, true, this, offset);
}
protected void setImage(TextProposal proposal, ISeamContextVariable var) {
@@ -305,11 +305,12 @@
* Create the array of suggestions from expression.
* @param project Seam project
* @param file File
+ * @param offset TODO
* @param document
* @param prefix the prefix to search for
* @param position Offset of the prefix
*/
- public List<IJavaElement> getJavaElementsForExpression(ISeamProject project, IFile
file, String expression) throws BadLocationException, StringIndexOutOfBoundsException {
+ public List<IJavaElement> getJavaElementsForExpression(ISeamProject project, IFile
file, String expression, int offset) throws BadLocationException,
StringIndexOutOfBoundsException {
ELExpression expr = parseOperand(expression);
if(!(expr instanceof ELInvocationExpression)) {
return new ArrayList<IJavaElement>();
@@ -333,7 +334,7 @@
ElVarSearcher varSearcher = new ElVarSearcher(file, this);
List<Var> vars = varSearcher.findAllVars(file, expr.getStartPosition());
- ELResolution resolution = resolveELOperand(file, expr, true, vars, varSearcher);
+ ELResolution resolution = resolveELOperand(file, expr, true, vars, varSearcher, 0);
if (resolution!=null && resolution.isResolved()) {
ELSegment segment = resolution.getLastSegment();
if(segment instanceof JavaMemberELSegment) {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java 2011-05-05
15:56:12 UTC (rev 31105)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2007-2011 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,
@@ -51,10 +51,8 @@
import org.jboss.tools.seam.core.ISeamMessages;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamXmlFactory;
-import org.jboss.tools.seam.core.ScopeType;
import org.jboss.tools.seam.core.SeamComponentMethodType;
import org.jboss.tools.seam.core.SeamCorePlugin;
-import org.jboss.tools.seam.internal.core.SeamJavaComponentDeclaration;
/**
* Utility class used to resolve Seam project variables and to get the methods/properties
and their presentation strings from type
@@ -263,10 +261,10 @@
* @param variable
* @return
*/
- public static TypeInfoCollector.MemberInfo getMemberInfoByVariable(ISeamContextVariable
variable, boolean onlyEqualNames, SeamELCompletionEngine engine) {
+ public static TypeInfoCollector.MemberInfo getMemberInfoByVariable(ISeamContextVariable
variable, boolean onlyEqualNames, SeamELCompletionEngine engine, int offset) {
TypeInfoCollector.MemberInfo member = null;
if(variable instanceof ISeamContextShortVariable) {
- return getMemberInfoByVariable(((ISeamContextShortVariable)variable).getOriginal(),
onlyEqualNames, engine);
+ return getMemberInfoByVariable(((ISeamContextShortVariable)variable).getOriginal(),
onlyEqualNames, engine, offset);
}
if(variable instanceof ISeamMessages) {
MemberInfo info = null;;
@@ -343,7 +341,7 @@
List<ISeamContextVariable> resolvedValues = resolveVariables(project, null /*
factory.getScope()*/, value, onlyEqualNames);
for (ISeamContextVariable var : resolvedValues) {
if (var.getName().equals(value)) {
- member = getMemberInfoByVariable(var, onlyEqualNames, engine);
+ member = getMemberInfoByVariable(var, onlyEqualNames, engine, offset);
break;
}
}
@@ -357,7 +355,7 @@
if(ex instanceof ELInvocationExpression) {
ELInvocationExpression expr = (ELInvocationExpression)ex;
try {
- ELResolution resolution = engine.resolveEL(null, expr, false);
+ ELResolution resolution = engine.resolveEL(null, expr, false, offset);
if(resolution != null && resolution.isResolved()) {
ELSegment segment = resolution.getLastSegment();
if(segment instanceof JavaMemberELSegmentImpl) {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamBeanHyperlinkPartitioner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamBeanHyperlinkPartitioner.java 2011-05-05
15:56:12 UTC (rev 31105)
+++
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamBeanHyperlinkPartitioner.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2008 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2008-2011 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.seam.text.ext.hyperlink;
@@ -41,7 +41,6 @@
import org.jboss.tools.seam.core.ISeamContextVariable;
import org.jboss.tools.seam.core.ISeamMessages;
import org.jboss.tools.seam.core.ISeamProject;
-import org.jboss.tools.seam.core.ScopeType;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.internal.core.el.SeamELCompletionEngine;
import org.jboss.tools.seam.text.ext.SeamExtPlugin;
@@ -347,7 +346,7 @@
elText.append('.').append(app);
javaElements = engine.getJavaElementsForExpression(
- seamProject, file, elText.toString());
+ seamProject, file, elText.toString(), region.getOffset());
}
return javaElements;
} catch (BadLocationException x) {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamComponentHyperlinkDetector.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamComponentHyperlinkDetector.java 2011-05-05
15:56:12 UTC (rev 31105)
+++
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamComponentHyperlinkDetector.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2009 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2009-2011 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.seam.text.ext.hyperlink;
@@ -172,7 +172,7 @@
try {
javaElements = engine.getJavaElementsForExpression(
- seamProject, file, value);
+ seamProject, file, value, region.getOffset());
} catch (StringIndexOutOfBoundsException e) {
SeamExtPlugin.getDefault().logError(e);
} catch (BadLocationException e) {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamELInJavaStringHyperlinkDetector.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamELInJavaStringHyperlinkDetector.java 2011-05-05
15:56:12 UTC (rev 31105)
+++
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamELInJavaStringHyperlinkDetector.java 2011-05-05
16:30:01 UTC (rev 31106)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
+ * Copyright (c) 2008-2011 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,
@@ -41,7 +41,6 @@
import org.jboss.tools.seam.core.ISeamContextVariable;
import org.jboss.tools.seam.core.ISeamMessages;
import org.jboss.tools.seam.core.ISeamProject;
-import org.jboss.tools.seam.core.ScopeType;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.internal.core.el.SeamELCompletionEngine;
import org.jboss.tools.seam.text.ext.SeamExtPlugin;
@@ -125,7 +124,7 @@
try {
javaElements = engine.getJavaElementsForExpression(
- seamProject, file, prefix);
+ seamProject, file, prefix, region.getOffset());
} catch (StringIndexOutOfBoundsException e) {
SeamExtPlugin.getPluginLog().logError(e);
} catch (BadLocationException e) {