Author: scabanovich
Date: 2008-09-25 10:22:58 -0400 (Thu, 25 Sep 2008)
New Revision: 10478
Modified:
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/SeamELCompletionEngine.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java
Log:
JBIDE-1497.
Internal methods prepared to be called with EL model objects
Modified:
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-09-25
13:12:01 UTC (rev 10477)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ElVarSearcher.java 2008-09-25
14:22:58 UTC (rev 10478)
@@ -260,7 +260,7 @@
if(resolvedToken==null && parentVar.getElToken()!=null) {
try {
// Initialize parent vars.
- engine.resolveSeamELOperand(project, file, var.getElToken().getText(),
var.getElToken().getText(), 0, true, parentVars, this);
+ engine.resolveSeamELOperand(project, file, var.getElToken().getText(), true,
parentVars, this);
resolvedToken = parentVar.getResolvedElToken();
} catch (StringIndexOutOfBoundsException e) {
SeamCorePlugin.getPluginLog().logError(e);
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-09-25
13:12:01 UTC (rev 10477)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2008-09-25
14:22:58 UTC (rev 10478)
@@ -97,7 +97,9 @@
public List<String> getCompletions(ISeamProject project, IFile file, String
documentContent, CharSequence prefix,
int position, boolean returnEqualedVariablesOnly, List<Var> vars) throws
BadLocationException, StringIndexOutOfBoundsException {
List<String> completions = new ArrayList<String>();
- SeamELOperandResolveStatus status = resolveSeamELOperand(project, file,
documentContent, prefix, position, returnEqualedVariablesOnly, vars, new
ElVarSearcher(project, file, this));
+ String prefix2 = SeamELCompletionEngine.getPrefix(documentContent, position +
prefix.length());
+
+ SeamELOperandResolveStatus status = resolveSeamELOperand(project, file, prefix2,
returnEqualedVariablesOnly, vars, new ElVarSearcher(project, file, this));
if (status.isOK()) {
completions.addAll(status.getProposals());
}
@@ -122,7 +124,7 @@
* Resolve EL.
* @param project Seam project.
* @param file
- * @param documentContent
+ * @param operand
* @param prefix Text between #{ and cursor position in document.
* @param position Cursor position in document
* @param returnEqualedVariablesOnly if "false" use prefix as mask.
@@ -132,9 +134,9 @@
* @throws BadLocationException
* @throws StringIndexOutOfBoundsException
*/
- public SeamELOperandResolveStatus resolveSeamELOperand(ISeamProject project, IFile file,
String documentContent, CharSequence prefix,
- int position, boolean returnEqualedVariablesOnly, List<Var> vars, ElVarSearcher
varSearcher) throws BadLocationException, StringIndexOutOfBoundsException {
- String oldEl = prefix.toString();
+ public SeamELOperandResolveStatus resolveSeamELOperand(ISeamProject project, IFile file,
String operand,
+ boolean returnEqualedVariablesOnly, List<Var> vars, ElVarSearcher varSearcher)
throws BadLocationException, StringIndexOutOfBoundsException {
+ String oldEl = operand;
Var var = varSearcher.findVarForEl(oldEl, vars, true);
String suffix = "";
String newEl = oldEl;
@@ -158,18 +160,18 @@
newEl = var.getElToken().getText() + suffix +
oldEl.substring(var.getName().length());
}
}
- String newDocumentContent = documentContent;
+ String newOperand = operand;
boolean prefixWasChanged = newEl!=oldEl;
if(prefixWasChanged) {
- newDocumentContent = documentContent.substring(0, position) + newEl;
+ newOperand = newEl;
}
- SeamELOperandResolveStatus status = resolveSeamELOperand(project, file,
newDocumentContent, newEl, position, returnEqualedVariablesOnly);
+ SeamELOperandResolveStatus status = resolveSeamELOperand(project, file, newOperand,
returnEqualedVariablesOnly);
if(prefixWasChanged) {
// Replace new EL by original one in result status.
ELOperandToken newLastResolvedToken = status.getLastResolvedToken();
- SeamELOperandTokenizer tokenizer = new SeamELOperandTokenizer(documentContent,
position + prefix.length());
+ SeamELOperandTokenizer tokenizer = new SeamELOperandTokenizer(operand,
operand.length());
List<ELOperandToken> oldTokens = tokenizer.getTokens();
status.setTokens(oldTokens);
if(newLastResolvedToken != null) {
@@ -194,7 +196,7 @@
}
if(!returnEqualedVariablesOnly && vars!=null) {
- status.getProposals().addAll(getVarNameProposals(vars, prefix.toString()));
+ status.getProposals().addAll(getVarNameProposals(vars, operand.toString()));
}
return status;
}
@@ -203,13 +205,13 @@
* Returns MemberInfo for last segment of EL. Null if El is not resolved.
* @param project
* @param file
- * @param elBody EL without #{}
+ * @param operand EL without #{}
* @return MemberInfo for last segment of EL. Null if El is not resolved.
* @throws BadLocationException
* @throws StringIndexOutOfBoundsException
*/
- public TypeInfoCollector.MemberInfo resolveSeamEL(ISeamProject project, IFile file,
String elBody) throws BadLocationException, StringIndexOutOfBoundsException {
- SeamELOperandResolveStatus status = resolveSeamELOperand(project, file, elBody, elBody,
0, true);
+ public TypeInfoCollector.MemberInfo resolveSeamEL(ISeamProject project, IFile file,
String operand) throws BadLocationException, StringIndexOutOfBoundsException {
+ SeamELOperandResolveStatus status = resolveSeamELOperand(project, file, operand,
true);
return status.getMemberOfResolvedOperand();
}
@@ -261,7 +263,7 @@
* Resolves Seam EL
* @param project
* @param file
- * @param documentContent
+ * @param operand
* @param prefix
* @param position
* @param returnEqualedVariablesOnly
@@ -269,10 +271,10 @@
* @throws BadLocationException
* @throws StringIndexOutOfBoundsException
*/
- public SeamELOperandResolveStatus resolveSeamELOperand(ISeamProject project, IFile file,
String documentContent, String prefix,
- int position, boolean returnEqualedVariablesOnly) throws BadLocationException,
StringIndexOutOfBoundsException {
+ public SeamELOperandResolveStatus resolveSeamELOperand(ISeamProject project, IFile file,
String operand,
+ boolean returnEqualedVariablesOnly) throws BadLocationException,
StringIndexOutOfBoundsException {
- SeamELOperandTokenizer tokenizer = new SeamELOperandTokenizer(documentContent, position
+ prefix.length());
+ SeamELOperandTokenizer tokenizer = new SeamELOperandTokenizer(operand,
operand.length());
SeamELOperandResolveStatus status = new
SeamELOperandResolveStatus(tokenizer.getTokens());
List<ISeamContextVariable> resolvedVariables = new
ArrayList<ISeamContextVariable>();
@@ -312,8 +314,8 @@
Set<String> proposals = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
for (ISeamContextVariable var : resolvedVariables) {
String varName = var.getName();
- if(varName.startsWith(prefix)) {
- proposals.add(varName.substring(prefix.length()));
+ if(varName.startsWith(operand)) {
+ proposals.add(varName.substring(operand.length()));
}
}
status.setProposals(proposals);
@@ -327,8 +329,8 @@
Set<String> proposals = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
for (ISeamContextVariable var : resolvedVariables) {
String varName = var.getName();
- if(prefix.length()<=varName.length()) {
- proposals.add(varName.substring(prefix.length()));
+ if(operand.length()<=varName.length()) {
+ proposals.add(varName.substring(operand.length()));
} else if(returnEqualedVariablesOnly) {
proposals.add(varName);
}
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-09-25
13:12:01 UTC (rev 10477)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2008-09-25
14:22:58 UTC (rev 10478)
@@ -304,7 +304,7 @@
}
SeamELOperandResolveStatus status =
- engine.resolveSeamELOperand(project, file, operand, prefix, position, true,
varListForCurentValidatedNode, elVarSearcher);
+ engine.resolveSeamELOperand(project, file, operand, true,
varListForCurentValidatedNode, elVarSearcher);
if(status.getUsedVariables().size()==0 && status.isError()) {
// Save resources with unknown variables names