Author: scabanovich
Date: 2008-10-01 11:34:00 -0400 (Wed, 01 Oct 2008)
New Revision: 10599
Removed:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ElVarSearcher.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELOperandResolveStatus.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/Var.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.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.core/src/org/jboss/tools/seam/internal/core/el/SeamPromptingProvider.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidatorManager.java
Log:
JBIDE-1497.
Refactoring
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2008-10-01
15:33:13 UTC (rev 10598)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2008-10-01
15:34:00 UTC (rev 10599)
@@ -21,7 +21,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osgi.util.NLS;
-import org.jboss.tools.common.model.util.TypeInfoCollector;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector;
import org.jboss.tools.seam.internal.core.SeamProject;
import org.jboss.tools.seam.internal.core.SeamResourceVisitor;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
Deleted:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ElVarSearcher.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ElVarSearcher.java 2008-10-01
15:33:13 UTC (rev 10598)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ElVarSearcher.java 2008-10-01
15:34:00 UTC (rev 10599)
@@ -1,287 +0,0 @@
- /*******************************************************************************
- * Copyright (c) 2007 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.seam.internal.core.el;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.jboss.tools.common.el.core.model.ELExpression;
-import org.jboss.tools.seam.core.ISeamProject;
-import org.jboss.tools.seam.core.SeamCorePlugin;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * This class helps to find var/value attributes in DOM tree.
- * @author Alexey Kazakov
- */
-public class ElVarSearcher {
-
- private final static String VAR_ATTRIBUTE_NAME = "var";
- private final static String VALUE_ATTRIBUTE_NAME = "value";
-
- private ISeamProject project;
- private IFile file;
- private SeamELCompletionEngine engine;
-
- /**
- * Constructor.
- * @param project Seam project where we will look for vars.
- * @param file File where we will look for vars.
- * @param engine Competion Engine that we will use for resolving vars.
- */
- public ElVarSearcher(ISeamProject project, IFile file, SeamELCompletionEngine engine) {
- this.project = project;
- this.file = file;
- this.engine = engine;
- }
-
- /**
- * Constructor.
- * @param project Seam project where we will look for vars.
- * @param engine Competion Engine that we will use for resolving vars.
- */
- public ElVarSearcher(ISeamProject project, SeamELCompletionEngine engine) {
- this(project, null, engine);
- }
-
- /**
- * @param file File where we will look for vars.
- */
- public void setFile(IFile file) {
- this.file = file;
- }
-
- /**
- * @param viewer
- * @param offset
- * @return
- */
- public static Node getNode(ITextViewer viewer, int offset) {
- IndexedRegion treeNode = ContentAssistUtils.getNodeAt(viewer, offset);
- if(treeNode instanceof Node) {
- return (Node)treeNode;
- }
- return null;
- }
-
- /**
- * @param viewer
- * @param offset
- * @return
- */
-
- public static Node getNode(IFile file, int offset) {
- IndexedRegion treeNode = getNodeAt(file, offset);
- if(treeNode instanceof Node) {
- return (Node)treeNode;
- }
- return null;
- }
-
- /**
- * Returns the closest IndexedRegion for the offset and viewer allowing
- * for differences between viewer offsets and model positions. note: this
- * method returns an IndexedRegion for read only
- *
- * @param file
- * the file whose document is used to compute the proposals
- * @param documentOffset
- * an offset within the document for which completions should
- * be computed
- * @return an IndexedRegion
- */
-
- public static IndexedRegion getNodeAt(IFile file, int documentOffset) {
-
- if (file == null)
- return null;
-
- IndexedRegion node = null;
- IModelManager mm = StructuredModelManager.getModelManager();
- IStructuredModel model = null;
- if (mm != null) {
- try {
- model = mm.getModelForRead(file);
- } catch (IOException e) {
- return null;
- } catch (CoreException e) {
- return null;
- }
- }
- try {
- if (model != null) {
- int lastOffset = documentOffset;
- node = model.getIndexedRegion(documentOffset);
- while (node == null && lastOffset >= 0) {
- lastOffset--;
- node = model.getIndexedRegion(lastOffset);
- }
- }
- } finally {
- if (model != null)
- model.releaseFromRead();
- }
- return node;
- }
-
- /**
- * @param node
- * @return All var/value that can be used in this position and null if can't find
anyone.
- */
- public static List<Var> findAllVars(ITextViewer viewer, int offset) {
- Node node = getNode(viewer, offset);
- if(node!=null) {
- return findAllVars(node);
- }
- return null;
- }
-
- /**
- * @param node
- * @return All var/value that can be used in this position and null if can't find
anyone.
- */
- public static List<Var> findAllVars(IFile file, int offset) {
- Node node = getNode(file, offset);
- if(node!=null) {
- return findAllVars(node);
- }
- return null;
- }
-
- /**
- * @param node
- * @return All var/value that can be used in node and null if can't find anyone.
- */
- public static List<Var> findAllVars(Node node) {
- ArrayList<Var> vars = null;
- Node parentNode = node.getParentNode();
- while(parentNode!=null) {
- Var var = findVar(parentNode);
- if(var!=null) {
- if(vars == null) {
- vars = new ArrayList<Var>();
- }
- vars.add(0, var);
- }
- parentNode = parentNode.getParentNode();
- }
- return vars;
- }
-
- /**
- * @param node
- * @return found var/value that can be used in this position and null if can't find
anyone.
- */
- public static Var findVar(IFile file, int offset) {
- Node node = getNode(file, offset);
- if(node!=null) {
- return findVar(node);
- }
- return null;
- }
-
- /**
- * Finds var/value attribute in node
- * @param node
- * @param vars
- * @return found var/value or null
- */
- public static Var findVar(Node node) {
- if(node!=null && Node.ELEMENT_NODE == node.getNodeType()) {
- Element element = (Element)node;
- String var = element.getAttribute(VAR_ATTRIBUTE_NAME);
- if(var!=null) {
- int declOffset = 0;
- int declLength = 0;
- Node varAttr = element.getAttributeNode(VAR_ATTRIBUTE_NAME);
- if (varAttr instanceof IDOMAttr) {
- int varNameStart = ((IDOMAttr)varAttr).getNameRegionStartOffset();
- int varNameEnd = ((IDOMAttr)varAttr).getNameRegionEndOffset();
- declOffset = varNameStart;
- declLength = varNameEnd - varNameStart;
- }
- var = var.trim();
- if(!"".equals(var)) {
- String value = element.getAttribute(VALUE_ATTRIBUTE_NAME);
- if(value!=null) {
- value = value.trim();
- Var newVar = new Var(var, value, declOffset, declLength);
- if(newVar.getElToken()!=null) {
- return newVar;
- }
- }
- }
- }
- }
-
- return null;
- }
-
- /**
- * Finds var in list of vars that is used in given EL.
- * @param el EL without brackets.
- * @param vars
- * @param initializeNestedVars
- * @return
- */
- public Var findVarForEl(String el, List<Var> vars, boolean initializeNestedVars)
{
- if(vars!=null) {
- ArrayList<Var> parentVars = new ArrayList<Var>();
- for (Var var : vars) {
- ELExpression token = var.getElToken();
- if(token!=null && !token.getText().endsWith(".")) {
- String varName = var.getName();
- if(el.startsWith(varName)) { //TODO it was el.equals(varName) and did not work.
Why?
- if(var.getElToken()!=null && initializeNestedVars) {
- Var parentVar = findVarForEl(var.getElToken().getText(), parentVars, true);
- if(parentVar!=null) {
- ELExpression resolvedToken = parentVar.getResolvedElToken();
- if(resolvedToken==null && parentVar.getElToken()!=null) {
- try {
- // Initialize parent vars.
- engine.resolveSeamELOperand(project, file, var.getElToken(), true, parentVars,
this);
- resolvedToken = parentVar.getResolvedElToken();
- } catch (StringIndexOutOfBoundsException e) {
- SeamCorePlugin.getPluginLog().logError(e);
- } catch (BadLocationException e) {
- SeamCorePlugin.getPluginLog().logError(e);
- }
- }
- if(resolvedToken!=null) {
- String oldText = var.getElToken().getText();
- String newValue = "#{" + resolvedToken.getText() +
oldText.substring(parentVar.getName().length()) + "}";
- var.value = newValue;
- var.elToken = var.parseEl(newValue);
- }
- }
- }
- return var;
- }
- }
- parentVars.add(var);
- }
- }
- return null;
- }
-
-}
\ No newline at end of file
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 2008-10-01
15:33:13 UTC (rev 10598)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2008-10-01
15:34:00 UTC (rev 10599)
@@ -38,8 +38,13 @@
import org.jboss.tools.common.el.core.model.ELUtil;
import org.jboss.tools.common.el.core.parser.ELParser;
import org.jboss.tools.common.el.core.parser.ELParserFactory;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
import org.jboss.tools.common.el.core.parser.LexicalToken;
-import org.jboss.tools.common.model.util.TypeInfoCollector;
+import org.jboss.tools.common.el.core.resolver.ELCompletionEngine;
+import org.jboss.tools.common.el.core.resolver.ELOperandResolveStatus;
+import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector;
+import org.jboss.tools.common.el.core.resolver.Var;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamContextVariable;
import org.jboss.tools.seam.core.ISeamProject;
@@ -52,14 +57,21 @@
*
* @author Jeremy
*/
-public final class SeamELCompletionEngine {
+public final class SeamELCompletionEngine implements ELCompletionEngine {
+ ISeamProject project;
+ ELParserFactory factory = ELParserUtil.getJbossFactory();
/**
* Constructs SeamELCompletionEngine object
*/
- public SeamELCompletionEngine() {
+ public SeamELCompletionEngine(ISeamProject project) {
+ this.project = project;
}
+ public ELParserFactory getParserFactory() {
+ return factory;
+ }
+
/**
* Create the array of suggestions.
*
@@ -74,9 +86,9 @@
* @return the list of all possible suggestions
* @throws BadLocationException if accessing the current document fails
*/
- public List<String> getCompletions(ISeamProject project, IFile file, IDocument
document, CharSequence prefix,
+ public List<String> getCompletions(IFile file, IDocument document, CharSequence
prefix,
int position, List<Var> vars, int start, int end) throws BadLocationException,
StringIndexOutOfBoundsException {
- return getCompletions(project, file, document, prefix, position, false, vars, start,
end);
+ return getCompletions(file, document, prefix, position, false, vars, start, end);
}
/**
@@ -103,13 +115,13 @@
* @throws BadLocationException if accessing the current document fails
* @throws StringIndexOutOfBoundsException
*/
- public List<String> getCompletions(ISeamProject project, IFile file, IDocument
document, CharSequence prefix,
+ public List<String> getCompletions(IFile file, IDocument document, CharSequence
prefix,
int position, boolean returnEqualedVariablesOnly, List<Var> vars, int start, int
end) throws BadLocationException, StringIndexOutOfBoundsException {
List<String> completions = new ArrayList<String>();
String prefix2 = getPrefix(document, position + prefix.length(), start, end);
- SeamELOperandResolveStatus status = resolveSeamELOperand(project, file,
parseOperand(prefix2), returnEqualedVariablesOnly, vars, new ElVarSearcher(project, file,
this));
+ ELOperandResolveStatus status = resolveELOperand(file, parseOperand(prefix2),
returnEqualedVariablesOnly, vars, new ElVarSearcher(file, this));
if (status.isOK()) {
completions.addAll(status.getProposals());
}
@@ -131,7 +143,7 @@
return proposals;
}
- public SeamELOperandResolveStatus resolveSeamELOperand(ISeamProject project, IFile file,
ELExpression operand,
+ public SeamELOperandResolveStatus resolveELOperand(IFile file, ELExpression operand,
boolean returnEqualedVariablesOnly, List<Var> vars, ElVarSearcher varSearcher)
throws BadLocationException, StringIndexOutOfBoundsException {
if(operand == null) {
//TODO
@@ -142,7 +154,7 @@
String suffix = "";
String newEl = oldEl;
if(var!=null) {
- TypeInfoCollector.MemberInfo member = resolveSeamEL(project, file, var.getElToken());
+ TypeInfoCollector.MemberInfo member = resolveSeamEL(file, var.getElToken());
if(member!=null && !member.getType().isArray()) {
IType type = member.getMemberType();
if(type!=null) {
@@ -164,7 +176,7 @@
boolean prefixWasChanged = newEl != oldEl;
ELExpression newOperand = (prefixWasChanged) ? parseOperand(newEl) : operand;
- SeamELOperandResolveStatus status = resolveSeamELOperand(project, file, newOperand,
returnEqualedVariablesOnly);
+ SeamELOperandResolveStatus status = resolveELOperand(file, newOperand,
returnEqualedVariablesOnly);
if(prefixWasChanged) {
ELInvocationExpression newLastResolvedToken = status.getLastResolvedToken();
@@ -199,10 +211,10 @@
return status;
}
- public static ELExpression parseOperand(String operand) {
+ public ELExpression parseOperand(String operand) {
if(operand == null) return null;
String el = (operand.indexOf("#{") < 0) ? "#{" + operand +
"}" : operand;
- ELParser p = ELParserFactory.createJbossParser();
+ ELParser p = factory.createParser();
ELModel model = p.parse(el);
List<ELInstance> is = model.getInstances();
if(is.size() == 0) return null;
@@ -218,10 +230,9 @@
* @throws BadLocationException
* @throws StringIndexOutOfBoundsException
*/
- public TypeInfoCollector.MemberInfo resolveSeamEL(ISeamProject project, IFile file,
ELExpression operand) throws BadLocationException, StringIndexOutOfBoundsException {
+ public TypeInfoCollector.MemberInfo resolveSeamEL(IFile file, ELExpression operand)
throws BadLocationException, StringIndexOutOfBoundsException {
if(!(operand instanceof ELInvocationExpression)) return null;
- SeamELOperandResolveStatus status = resolveSeamELOperand(project, file, operand,
true);
-
+ ELOperandResolveStatus status = resolveELOperand(file, operand, true);
return status.getMemberOfResolvedOperand();
}
@@ -240,7 +251,7 @@
if(!el.startsWith("#{")) {
el = "#{" + el + "}";
}
- ELParser parser = ELParserFactory.createJbossParser();
+ ELParser parser = factory.createParser();
ELModel model = parser.parse(el);
List<ELInstance> is = model.getInstances();
if(is.size() < 1) return resolvedVariables;
@@ -253,17 +264,17 @@
boolean isIncomplete = expr.getType() == ELObjectType.EL_PROPERTY_INVOCATION
&& ((ELPropertyInvocation) expr).getName() == null;
- SeamELOperandResolveStatus status = new SeamELOperandResolveStatus(expr);
+ ELOperandResolveStatus status = new ELOperandResolveStatus(expr);
ELInvocationExpression left = expr;
ScopeType scope = getScope(project, file);
if (expr.getLeft() == null && isIncomplete) {
- resolvedVariables = resolveVariables(project, scope, expr, true, true);
+ resolvedVariables = resolveVariables(scope, expr, true, true);
} else {
while (left != null) {
List<ISeamContextVariable> resolvedVars = new
ArrayList<ISeamContextVariable>();
- resolvedVars = resolveVariables(project, scope, left,
+ resolvedVars = resolveVariables(scope, left,
left == expr, true);
if (resolvedVars != null && !resolvedVars.isEmpty()) {
resolvedVariables = resolvedVars;
@@ -281,7 +292,7 @@
return resolvedVariables;
}
- public SeamELOperandResolveStatus resolveSeamELOperand(ISeamProject project, IFile file,
ELExpression operand,
+ public SeamELOperandResolveStatus resolveELOperand(IFile file, ELExpression operand,
boolean returnEqualedVariablesOnly) throws BadLocationException,
StringIndexOutOfBoundsException {
if(!(operand instanceof ELInvocationExpression)) {
return new SeamELOperandResolveStatus(null);
@@ -298,13 +309,12 @@
ScopeType scope = getScope(project, file);
if (expr.getLeft() == null && isIncomplete) {
- resolvedVariables = resolveVariables(project, scope,
- expr, true,
+ resolvedVariables = resolveVariables(scope, expr, true,
returnEqualedVariablesOnly);
} else {
while(left != null) {
List<ISeamContextVariable>resolvedVars = new
ArrayList<ISeamContextVariable>();
- resolvedVars = resolveVariables(project, scope,
+ resolvedVars = resolveVariables(scope,
left, left == expr,
returnEqualedVariablesOnly);
if (resolvedVars != null && !resolvedVars.isEmpty()) {
@@ -327,7 +337,7 @@
isIncomplete) {
// no vars are resolved
// the tokens are the part of var name ended with a separator (.)
- resolvedVariables = resolveVariables(project, scope, expr, true,
returnEqualedVariablesOnly);
+ resolvedVariables = resolveVariables(scope, expr, true,
returnEqualedVariablesOnly);
Set<String> proposals = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
for (ISeamContextVariable var : resolvedVariables) {
String varName = var.getName();
@@ -383,7 +393,7 @@
private List<TypeInfoCollector.MemberInfo> resolveSegment(ELInvocationExpression
expr,
List<TypeInfoCollector.MemberInfo> members,
- SeamELOperandResolveStatus status,
+ ELOperandResolveStatus status,
boolean returnEqualedVariablesOnly) {
LexicalToken lt = (expr instanceof ELPropertyInvocation)
? ((ELPropertyInvocation)expr).getName()
@@ -444,11 +454,10 @@
private void resolveLastSegment(ELInvocationExpression expr,
List<TypeInfoCollector.MemberInfo> members,
- SeamELOperandResolveStatus status,
+ ELOperandResolveStatus status,
boolean returnEqualedVariablesOnly) {
Set<String> proposals = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
if (expr.getType() == ELObjectType.EL_PROPERTY_INVOCATION &&
((ELPropertyInvocation)expr).getName() == null) {
-// if (token.getType() == ELOperandToken.EL_SEPARATOR_TOKEN) {
// return all the methods + properties
for (TypeInfoCollector.MemberInfo mbr : members) {
if (mbr instanceof MessagesInfo) {
@@ -506,15 +515,8 @@
}
for (TypeInfoCollector.MemberPresentation proposal : proposalsToFilter) {
// We do expect nothing but name for method tokens (No round brackets)
- LexicalToken lt = (expr instanceof ELPropertyInvocation)
- ? ((ELPropertyInvocation)expr).getName()
- : (expr instanceof ELMethodInvocation)
- ? ((ELMethodInvocation)expr).getName()
- : null;
- String filter = lt != null ? lt.getText() : ""; //token.getText();
-// if (filter.indexOf('(') != -1) {
-// filter = filter.substring(0, filter.indexOf('('));
-// }
+ String filter = expr.getMemberName();
+ if(filter == null) filter = "";
if(returnEqualedVariablesOnly) {
// This is used for validation.
if (proposal.getPresentation().equals(filter)) {
@@ -596,34 +598,8 @@
return null;
}
-/**
- private List<ISeamContextVariable> resolveVariables(ISeamProject project,
ScopeType scope, List<ELOperandToken>part, List<ELOperandToken> tokens,
boolean onlyEqualNames) {
+ private List<ISeamContextVariable> resolveVariables(ScopeType scope,
ELInvocationExpression expr, boolean isFinal, boolean onlyEqualNames) {
List<ISeamContextVariable>resolvedVars = new
ArrayList<ISeamContextVariable>();
- String varName = computeVariableName(part);
- if (varName != null) {
- resolvedVars = SeamExpressionResolver.resolveVariables(project, scope, varName,
onlyEqualNames);
- }
- if (resolvedVars != null && resolvedVars.size() > 0) {
- List<ISeamContextVariable> newResolvedVars = new
ArrayList<ISeamContextVariable>();
- for (ISeamContextVariable var : resolvedVars) {
- if(!areEqualExpressions(part, tokens)) {
- // Do filter by equals (name)
- // In case of the last pass - do not filter by startsWith(name) instead of equals
- if (varName.equals(var.getName())) {
- newResolvedVars.add(var);
- }
- } else {
- newResolvedVars.add(var);
- }
- }
- return newResolvedVars;
- }
- return new ArrayList<ISeamContextVariable>();
- }
-*/
-
- private List<ISeamContextVariable> resolveVariables(ISeamProject project,
ScopeType scope, ELInvocationExpression expr, boolean isFinal, boolean onlyEqualNames) {
- List<ISeamContextVariable>resolvedVars = new
ArrayList<ISeamContextVariable>();
String varName = expr.toString();
if (varName != null) {
resolvedVars = SeamExpressionResolver.resolveVariables(project, scope, varName,
onlyEqualNames);
@@ -646,23 +622,6 @@
return new ArrayList<ISeamContextVariable>();
}
-/**
- public static List<List<ELOperandToken>>
getPossibleVarsFromPrefix(List<ELOperandToken>prefix) {
- ArrayList<List<ELOperandToken>> result = new
ArrayList<List<ELOperandToken>>();
- for (int i = 0; prefix != null && i < prefix.size(); i++) {
- ELOperandToken lastToken = prefix.get(i);
- if (lastToken.getType() != ELOperandToken.EL_SEPARATOR_TOKEN) {
- ArrayList<ELOperandToken> prefixPart = new ArrayList<ELOperandToken>();
- for (int j = 0; j <= i; j++) {
- prefixPart.add(prefix.get(j));
- }
- result.add(0, prefixPart);
- }
- }
- return result;
- }
-*/
-
/**
* Removes duplicates of completion strings
*
@@ -697,7 +656,7 @@
* @return
* @throws BadLocationException
*/
- public static String getPrefix(ITextViewer viewer, int offset, int start, int end)
throws StringIndexOutOfBoundsException {
+ public String getPrefix(ITextViewer viewer, int offset, int start, int end) throws
StringIndexOutOfBoundsException {
IDocument doc= viewer.getDocument();
if (doc == null || offset > doc.getLength())
return null;
@@ -714,7 +673,7 @@
* @return
* @throws StringIndexOutOfBoundsException
*/
- public static String getPrefix(IDocument document, int offset, int start, int end)
throws StringIndexOutOfBoundsException {
+ public String getPrefix(IDocument document, int offset, int start, int end) throws
StringIndexOutOfBoundsException {
if (document == null || document.get() == null || offset > document.get().length())
return null;
ELInvocationExpression expr = findExpressionAtOffset(document, offset, start, end);
@@ -773,154 +732,6 @@
return getJavaElementsForELOperandTokens(project, file, (ELInvocationExpression)expr);
}
-/**
- public List<IJavaElement> getJavaElementsForELOperandTokens(
- ISeamProject project, IFile file,
- List<ELOperandToken> tokens) throws BadLocationException,
StringIndexOutOfBoundsException {
- List<IJavaElement> res= new ArrayList<IJavaElement>();
- if (tokens == null || tokens.size() == 0 || tokens.get(tokens.size() - 1).getType() ==
ELOperandToken.EL_SEPARATOR_TOKEN)
- return res;
-
- List<ELOperandToken> resolvedExpressionPart = new
ArrayList<ELOperandToken>();
- List<ISeamContextVariable> resolvedVariables = new
ArrayList<ISeamContextVariable>();
- ScopeType scope = getScope(project, file);
- List<List<ELOperandToken>> variations = getPossibleVarsFromPrefix(tokens);
-
- if (variations.isEmpty()) {
- resolvedVariables = resolveVariables(project, scope, tokens, tokens, true);
- } else {
- for (List<ELOperandToken> variation : variations) {
- List<ISeamContextVariable>resolvedVars = new
ArrayList<ISeamContextVariable>();
- resolvedVars = resolveVariables(project, scope, variation, tokens, true);
- if (resolvedVars != null && !resolvedVars.isEmpty()) {
- resolvedVariables = resolvedVars;
- resolvedExpressionPart = variation;
- break;
- }
- }
- }
-
- // Here we have a list of vars for some part of expression
- // OK. we'll proceed with members of these vars
- if (areEqualExpressions(resolvedExpressionPart, tokens)) {
- // First segment is the last one
- for (ISeamContextVariable var : resolvedVariables) {
- IMember member = SeamExpressionResolver.getMemberByVariable(var, true);
- if (member instanceof IJavaElement){
- res.add((IJavaElement)member);
- }
- }
- return res;
- }
-
- // First segment is found - proceed with next tokens
- int startTokenIndex = (resolvedExpressionPart == null ? 0 :
resolvedExpressionPart.size());
- List<TypeInfoCollector.MemberInfo> members = new
ArrayList<TypeInfoCollector.MemberInfo>();
- for (ISeamContextVariable var : resolvedVariables) {
- TypeInfoCollector.MemberInfo member =
SeamExpressionResolver.getMemberInfoByVariable(var, true);
- if (member != null && !members.contains(member))
- members.add(member);
- }
- for (int i = startTokenIndex;
- tokens != null && i < tokens.size() &&
- members != null && members.size() > 0;
- i++) {
- ELOperandToken token = tokens.get(i);
-
- if (i < tokens.size() - 1) { // inside expression
- if (token.getType() == ELOperandToken.EL_SEPARATOR_TOKEN)
- // proceed with next token
- continue;
-
- if (token.isNameToken()) {
- // Find properties for the token
- String name = token.getText();
- List<TypeInfoCollector.MemberInfo> newMembers = new
ArrayList<TypeInfoCollector.MemberInfo>();
- for (TypeInfoCollector.MemberInfo mbr : members) {
- TypeInfoCollector infos = mbr.getTypeCollector();
- List<TypeInfoCollector.MemberInfo> properties = infos.getProperties();
- for (TypeInfoCollector.MemberInfo property : properties) {
- StringBuffer propertyName = new StringBuffer(property.getName());
- if (property instanceof TypeInfoCollector.MethodInfo) { // Setter or getter
- propertyName.delete(0, 3);
- propertyName.setCharAt(0, Character.toLowerCase(propertyName.charAt(0)));
- }
- if (name.equals(propertyName.toString())) {
- newMembers.add(property);
- }
- }
- }
- members = newMembers;
- }
- if (token.getType() == ELOperandToken.EL_METHOD_TOKEN) {
- // Find methods for the token
- String name = token.getText();
- if (name.indexOf('(') != -1) {
- name = name.substring(0, name.indexOf('('));
- }
- List<TypeInfoCollector.MemberInfo> newMembers = new
ArrayList<TypeInfoCollector.MemberInfo>();
- for (TypeInfoCollector.MemberInfo mbr : members) {
- TypeInfoCollector infos = mbr.getTypeCollector();
- List<TypeInfoCollector.MemberInfo> methods = infos.getMethods();
- for (TypeInfoCollector.MemberInfo method : methods) {
- if (method instanceof TypeInfoCollector.MethodInfo
- && name.equals(method.getName())) {
- newMembers.add(method);
- }
- }
- }
- members = newMembers;
- }
- } else { // Last segment
- List<IJavaElement> javaElements = new ArrayList<IJavaElement>();
- if (token.getType() == ELOperandToken.EL_VARIABLE_NAME_TOKEN ||
- token.getType() == ELOperandToken.EL_PROPERTY_NAME_TOKEN ||
- token.getType() == ELOperandToken.EL_METHOD_TOKEN) {
- // return filtered methods + properties
- List<TypeInfoCollector.MemberInfo> javaElementInfosToFilter = new
ArrayList<TypeInfoCollector.MemberInfo>();
- for (TypeInfoCollector.MemberInfo mbr : members) {
- TypeInfoCollector infos = mbr.getTypeCollector();
- javaElementInfosToFilter.addAll(infos.getMethods());
- javaElementInfosToFilter.addAll(infos.getProperties());
- }
-
- for (TypeInfoCollector.MemberInfo info : javaElementInfosToFilter) {
- // We do expect nothing but name for method tokens (No round brackets)
- String filter = token.getText();
- if (token.getType() == ELOperandToken.EL_METHOD_TOKEN) {
- if (filter.indexOf('(') >=0)
- filter = filter.substring(0, filter.indexOf('('));
- }
- // This is used for validation.
- if (info.getName().equals(filter)) {
- javaElements.add(info.getJavaElement());
- } else {
- if (info instanceof TypeInfoCollector.MethodInfo) {
- TypeInfoCollector.MethodInfo methodInfo = (TypeInfoCollector.MethodInfo)info;
- if(methodInfo.isGetter() || methodInfo.isSetter()) {
- StringBuffer name = new StringBuffer(methodInfo.getName());
- if(methodInfo.getName().startsWith("i")) { //$NON-NLS-1$
- name.delete(0, 2);
- } else {
- name.delete(0, 3);
- }
- name.setCharAt(0, Character.toLowerCase(name.charAt(0)));
- String propertyName = name.toString();
- if (propertyName.equals(filter)) {
- javaElements.add(methodInfo.getJavaElement());
- }
- }
- }
- }
- }
- }
- res.addAll(javaElements);
- }
- }
- return res;
- }
-*/
-
/**
* Create the array of suggestions.
* @param project Seam project
@@ -945,17 +756,50 @@
while(left != null) {
List<ISeamContextVariable>resolvedVars = new
ArrayList<ISeamContextVariable>();
- resolvedVars = resolveVariables(project, scope,
- left, left == expr,
- true);
+ resolvedVars = resolveVariables(scope, left, left == expr, true);
if (resolvedVars != null && !resolvedVars.isEmpty()) {
resolvedVariables = resolvedVars;
break;
}
- int y = 0;
left = (ELInvocationExpression)left.getLeft();
}
+ if(resolvedVariables.size() == 0) {
+
+ ElVarSearcher varSearcher = new ElVarSearcher(this);
+ List<Var> vars = varSearcher.findAllVars(file, expr.getStartPosition());
+ String oldEl = expr.getText();
+ Var var = varSearcher.findVarForEl(oldEl, vars, true);
+ String suffix = "";
+ String newEl = oldEl;
+ if(var!=null) {
+ TypeInfoCollector.MemberInfo member = resolveSeamEL(file, var.getElToken());
+ if(member!=null && !member.getType().isArray()) {
+ IType type = member.getMemberType();
+ if(type!=null) {
+ try {
+ if(TypeInfoCollector.isInstanceofType(type, "java.util.Map")) {
+ suffix = collectionAdditionForMapDataModel;
+ } else {
+ suffix = collectionAdditionForCollectionDataModel;
+ }
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ }
+ }
+ if(var.getElToken() != null) {
+ newEl = var.getElToken().getText() + suffix +
oldEl.substring(var.getName().length());
+ ELExpression newOperand = parseOperand(newEl);
+ if(newOperand instanceof ELInvocationExpression) {
+ return getJavaElementsForELOperandTokens(project, file,
(ELInvocationExpression)newOperand);
+ }
+ }
+ }
+
+
+ }
+ int i = 2;
// Here we have a list of vars for some part of expression
// OK. we'll proceed with members of these vars
if (left == expr) {
@@ -1054,12 +898,8 @@
for (TypeInfoCollector.MemberInfo info : javaElementInfosToFilter) {
// We do expect nothing but name for method tokens (No round brackets)
- LexicalToken lt = (expr instanceof ELPropertyInvocation)
- ? ((ELPropertyInvocation)expr).getName()
- : (expr instanceof ELMethodInvocation)
- ? ((ELMethodInvocation)expr).getName()
- : null;
- String filter = lt != null ? lt.getText() : ""; //token.getText();
+ String filter = expr.getMemberName();
+ if(filter == null) filter = "";
// This is used for validation.
if (info.getName().equals(filter)) {
@@ -1095,7 +935,7 @@
* @param end end of relevant region in document
* @return
*/
- public static ELInvocationExpression findExpressionAtOffset(IDocument document, int
offset, int start, int end) {
+ public ELInvocationExpression findExpressionAtOffset(IDocument document, int offset, int
start, int end) {
String content = document.get();
//TODO this naive calculations should be removed;
@@ -1103,7 +943,7 @@
if(start <= 0) start = guessStart(content, offset);
if(end >= content.length()) end = guessEnd(content, offset);
- ELParser parser = ELParserFactory.createJbossParser();
+ ELParser parser = factory.createParser();
ELModel model = parser.parse(content, start, end - start);
return ELUtil.findExpression(model, offset);
@@ -1133,54 +973,4 @@
return content.length();
}
-/**
- public static List<ELOperandToken> findTokensAtOffset(IDocument document, int
offset) {
- List<ELOperandToken> result = new ArrayList<ELOperandToken>();
-
- int elStart = getELStart(document, offset);
-
- if (elStart == -1)
- elStart = offset;
-
- SeamELOperandTokenizerForward tokenizer = new SeamELOperandTokenizerForward(document,
elStart);
- List<ELOperandToken> tokens = tokenizer.getTokens();
-
- ELOperandToken lastSeparator = null;
- for (int i = 0; tokens != null && i < tokens.size(); i++) {
- ELOperandToken token = tokens.get(i);
- if (token.getType() == ELOperandToken.EL_SEPARATOR_TOKEN) {
- lastSeparator = token;
- continue;
- }
- if (token.getType() == ELOperandToken.EL_VARIABLE_NAME_TOKEN ||
- token.getType() == ELOperandToken.EL_METHOD_TOKEN ||
- token.getType() == ELOperandToken.EL_PROPERTY_NAME_TOKEN) {
- if (token.getStart() <= offset) {
- if (lastSeparator != null)
- result.add(lastSeparator);
- result.add(token);
- } else {
- // Stop processing. We're not interrested of the rest of tokens
- break;
- }
- }
- }
-
- return result;
- }
-*/
-
-/**
- private static int getELStart(IDocument document, int offset) {
- SeamELOperandTokenizer tokenizer = new SeamELOperandTokenizer(document, offset);
- List<ELOperandToken> tokens = tokenizer.getTokens();
-
- if (tokens == null || tokens.size() == 0)
- return -1;
-
- ELOperandToken firstToken = tokens.get(0);
- return firstToken.getStart();
- }
-*/
-
}
Deleted:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELOperandResolveStatus.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELOperandResolveStatus.java 2008-10-01
15:33:13 UTC (rev 10598)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELOperandResolveStatus.java 2008-10-01
15:34:00 UTC (rev 10599)
@@ -1,174 +0,0 @@
-package org.jboss.tools.seam.internal.core.el;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.jboss.tools.common.el.core.model.ELInvocationExpression;
-import org.jboss.tools.common.model.util.TypeInfoCollector;
-import org.jboss.tools.seam.core.ISeamContextVariable;
-
-/**
- * Status of EL resolving.
- * @author Jeremy
- */
-public class SeamELOperandResolveStatus {
- private ELInvocationExpression tokens;
- public List<ISeamContextVariable> usedVariables;
- Map<String, TypeInfoCollector.MethodInfo> unpairedGettersOrSetters;
- Set<String> proposals;
- private ELInvocationExpression lastResolvedToken;
- private boolean isMapOrCollectionOrBundleAmoungTheTokens = false;
- private TypeInfoCollector.MemberInfo memberOfResolvedOperand;
-
- /**
- * @return MemberInfo of last segment of EL operand. Null if El is not resolved.
- */
- public TypeInfoCollector.MemberInfo getMemberOfResolvedOperand() {
- return memberOfResolvedOperand;
- }
-
- /**
- * Sets MemberInfo for last segment of EL operand.
- * @param lastResolvedMember
- */
- public void setMemberOfResolvedOperand(
- TypeInfoCollector.MemberInfo lastResolvedMember) {
- this.memberOfResolvedOperand = lastResolvedMember;
- }
-
- /**
- * Constructor
- * @param tokens Tokens of EL
- */
- public SeamELOperandResolveStatus(ELInvocationExpression tokens) {
- this.tokens = tokens;
- }
-
- /**
- * @return true if EL contains any not parametrized Collection or ResourceBundle.
- */
- public boolean isMapOrCollectionOrBundleAmoungTheTokens() {
- return this.isMapOrCollectionOrBundleAmoungTheTokens;
- }
-
- public void setMapOrCollectionOrBundleAmoungTheTokens() {
- this.isMapOrCollectionOrBundleAmoungTheTokens = true;
- }
-
- /**
- * @return true if EL is resolved.
- */
- public boolean isOK() {
- return !getProposals().isEmpty() || isMapOrCollectionOrBundleAmoungTheTokens();
- }
-
- /**
- * @return false if El is not resolved.
- */
- public boolean isError() {
- return !isOK();
- }
-
- /**
- * @return List of resolved tokens of EL. Includes separators "."
- */
- public ELInvocationExpression getResolvedTokens() {
- return lastResolvedToken;
- }
-
- /**
- * @return List of unresolved tokens of EL.
- */
- public ELInvocationExpression getUnresolvedTokens() {
- if(lastResolvedToken == tokens) return null;
- if(lastResolvedToken != null && (lastResolvedToken.getParent() instanceof
ELInvocationExpression)) {
- return (ELInvocationExpression)lastResolvedToken.getParent();
- }
- ELInvocationExpression l = tokens;
- while(l != null && l.getLeft() != lastResolvedToken) {
- l = l.getLeft();
- }
- return l;
- }
-
- /**
- * @return Last resolved token of EL. Can be separator "." // no, change it
- */
- public ELInvocationExpression getLastResolvedToken() {
- return lastResolvedToken;
- }
-
- /**
- * @param lastResolvedToken Last resolved token of EL. Can be separator "."
- */
- public void setLastResolvedToken(ELInvocationExpression lastResolvedToken) {
- this.lastResolvedToken = lastResolvedToken;
- }
-
- /**
- * @return Tokens of EL.
- */
- public ELInvocationExpression getTokens() {
- return tokens;
- }
-
- /**
- * @param tokens Tokens of EL.
- */
- public void setTokens(ELInvocationExpression tokens) {
- this.tokens = tokens;
- }
-
- /**
- * @return Set of proposals for EL.
- */
- public Set<String> getProposals() {
- return proposals == null ? new TreeSet<String>() : proposals;
- }
-
- /**
- * @param proposals Set of proposals.
- */
- public void setProposals(Set<String> proposals) {
- this.proposals = proposals;
- }
-
- /**
- * @return List of Seam Context Variables used in EL.
- */
- public List<ISeamContextVariable> getUsedVariables() {
- return (usedVariables == null ? new ArrayList<ISeamContextVariable>() :
usedVariables);
- }
-
- /**
- * @param usedVariables List of Seam Context Variables used in EL.
- */
- public void setUsedVariables(List<ISeamContextVariable> usedVariables) {
- this.usedVariables = usedVariables;
- }
-
- /**
- * @return Map of unpaired getters and setters (getters/setters without proper
setters/getters).
- * of all properties used in EL.
- * Key - name of property.
- * Value - MethodInfo of existed getter/setter.
- */
- public Map<String, TypeInfoCollector.MethodInfo> getUnpairedGettersOrSetters() {
- if (unpairedGettersOrSetters == null) {
- unpairedGettersOrSetters = new HashMap<String, TypeInfoCollector.MethodInfo>();
- }
- return unpairedGettersOrSetters;
- }
-
- /**
- * Clear Map of unpaired getters and setters.
- */
- public void clearUnpairedGettersOrSetters() {
- getUnpairedGettersOrSetters().clear();
- }
-
-}
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 2008-10-01
15:33:13 UTC (rev 10598)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java 2008-10-01
15:34:00 UTC (rev 10599)
@@ -20,11 +20,11 @@
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
-import org.jboss.tools.common.model.util.TypeInfoCollector;
-import org.jboss.tools.common.model.util.TypeInfoCollector.MemberInfo;
-import org.jboss.tools.common.model.util.TypeInfoCollector.Type;
-import org.jboss.tools.common.model.util.TypeInfoCollector.TypeInfo;
-import org.jboss.tools.common.model.util.TypeInfoCollector.TypeMemberInfo;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector.MemberInfo;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector.Type;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector.TypeInfo;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector.TypeMemberInfo;
import org.jboss.tools.seam.core.BijectedAttributeType;
import org.jboss.tools.seam.core.IBijectedAttribute;
import org.jboss.tools.seam.core.ISeamComponent;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamPromptingProvider.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamPromptingProvider.java 2008-10-01
15:33:13 UTC (rev 10598)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamPromptingProvider.java 2008-10-01
15:34:00 UTC (rev 10599)
@@ -29,7 +29,7 @@
public static String VARIABLES = "seam.variables"; //$NON-NLS-1$
public static String MEMBERS = "seam.members"; //$NON-NLS-1$
- SeamELCompletionEngine engine= new SeamELCompletionEngine();
+// SeamELCompletionEngine engine= new SeamELCompletionEngine();
public SeamPromptingProvider() {}
Deleted:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/Var.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/Var.java 2008-10-01
15:33:13 UTC (rev 10598)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/Var.java 2008-10-01
15:34:00 UTC (rev 10599)
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.seam.internal.core.el;
-
-import java.util.List;
-
-import org.jboss.tools.common.el.core.model.ELExpression;
-import org.jboss.tools.common.el.core.model.ELInstance;
-import org.jboss.tools.common.el.core.model.ELModel;
-import org.jboss.tools.common.el.core.parser.ELParser;
-import org.jboss.tools.common.el.core.parser.ELParserFactory;
-
-/**
- * Represents "var"/"value" attributes.
- * @author Alexey Kazakov
- */
-public class Var {
- String name;
- String value;
- ELExpression elToken;
- String resolvedValue;
- ELExpression resolvedElToken;
- int declOffset;
- int declLength;
-
- /**
- * Constructor
- * @param name - value of "var" attribute.
- * @param value - value of "value" attribute.
- */
- public Var(String name, String value, int declOffset, int declLength) {
- super();
- this.name = name;
- this.value = value;
- elToken = parseEl(value);
- this.declOffset = declOffset;
- this.declLength = declLength;
- }
-
- /**
- * Constructor
- * @param name - value of "var" attribute.
- * @param value - value of "value" attribute.
- */
- public Var(String name, String value) {
- this(name, value, 0, 0);
- }
-
- ELExpression parseEl(String el) {
- if(el.length()>3 && el.startsWith("#{") &&
el.endsWith("}")) {
- ELParser parser = ELParserFactory.createJbossParser();
- ELModel model = parser.parse(el);
- if(model == null || parser.getSyntaxErrors().size() > 0) return null;
- List<ELInstance> is = model.getInstances();
- if(is.size() == 0) return null;
- return is.get(0).getExpression();
- }
- return null;
- }
-
- /**
- * Sets value to new resolved EL which we got as result of parsing value.
- * For example:
- * <h:datatable value="#{list}" var="item">
- * <h:dataTable value="#{item.anotherList}" var="innerItem">
- * ...
- * </h:dataTable>
- * </h:dataTable>
- * Original El is #{item.anotherList}
- * Resolved El is #{list.iterator().next().anotherList}
- * It's very useful for nested vars.
- * @param newEl
- */
- public void resolveValue(String newEl) {
- resolvedValue = newEl;
- resolvedElToken = parseEl(newEl);
- }
-
- /**
- * @return parsed EL from "value" attribute. Returns null if EL is not valid.
- */
- public ELExpression getElToken() {
- return elToken;
- }
-
- /**
- * @return parsed resolved EL from "value" attribute. May be null.
- */
- public ELExpression getResolvedElToken() {
- return resolvedElToken;
- }
-
- /**
- * @return name of variable.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @return value of variable. It's EL.
- */
- public String getValue() {
- return value;
- }
-
- /**
- * @return resolved value of variable. It's EL. May be null.
- */
- public String getResolvedValue() {
- return resolvedValue;
- }
-
- /**
- * @return offset of the var declaration
- */
- public int getDeclarationOffset() {
- return declOffset;
- }
-
- /**
- * @return length of the var declaration
- */
- public int getDeclarationLength() {
- return declLength;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Var) {
- Var compare = (Var)obj;
- String str = getName();
- if (str != null) {
- if (!str.equals(compare.getName()))
- return false;
- } else {
- if (compare.getName() != null)
- return false;
- }
- str = getValue();
- return (str != null ?
- str.equals(compare.getValue()) :
- compare.getValue() == null);
- }
- return false;
- }
-
-}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2008-10-01
15:33:13 UTC (rev 10598)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2008-10-01
15:34:00 UTC (rev 10599)
@@ -31,8 +31,8 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.validation.internal.core.ValidationException;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.common.model.util.TypeInfoCollector;
import org.jboss.tools.seam.core.BijectedAttributeType;
import org.jboss.tools.seam.core.IBijectedAttribute;
import org.jboss.tools.seam.core.IRole;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2008-10-01
15:33:13 UTC (rev 10598)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2008-10-01
15:34:00 UTC (rev 10599)
@@ -47,18 +47,20 @@
import org.jboss.tools.common.el.core.model.ELModel;
import org.jboss.tools.common.el.core.parser.ELParser;
import org.jboss.tools.common.el.core.parser.ELParserFactory;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
import org.jboss.tools.common.el.core.parser.SyntaxError;
-import org.jboss.tools.common.model.util.TypeInfoCollector;
+import org.jboss.tools.common.el.core.resolver.ELOperandResolveStatus;
+import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector;
+import org.jboss.tools.common.el.core.resolver.Var;
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.seam.core.ISeamContextVariable;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCoreMessages;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.SeamPreferences;
-import org.jboss.tools.seam.internal.core.el.ElVarSearcher;
import org.jboss.tools.seam.internal.core.el.SeamELCompletionEngine;
import org.jboss.tools.seam.internal.core.el.SeamELOperandResolveStatus;
-import org.jboss.tools.seam.internal.core.el.Var;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -75,7 +77,7 @@
protected static final String VALIDATING_EL_FILE_MESSAGE_ID =
"VALIDATING_EL_FILE";
- private SeamELCompletionEngine engine = new SeamELCompletionEngine();
+ private SeamELCompletionEngine engine;
private List<Var> varListForCurentValidatedNode = new ArrayList<Var>();
private ElVarSearcher elVarSearcher;
@@ -83,7 +85,8 @@
SeamContextValidationHelper coreHelper, IReporter reporter,
SeamValidationContext validationContext, ISeamProject project) {
super(validatorManager, coreHelper, reporter, validationContext, project);
- elVarSearcher = new ElVarSearcher(project, engine);
+ engine = new SeamELCompletionEngine(project);
+ elVarSearcher = new ElVarSearcher(engine);
}
/* (non-Javadoc)
@@ -213,7 +216,7 @@
String preferenceValue = SeamPreferences.getProjectPreference(project,
SeamPreferences.CHECK_VARS);
Var var = null;
if (SeamPreferences.ENABLE.equals(preferenceValue)) {
- var = ElVarSearcher.findVar(parent);
+ var = elVarSearcher.findVar(parent);
}
if(var!=null) {
varListForCurentValidatedNode.add(var);
@@ -254,7 +257,7 @@
private void validateString(IFile file, String string, int offset) {
int startEl = string.indexOf("#{"); //$NON-NLS-1$
if(startEl>-1) {
- ELParser parser = ELParserFactory.createJbossParser();
+ ELParser parser = ELParserUtil.getJbossFactory().createParser();
ELModel model = parser.parse(string);
List<SyntaxError> errors = parser.getSyntaxErrors();
if(errors.size() > 0) {
@@ -298,7 +301,7 @@
if (!operand.endsWith(".")) { //$NON-NLS-1$
{
SeamELOperandResolveStatus status =
- engine.resolveSeamELOperand(project, file, operandToken, true,
varListForCurentValidatedNode, elVarSearcher);
+ engine.resolveELOperand(file, operandToken, true, varListForCurentValidatedNode,
elVarSearcher);
if(status.getUsedVariables().size()==0 && status.isError()) {
// Save resources with unknown variables names
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidatorManager.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidatorManager.java 2008-10-01
15:33:13 UTC (rev 10598)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidatorManager.java 2008-10-01
15:34:00 UTC (rev 10599)
@@ -19,7 +19,7 @@
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
import org.eclipse.wst.validation.internal.provisional.core.IValidatorJob;
-import org.jboss.tools.common.model.util.TypeInfoCollector;
+import org.jboss.tools.common.el.core.resolver.TypeInfoCollector;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.internal.core.SeamProject;