JBoss Tools SVN: r16193 - in trunk/jst/plugins: org.jboss.tools.jst.web.kb/META-INF and 12 other directories.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2009-06-24 17:20:45 -0400 (Wed, 24 Jun 2009)
New Revision: 16193
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/
trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/jboss/
trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/jboss/tools/
trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/jboss/tools/jst/
trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/jboss/tools/jst/web/
trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/jboss/tools/jst/web/kb/
trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/jboss/tools/jst/web/kb/EnumerationProposal.gif
trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/jboss/tools/jst/web/kb/JSFActionProposal.gif
trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/jboss/tools/jst/web/kb/MessageBundleProposal.gif
trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/jboss/tools/jst/web/kb/ResourcePathProposal.gif
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/el/
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/el/AbstractELCompletionEngine.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ActionProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalTypeFactory.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EnumerationProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletsJsfCProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ModelProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpaceProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourceBundleNameProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourcePathProposalType.java
Removed:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/AbstractELCompletionEngine.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibAttribute.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibrary.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/CustomTagLibManager.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2808
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2009-06-24 21:15:23 UTC (rev 16192)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2009-06-24 21:20:45 UTC (rev 16193)
@@ -48,11 +48,11 @@
<provisionalDefinition
type="showintarget"
value="org.eclipse.jdt.ui.PackageExplorer"
- target="org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor"/>
- <provisionalDefinition
- type="showintarget"
- value="org.jboss.tools.jst.web.ui.navigator.WebProjectsView"
target="org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor"/>
+ <provisionalDefinition
+ type="showintarget"
+ value="org.jboss.tools.jst.web.ui.navigator.WebProjectsView"
+ target="org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor"/>
<provisionalDefinition
type="preferencepages"
value="org.eclipse.wst.sse.ui.preferences.jsp.occurrences"
@@ -422,7 +422,7 @@
<contenttype id="org.eclipse.wst.html.core.htmlsource">
<partitiontype id="org.eclipse.wst.html.HTML_DEFAULT" />
<partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL" />
- <partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL2" />
+ <partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL2" /> <!-- Is this forgotten? -->
</contenttype>
</contentAssistProcessor>
@@ -430,7 +430,7 @@
//added by estherbin
//fix http://jira.jboss.com/jira/browse/JBIDE-1791
-->
- <!--contentAssistProcessor
+ <contentAssistProcessor
class="org.eclipse.wst.css.ui.internal.contentassist.CSSContentAssistProcessor"
id="org.eclipse.wst.css.ui.internal.contentassist.CSSContentAssistProcessor">
<contenttype id="org.eclipse.wst.html.core.htmlsource">
@@ -438,6 +438,7 @@
</contenttype>
</contentAssistProcessor>
+ <!--
<contentAssistProcessor
class="org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor"
id="org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor">
@@ -475,7 +476,8 @@
<partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL" />
<partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL2" />
</contenttype>
- </contentAssistProcessor -->
+ </contentAssistProcessor>
+ -->
</extension>
<extension
point="org.eclipse.ui.popupMenus">
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF 2009-06-24 21:15:23 UTC (rev 16192)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF 2009-06-24 21:20:45 UTC (rev 16193)
@@ -15,6 +15,7 @@
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %providerName
Export-Package: org.jboss.tools.jst.web.kb,
+ org.jboss.tools.jst.web.kb.el,
org.jboss.tools.jst.web.kb.internal,
org.jboss.tools.jst.web.kb.internal.scanner,
org.jboss.tools.jst.web.kb.internal.taglib,
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/jboss/tools/jst/web/kb/EnumerationProposal.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/jboss/tools/jst/web/kb/EnumerationProposal.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/jboss/tools/jst/web/kb/JSFActionProposal.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/jboss/tools/jst/web/kb/JSFActionProposal.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/jboss/tools/jst/web/kb/MessageBundleProposal.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/jboss/tools/jst/web/kb/MessageBundleProposal.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/jboss/tools/jst/web/kb/ResourcePathProposal.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/resources/org/jboss/tools/jst/web/kb/ResourcePathProposal.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/AbstractELCompletionEngine.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/AbstractELCompletionEngine.java 2009-06-24 21:15:23 UTC (rev 16192)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/AbstractELCompletionEngine.java 2009-06-24 21:20:45 UTC (rev 16193)
@@ -1,671 +0,0 @@
-package org.jboss.tools.jst.web.kb;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.swt.graphics.Image;
-import org.jboss.tools.common.el.core.model.ELArgumentInvocation;
-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.ELInvocationExpression;
-import org.jboss.tools.common.el.core.model.ELMethodInvocation;
-import org.jboss.tools.common.el.core.model.ELModel;
-import org.jboss.tools.common.el.core.model.ELObjectType;
-import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
-import org.jboss.tools.common.el.core.parser.ELParser;
-import org.jboss.tools.common.el.core.parser.LexicalToken;
-import org.jboss.tools.common.el.core.resolver.ELCompletionEngine;
-import org.jboss.tools.common.el.core.resolver.ELContext;
-import org.jboss.tools.common.el.core.resolver.ELOperandResolveStatus;
-import org.jboss.tools.common.el.core.resolver.ELResolver;
-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.text.TextProposal;
-
-public abstract class AbstractELCompletionEngine<V extends AbstractELCompletionEngine.IVariable> implements ELResolver, ELCompletionEngine {
-
- public static interface IVariable {
- public String getName();
- }
-
- public AbstractELCompletionEngine() {}
-
- public abstract Image getELProposalImage();
-
- protected abstract void log(Exception e);
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.common.el.core.resolver.ELResolver#getCompletions(java.lang.String, boolean, int, org.jboss.tools.common.el.core.resolver.ELContext)
- */
- public List<TextProposal> getCompletions(String elString, boolean returnEqualedVariablesOnly, int position, ELContext context) {
- IDocument document = null;
- if(context instanceof IPageContext) {
- IPageContext pageContext = (IPageContext)context;
- document = pageContext.getDocument();
- }
- List<Var> vars = new ArrayList<Var>();
- Var[] array = context.getVars();
- for (int i = 0; i < array.length; i++) {
- vars.add(array[i]);
- }
- List<TextProposal> proposals = null;
- try {
- proposals = getCompletions(context.getResource(), document, elString.subSequence(0, elString.length()), position, returnEqualedVariablesOnly, vars);
- } catch (StringIndexOutOfBoundsException e) {
- log(e);
- } catch (BadLocationException e) {
- log(e);
- }
- return proposals;
- }
-
- /**
- * Create the list of suggestions.
- * @param seamProject Seam project
- * @param file File
- * @param documentContent
- * @param prefix the prefix to search for
- * @param position Offset of the prefix
- * @param vars - 'var' attributes which can be used in this EL. Can be null.
- * @param returnEqualedVariablesOnly 'false' if we get proposals for mask
- * for example:
- * we have 'variableName.variableProperty', 'variableName.variableProperty1', 'variableName.variableProperty2'
- * prefix is 'variableName.variableProperty'
- * Result is {'variableProperty'}
- * if 'false' then returns ends of variables that starts with prefix. It's useful for CA.
- * for example:
- * we have 'variableName.variableProperty', 'variableName.variableProperty1', 'variableName.variableProperty2'
- * prefix is 'variableName.variableProperty'
- * Result is {'1','2'}
- * @return the list of all possible suggestions
- * @throws BadLocationException if accessing the current document fails
- * @throws StringIndexOutOfBoundsException
- */
- public List<TextProposal> getCompletions(IFile file, IDocument document, CharSequence prefix,
- int position, boolean returnEqualedVariablesOnly, List<Var> vars) throws BadLocationException, StringIndexOutOfBoundsException {
- List<TextProposal> completions = new ArrayList<TextProposal>();
-
- ELOperandResolveStatus status = resolveELOperand(file, parseOperand("" + prefix), returnEqualedVariablesOnly, vars, new ElVarSearcher(file, this));
- if (status.isOK()) {
- completions.addAll(status.getProposals());
- }
-
- return completions;
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.common.el.core.resolver.ELResolver#resolveELOperand(org.jboss.tools.common.el.core.model.ELExpression, org.jboss.tools.common.el.core.resolver.ELContext, boolean)
- */
- public ELOperandResolveStatus resolveELOperand(ELExpression operand, ELContext context, boolean returnEqualedVariablesOnly) {
- List<Var> vars = new ArrayList<Var>();
- Var[] array = context.getVars();
- for (int i = 0; i < array.length; i++) {
- vars.add(array[i]);
- }
- ELOperandResolveStatus status = null;
- try {
- status = resolveELOperand(context.getResource(), operand, returnEqualedVariablesOnly, vars, new ElVarSearcher(context.getResource(), this));
- } catch (StringIndexOutOfBoundsException e) {
- log(e);
- } catch (BadLocationException e) {
- log(e);
- }
- return status;
- }
-
- public ELExpression parseOperand(String operand) {
- if(operand == null) return null;
- String el = (operand.indexOf("#{") < 0 && operand.indexOf("${") < 0) ? "#{" + operand + "}" : operand;
- ELParser p = getParserFactory().createParser();
- ELModel model = p.parse(el);
- List<ELInstance> is = model.getInstances();
- if(is.isEmpty()) return null;
- return is.get(0).getExpression();
- }
-
- protected static final String collectionAdditionForCollectionDataModel = ".iterator().next()";
- protected static final String collectionAdditionForMapDataModel = ".entrySet().iterator().next()";
-
- protected List<String> getVarNameProposals(List <Var> vars, String prefix) {
- List<String> proposals = new ArrayList<String>();
- for (Var var : vars) {
- if(var.getName().startsWith(prefix)) {
- String proposal = var.getName().substring(prefix.length());
- proposals.add(proposal);
- }
- }
- return proposals;
- }
-
- protected ELOperandResolveStatus newELOperandResolveStatus(ELInvocationExpression tokens) {
- return new ELOperandResolveStatus(tokens);
- }
-
- public ELOperandResolveStatus resolveELOperand(IFile file,
- ELExpression operand, boolean returnEqualedVariablesOnly,
- List<Var> vars, ElVarSearcher varSearcher)
- throws BadLocationException, StringIndexOutOfBoundsException {
- if(operand == null) {
- //TODO
- return newELOperandResolveStatus(null);
- }
- String oldEl = operand.getText();
- Var var = varSearcher.findVarForEl(oldEl, vars, true);
- String suffix = "";
- String newEl = oldEl;
- TypeInfoCollector.MemberInfo member = null;
- boolean isArray = false;
- if(var!=null) {
- member = resolveEL(file, var.getElToken(), true);
- if(member!=null) {
- if(!member.getType().isArray()) {
- IType type = member.getMemberType();
- if(type!=null) {
- try {
- if(TypeInfoCollector.isInstanceofType(type, "java.util.Map")) {
- suffix = collectionAdditionForMapDataModel;
- } else if(TypeInfoCollector.isInstanceofType(type, "java.util.Collection")) {
- suffix = collectionAdditionForCollectionDataModel;
- }
- } catch (JavaModelException e) {
- log(e);
- }
- }
- } else {
- isArray = true;
- }
- }
- if(var.getElToken() != null) {
- newEl = var.getElToken().getText() + suffix + oldEl.substring(var.getName().length());
- }
- }
- boolean prefixWasChanged = !oldEl.equals(newEl);
- if(prefixWasChanged && isArray) {
- member.setDataModel(true);
- }
- ELExpression newOperand = (prefixWasChanged) ? parseOperand(newEl) : operand;
-
- ELOperandResolveStatus status = resolveELOperand(file, newOperand, returnEqualedVariablesOnly, prefixWasChanged);
-
- if(prefixWasChanged) {
- ELInvocationExpression newLastResolvedToken = status.getLastResolvedToken();
- status.setTokens((ELInvocationExpression)operand);
- if(newLastResolvedToken != null) {
- if(status.getUnresolvedTokens() != null
- && status.getUnresolvedTokens().getInvocationStartPosition() - status.getUnresolvedTokens().getStartPosition() < var.getElToken().getLength() + suffix.length()) {
- // Last resolved token is token from "var". Set first token of original EL as last resolved one.
- status.setLastResolvedToken(null);
- } else {
- // Last resolved token is token outside "var" prefix. Correct last resolved token.
- int oldLastResolvedTokenStart = newLastResolvedToken.getInvocationStartPosition() - var.getElToken().getText().length() - suffix.length() + var.getName().length();
- if(newLastResolvedToken.getLeft() == null) {
- //In this case we do not need to take into account difference in length of var and its expression.
- oldLastResolvedTokenStart = newLastResolvedToken.getInvocationStartPosition();
- }
- ELInvocationExpression l = (ELInvocationExpression)operand;
- while(l != null) {
- if(l.getInvocationStartPosition() - l.getStartPosition() <= oldLastResolvedTokenStart) {
- status.setLastResolvedToken(l);
- break;
- }
- l = l.getLeft();
- }
- }
- }
- }
-
- if(prefixWasChanged) {
- var.resolveValue("#{" + var.getElToken().getText() + suffix + "}");
- }
-
- if(!returnEqualedVariablesOnly && vars!=null) {
- List<String> varNameProposals = getVarNameProposals(vars, operand.toString());
- if (varNameProposals != null) {
- for (String varNameProposal : varNameProposals) {
- TextProposal proposal = new TextProposal();
- proposal.setReplacementString(varNameProposal);
- proposal.setImage(getELProposalImage());
- status.getProposals().add(proposal);
- }
- }
- }
- return status;
- }
-
-
- /**
- * Returns MemberInfo for last segment of EL. Null if El is not resolved.
- * @param seamProject
- * @param file
- * @param operand EL without #{}
- * @return MemberInfo for last segment of EL. Null if El is not resolved.
- * @throws BadLocationException
- * @throws StringIndexOutOfBoundsException
- */
- public TypeInfoCollector.MemberInfo resolveEL(IFile file, ELExpression operand, boolean varIsUsed) throws BadLocationException, StringIndexOutOfBoundsException {
- if(!(operand instanceof ELInvocationExpression)) return null;
- ELOperandResolveStatus status = resolveELOperand(file, operand, true, varIsUsed);
- return status.getMemberOfResolvedOperand();
- }
-
- public ELOperandResolveStatus resolveELOperand(IFile file, ELExpression operand,
- boolean returnEqualedVariablesOnly, boolean varIsUsed) throws BadLocationException, StringIndexOutOfBoundsException {
- if(!(operand instanceof ELInvocationExpression) || file == null) {
- return newELOperandResolveStatus(null);
- }
-
- ELInvocationExpression expr = (ELInvocationExpression)operand;
- boolean isIncomplete = expr.getType() == ELObjectType.EL_PROPERTY_INVOCATION
- && ((ELPropertyInvocation)expr).getName() == null;
- boolean isArgument = expr.getType() == ELObjectType.EL_ARGUMENT_INVOCATION;
-
- ELOperandResolveStatus status = newELOperandResolveStatus(expr);
- ELInvocationExpression left = expr;
-
- List<V> resolvedVariables = new ArrayList<V>();
-
- if (expr.getLeft() != null && isArgument) {
- left = expr.getLeft();
- resolvedVariables = resolveVariables(file, left, false,
- true); // 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);
- } else {
- while(left != null) {
- List<V>resolvedVars = new ArrayList<V>();
- resolvedVars = resolveVariables(file,
- left, left == expr,
- returnEqualedVariablesOnly);
- if (resolvedVars != null && !resolvedVars.isEmpty()) {
- resolvedVariables = resolvedVars;
- status.setLastResolvedToken(left);
- break;
- }
- left = (ELInvocationExpression)left.getLeft();
- }
- }
-
- // Save all resolved variables. It's useful for incremental validation.
- if(resolvedVariables != null && !resolvedVariables.isEmpty()) {
- setUsedVariables(status, resolvedVariables);
- }
-
- if (status.getResolvedTokens() == null &&
- !returnEqualedVariablesOnly &&
- expr != null &&
- isIncomplete) {
- // no vars are resolved
- // the tokens are the part of var name ended with a separator (.)
- resolvedVariables = resolveVariables(file, expr, true, returnEqualedVariablesOnly);
- Set<TextProposal> proposals = new TreeSet<TextProposal>(TextProposal.KB_PROPOSAL_ORDER);
- for (V var : resolvedVariables) {
- String varName = var.getName();
- if(varName.startsWith(operand.getText())) {
- TextProposal proposal = new TextProposal();
- proposal.setReplacementString(varName.substring(operand.getLength()));
- setImage(proposal, var);
- proposals.add(proposal);
- }
- }
- status.setProposals(proposals);
- return status;
- }
-
- // Here we have a list of vars for some part of expression
- // OK. we'll proceed with members of these vars
- if (status.getResolvedTokens() == status.getTokens()) {
- // First segment is the last one
- Set<TextProposal> proposals = new TreeSet<TextProposal>(TextProposal.KB_PROPOSAL_ORDER);
- // In some cases there may be a few references to the same variable name.
- // For example @Factory and @DataModel. We should use @DataModel instead of @Factory
- // method which returns null.
- // See https://jira.jboss.org/jira/browse/JBIDE-3694
- TypeInfoCollector.MemberInfo bijectedAttribute = null;
- for (V var : resolvedVariables) {
- if(isSingularAttribute(var)) {
- bijectedAttribute = getMemberInfoByVariable(var, true);
- }
- String varName = var.getName();
- if(operand.getLength()<=varName.length()) {
- TextProposal proposal = new TextProposal();
- proposal.setReplacementString(varName.substring(operand.getLength()));
- setImage(proposal, var);
- proposals.add(proposal);
- } else if(returnEqualedVariablesOnly) {
- TextProposal proposal = new TextProposal();
- proposal.setReplacementString(varName);
- setImage(proposal, var);
- proposals.add(proposal);
- }
- status.setMemberOfResolvedOperand(bijectedAttribute!=null?bijectedAttribute:getMemberInfoByVariable(var, true));
- }
- status.setLastResolvedToken(expr);
- status.setProposals(proposals);
- return status;
- }
-
- // First segment is found - proceed with next tokens
- List<TypeInfoCollector.MemberInfo> members = new ArrayList<TypeInfoCollector.MemberInfo>();
- for (V var : resolvedVariables) {
- TypeInfoCollector.MemberInfo member = getMemberInfoByVariable(var, returnEqualedVariablesOnly);
- if (member != null && !members.contains(member))
- members.add(member);
- }
- //process segments one by one
- if(left != null) while(left != expr) {
- left = (ELInvocationExpression)left.getParent();
- if (left != expr) { // inside expression
- if(left instanceof ELArgumentInvocation) {
- String s = "#{" + left.getLeft().toString() + collectionAdditionForCollectionDataModel + "}";
- ELParser p = getParserFactory().createParser();
- ELInvocationExpression expr1 = (ELInvocationExpression)p.parse(s).getInstances().get(0).getExpression();
- members = resolveSegment(expr1.getLeft(), members, status, returnEqualedVariablesOnly, varIsUsed);
- members = resolveSegment(expr1, members, status, returnEqualedVariablesOnly, varIsUsed);
- if(status.getLastResolvedToken() == expr1) {
- status.setLastResolvedToken(left);
- }
- } else {
- members = resolveSegment(left, members, status, returnEqualedVariablesOnly, varIsUsed);
- }
- } else { // Last segment
- resolveLastSegment((ELInvocationExpression)operand, members, status, returnEqualedVariablesOnly, varIsUsed);
- break;
- }
- }
-
- if(status.getProposals().isEmpty() && status.getUnpairedGettersOrSetters()!=null) {
- status.clearUnpairedGettersOrSetters();
- }
- return status;
- }
-
- public List<V> resolveVariables(IFile file, ELInvocationExpression expr, boolean isFinal, boolean onlyEqualNames) {
- return new ArrayList<V>();
- }
-
- protected TypeInfoCollector.MemberInfo getMemberInfoByVariable(V var, boolean onlyEqualNames) {
- return null;
- }
-
- protected void setUsedVariables(ELOperandResolveStatus status, List<V> resolvedVariables) {
- }
-
- protected boolean isSingularAttribute(V var) {
- return false;
- }
-
-
- protected List<TypeInfoCollector.MemberInfo> resolveSegment(ELInvocationExpression expr,
- List<TypeInfoCollector.MemberInfo> members,
- ELOperandResolveStatus status,
- boolean returnEqualedVariablesOnly, boolean varIsUsed) {
- LexicalToken lt = (expr instanceof ELPropertyInvocation)
- ? ((ELPropertyInvocation)expr).getName()
- : (expr instanceof ELMethodInvocation)
- ? ((ELMethodInvocation)expr).getName()
- : null;
- String name = lt != null ? lt.getText() : ""; // token.getText();
- if (expr.getType() == ELObjectType.EL_PROPERTY_INVOCATION) {
- // Find properties for the token
- List<TypeInfoCollector.MemberInfo> newMembers = new ArrayList<TypeInfoCollector.MemberInfo>();
- for (TypeInfoCollector.MemberInfo mbr : members) {
- if (mbr.getMemberType() == null) continue;
- TypeInfoCollector infos = mbr.getTypeCollector(varIsUsed);
- if (TypeInfoCollector.isNotParameterizedCollection(mbr) || TypeInfoCollector.isResourceBundle(mbr.getMemberType())) {
- status.setMapOrCollectionOrBundleAmoungTheTokens();
- }
- 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, (propertyName.charAt(0) == 'i' ? 2 : 3));
- propertyName.setCharAt(0, Character.toLowerCase(propertyName.charAt(0)));
- }
- if (name.equals(propertyName.toString())) {
- newMembers.add(property);
- }
- }
- }
- members = newMembers;
- if (members != null && !members.isEmpty())
- status.setLastResolvedToken(expr);
- }
- if (expr.getType() == ELObjectType.EL_METHOD_INVOCATION) {
- // Find methods for the token
- if (name.indexOf('(') != -1) {
- name = name.substring(0, name.indexOf('('));
- }
- List<TypeInfoCollector.MemberInfo> newMembers = new ArrayList<TypeInfoCollector.MemberInfo>();
- for (TypeInfoCollector.MemberInfo mbr : members) {
- if (mbr.getMemberType() == null) continue;
- TypeInfoCollector infos = mbr.getTypeCollector();
- if (TypeInfoCollector.isNotParameterizedCollection(mbr) || TypeInfoCollector.isResourceBundle(mbr.getMemberType())) {
- status.setMapOrCollectionOrBundleAmoungTheTokens();
- }
- List<TypeInfoCollector.MemberInfo> methods = infos.getMethods();
- for (TypeInfoCollector.MemberInfo method : methods) {
- if (name.equals(method.getName())) {
- newMembers.add(method);
- }
- }
- }
- members = newMembers;
- if (members != null && !members.isEmpty())
- status.setLastResolvedToken(expr);
- }
- return members;
- }
-
- protected void resolveLastSegment(ELInvocationExpression expr,
- List<TypeInfoCollector.MemberInfo> members,
- ELOperandResolveStatus status,
- boolean returnEqualedVariablesOnly, boolean varIsUsed) {
- Set<TextProposal> kbProposals = new TreeSet<TextProposal>(TextProposal.KB_PROPOSAL_ORDER);
-
- if (expr.getType() == ELObjectType.EL_PROPERTY_INVOCATION && ((ELPropertyInvocation)expr).getName() == null) {
- // return all the methods + properties
- for (TypeInfoCollector.MemberInfo mbr : members) {
- if(isSingularMember(mbr)) {
- processSingularMember(mbr, kbProposals);
- continue;
- }
- if (mbr.getMemberType() == null) {
- continue;
- }
- TypeInfoCollector infos = mbr.getTypeCollector(varIsUsed);
- if (TypeInfoCollector.isNotParameterizedCollection(mbr) || TypeInfoCollector.isResourceBundle(mbr.getMemberType())) {
- status.setMapOrCollectionOrBundleAmoungTheTokens();
- }
-
- Set<String> methodPresentations =
- infos.getMethodPresentationStrings();
- if (methodPresentations != null) {
- for (String presentation : methodPresentations) {
- TextProposal proposal = new TextProposal();
- proposal.setReplacementString(presentation);
- proposal.setImage(getELProposalImage());
-
- kbProposals.add(proposal);
- }
- }
- Set<String> propertyPresentations =
- infos.getPropertyPresentationStrings(status.getUnpairedGettersOrSetters());
- if (propertyPresentations != null) {
- for (String presentation : propertyPresentations) {
- TextProposal proposal = new TextProposal();
- proposal.setReplacementString(presentation);
- proposal.setImage(getELProposalImage());
-
- kbProposals.add(proposal);
- }
- }
- }
- } else
- if(expr.getType() != ELObjectType.EL_ARGUMENT_INVOCATION)
- //actually any case
-// 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
- Set<TypeInfoCollector.MemberPresentation> proposalsToFilter = new TreeSet<TypeInfoCollector.MemberPresentation>(TypeInfoCollector.MEMBER_PRESENTATION_COMPARATOR);
- for (TypeInfoCollector.MemberInfo mbr : members) {
- if(isSingularMember(mbr)) {
- filterSingularMember(mbr, proposalsToFilter);
- continue;
- }
- if (mbr.getMemberType() == null) continue;
- TypeInfoCollector infos = mbr.getTypeCollector();
- if (TypeInfoCollector.isNotParameterizedCollection(mbr) || TypeInfoCollector.isResourceBundle(mbr.getMemberType())) {
- status.setMapOrCollectionOrBundleAmoungTheTokens();
- }
- proposalsToFilter.addAll(infos.getMethodPresentations());
- proposalsToFilter.addAll(infos.getPropertyPresentations(status.getUnpairedGettersOrSetters()));
- status.setMemberOfResolvedOperand(mbr);
- }
- for (TypeInfoCollector.MemberPresentation proposal : proposalsToFilter) {
- // We do expect nothing but name for method tokens (No round brackets)
- String filter = expr.getMemberName();
- if(filter == null) filter = "";
- if(returnEqualedVariablesOnly) {
- // This is used for validation.
- if (proposal.getPresentation().equals(filter)) {
- TextProposal kbProposal = new TextProposal();
- kbProposal.setReplacementString(proposal.getPresentation());
-
- setImage(kbProposal, proposal);
-
- kbProposals.add(kbProposal);
-
- status.setMemberOfResolvedOperand(proposal.getMember());
- if(status.getUnpairedGettersOrSetters()!=null) {
- TypeInfoCollector.MethodInfo unpirMethod = status.getUnpairedGettersOrSetters().get(filter);
- status.clearUnpairedGettersOrSetters();
- if(unpirMethod!=null) {
- status.getUnpairedGettersOrSetters().put(filter, unpirMethod);
- }
- }
- break;
- }
- } else if (proposal.getPresentation().startsWith(filter)) {
- // This is used for CA.
- TextProposal kbProposal = new TextProposal();
- kbProposal.setReplacementString(proposal.getPresentation().substring(filter.length()));
- kbProposal.setImage(getELProposalImage());
-
- kbProposals.add(kbProposal);
- }
- }
- } else if(expr.getType() == ELObjectType.EL_ARGUMENT_INVOCATION) {
- Set<TypeInfoCollector.MemberPresentation> proposalsToFilter = new TreeSet<TypeInfoCollector.MemberPresentation>(TypeInfoCollector.MEMBER_PRESENTATION_COMPARATOR);
- boolean isMessages = false;
- for (TypeInfoCollector.MemberInfo mbr : members) {
- if(isSingularMember(mbr)) {
- isMessages = true;
- filterSingularMember(mbr, proposalsToFilter);
- continue;
- }
- if (mbr.getMemberType() == null) continue;
- try {
- if(TypeInfoCollector.isInstanceofType(mbr.getMemberType(), "java.util.Map")) {
- status.setMapOrCollectionOrBundleAmoungTheTokens();
- //if map/collection is parameterized, we might return member info for value type.
- return;
- }
- } catch (JavaModelException jme) {
- //ignore
- }
- status.setMemberOfResolvedOperand(mbr);
- }
-
- String filter = expr.getMemberName();
- boolean bSurroundWithQuotes = false;
- if(filter == null) {
- filter = "";
- bSurroundWithQuotes = true;
- } else {
- if((filter.startsWith("'") || filter.startsWith("\""))
- && (filter.endsWith("'") || filter.endsWith("\""))) {
- filter = filter.substring(1, filter.length() - 1);
- } else {
- //Value is set as expression itself, we cannot compute it
- if(isMessages) status.setMapOrCollectionOrBundleAmoungTheTokens();
- return;
- }
- }
-
- for (TypeInfoCollector.MemberPresentation proposal : proposalsToFilter) {
- if(returnEqualedVariablesOnly) {
- // This is used for validation.
- if (proposal.getPresentation().equals(filter)) {
- TextProposal kbProposal = new TextProposal();
- kbProposal.setReplacementString(proposal.getPresentation());
-
- setImage(kbProposal, proposal);
-
- kbProposals.add(kbProposal);
-
- status.setMemberOfResolvedOperand(proposal.getMember());
- if(status.getUnpairedGettersOrSetters()!=null) {
- TypeInfoCollector.MethodInfo unpirMethod = status.getUnpairedGettersOrSetters().get(filter);
- status.clearUnpairedGettersOrSetters();
- if(unpirMethod!=null) {
- status.getUnpairedGettersOrSetters().put(filter, unpirMethod);
- }
- }
- break;
- }
- } else if (proposal.getPresentation().startsWith(filter)) {
- // This is used for CA.
- TextProposal kbProposal = new TextProposal();
-
- String replacementString = proposal.getPresentation().substring(filter.length());
- if (bSurroundWithQuotes) {
- replacementString = "'" + replacementString + "']";
- }
-
- kbProposal.setReplacementString(replacementString);
- kbProposal.setImage(getELProposalImage());
-
- kbProposals.add(kbProposal);
- }
- }
- }
- status.setProposals(kbProposals);
- if (status.isOK()){
- status.setLastResolvedToken(expr);
- }
- }
-
- protected boolean isSingularMember(TypeInfoCollector.MemberInfo mbr) {
- return false;
- }
-
- protected void processSingularMember(TypeInfoCollector.MemberInfo mbr, Set<TextProposal> kbProposals) {
- }
-
- protected void filterSingularMember(TypeInfoCollector.MemberInfo mbr, Set<TypeInfoCollector.MemberPresentation> proposalsToFilter) {
- }
-
- protected void setImage(TextProposal kbProposal, TypeInfoCollector.MemberPresentation proposal) {
- kbProposal.setImage(getELProposalImage());
- }
-
- protected void setImage(TextProposal kbProposal, V var) {
- kbProposal.setImage(getELProposalImage());
- }
-
-}
Copied: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/el/AbstractELCompletionEngine.java (from rev 16137, trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/AbstractELCompletionEngine.java)
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/el/AbstractELCompletionEngine.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/el/AbstractELCompletionEngine.java 2009-06-24 21:20:45 UTC (rev 16193)
@@ -0,0 +1,682 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jst.web.kb.el;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.el.core.model.ELArgumentInvocation;
+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.ELInvocationExpression;
+import org.jboss.tools.common.el.core.model.ELMethodInvocation;
+import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.core.model.ELObjectType;
+import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
+import org.jboss.tools.common.el.core.parser.ELParser;
+import org.jboss.tools.common.el.core.parser.LexicalToken;
+import org.jboss.tools.common.el.core.resolver.ELCompletionEngine;
+import org.jboss.tools.common.el.core.resolver.ELContext;
+import org.jboss.tools.common.el.core.resolver.ELOperandResolveStatus;
+import org.jboss.tools.common.el.core.resolver.ELResolver;
+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.text.TextProposal;
+import org.jboss.tools.jst.web.kb.IPageContext;
+
+public abstract class AbstractELCompletionEngine<V extends AbstractELCompletionEngine.IVariable> implements ELResolver, ELCompletionEngine {
+
+ public static interface IVariable {
+ public String getName();
+ }
+
+ public AbstractELCompletionEngine() {}
+
+ public abstract Image getELProposalImage();
+
+ protected abstract void log(Exception e);
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.el.core.resolver.ELResolver#getCompletions(java.lang.String, boolean, int, org.jboss.tools.common.el.core.resolver.ELContext)
+ */
+ public List<TextProposal> getCompletions(String elString, boolean returnEqualedVariablesOnly, int position, ELContext context) {
+ IDocument document = null;
+ if(context instanceof IPageContext) {
+ IPageContext pageContext = (IPageContext)context;
+ document = pageContext.getDocument();
+ }
+ List<Var> vars = new ArrayList<Var>();
+ Var[] array = context.getVars();
+ for (int i = 0; i < array.length; i++) {
+ vars.add(array[i]);
+ }
+ List<TextProposal> proposals = null;
+ try {
+ proposals = getCompletions(context.getResource(), document, elString.subSequence(0, elString.length()), position, returnEqualedVariablesOnly, vars);
+ } catch (StringIndexOutOfBoundsException e) {
+ log(e);
+ } catch (BadLocationException e) {
+ log(e);
+ }
+ return proposals;
+ }
+
+ /**
+ * Create the list of suggestions.
+ * @param seamProject Seam project
+ * @param file File
+ * @param documentContent
+ * @param prefix the prefix to search for
+ * @param position Offset of the prefix
+ * @param vars - 'var' attributes which can be used in this EL. Can be null.
+ * @param returnEqualedVariablesOnly 'false' if we get proposals for mask
+ * for example:
+ * we have 'variableName.variableProperty', 'variableName.variableProperty1', 'variableName.variableProperty2'
+ * prefix is 'variableName.variableProperty'
+ * Result is {'variableProperty'}
+ * if 'false' then returns ends of variables that starts with prefix. It's useful for CA.
+ * for example:
+ * we have 'variableName.variableProperty', 'variableName.variableProperty1', 'variableName.variableProperty2'
+ * prefix is 'variableName.variableProperty'
+ * Result is {'1','2'}
+ * @return the list of all possible suggestions
+ * @throws BadLocationException if accessing the current document fails
+ * @throws StringIndexOutOfBoundsException
+ */
+ public List<TextProposal> getCompletions(IFile file, IDocument document, CharSequence prefix,
+ int position, boolean returnEqualedVariablesOnly, List<Var> vars) throws BadLocationException, StringIndexOutOfBoundsException {
+ List<TextProposal> completions = new ArrayList<TextProposal>();
+
+ ELOperandResolveStatus status = resolveELOperand(file, parseOperand("" + prefix), returnEqualedVariablesOnly, vars, new ElVarSearcher(file, this));
+ if (status.isOK()) {
+ completions.addAll(status.getProposals());
+ }
+
+ return completions;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.el.core.resolver.ELResolver#resolveELOperand(org.jboss.tools.common.el.core.model.ELExpression, org.jboss.tools.common.el.core.resolver.ELContext, boolean)
+ */
+ public ELOperandResolveStatus resolveELOperand(ELExpression operand, ELContext context, boolean returnEqualedVariablesOnly) {
+ List<Var> vars = new ArrayList<Var>();
+ Var[] array = context.getVars();
+ for (int i = 0; i < array.length; i++) {
+ vars.add(array[i]);
+ }
+ ELOperandResolveStatus status = null;
+ try {
+ status = resolveELOperand(context.getResource(), operand, returnEqualedVariablesOnly, vars, new ElVarSearcher(context.getResource(), this));
+ } catch (StringIndexOutOfBoundsException e) {
+ log(e);
+ } catch (BadLocationException e) {
+ log(e);
+ }
+ return status;
+ }
+
+ public ELExpression parseOperand(String operand) {
+ if(operand == null) return null;
+ String el = (operand.indexOf("#{") < 0 && operand.indexOf("${") < 0) ? "#{" + operand + "}" : operand; //$NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
+ ELParser p = getParserFactory().createParser();
+ ELModel model = p.parse(el);
+ List<ELInstance> is = model.getInstances();
+ if(is.isEmpty()) return null;
+ return is.get(0).getExpression();
+ }
+
+ protected static final String collectionAdditionForCollectionDataModel = ".iterator().next()"; //$NON-NLS-1$
+ protected static final String collectionAdditionForMapDataModel = ".entrySet().iterator().next()"; //$NON-NLS-1$
+
+ protected List<String> getVarNameProposals(List <Var> vars, String prefix) {
+ List<String> proposals = new ArrayList<String>();
+ for (Var var : vars) {
+ if(var.getName().startsWith(prefix)) {
+ String proposal = var.getName().substring(prefix.length());
+ proposals.add(proposal);
+ }
+ }
+ return proposals;
+ }
+
+ protected ELOperandResolveStatus newELOperandResolveStatus(ELInvocationExpression tokens) {
+ return new ELOperandResolveStatus(tokens);
+ }
+
+ public ELOperandResolveStatus resolveELOperand(IFile file,
+ ELExpression operand, boolean returnEqualedVariablesOnly,
+ List<Var> vars, ElVarSearcher varSearcher)
+ throws BadLocationException, StringIndexOutOfBoundsException {
+ if(operand == null) {
+ //TODO
+ return newELOperandResolveStatus(null);
+ }
+ String oldEl = operand.getText();
+ Var var = varSearcher.findVarForEl(oldEl, vars, true);
+ String suffix = "";
+ String newEl = oldEl;
+ TypeInfoCollector.MemberInfo member = null;
+ boolean isArray = false;
+ if(var!=null) {
+ member = resolveEL(file, var.getElToken(), true);
+ if(member!=null) {
+ if(!member.getType().isArray()) {
+ IType type = member.getMemberType();
+ if(type!=null) {
+ try {
+ if(TypeInfoCollector.isInstanceofType(type, "java.util.Map")) { //$NON-NLS-1$
+ suffix = collectionAdditionForMapDataModel;
+ } else if(TypeInfoCollector.isInstanceofType(type, "java.util.Collection")) { //$NON-NLS-1$
+ suffix = collectionAdditionForCollectionDataModel;
+ }
+ } catch (JavaModelException e) {
+ log(e);
+ }
+ }
+ } else {
+ isArray = true;
+ }
+ }
+ if(var.getElToken() != null) {
+ newEl = var.getElToken().getText() + suffix + oldEl.substring(var.getName().length());
+ }
+ }
+ boolean prefixWasChanged = !oldEl.equals(newEl);
+ if(prefixWasChanged && isArray) {
+ member.setDataModel(true);
+ }
+ ELExpression newOperand = (prefixWasChanged) ? parseOperand(newEl) : operand;
+
+ ELOperandResolveStatus status = resolveELOperand(file, newOperand, returnEqualedVariablesOnly, prefixWasChanged);
+
+ if(prefixWasChanged) {
+ ELInvocationExpression newLastResolvedToken = status.getLastResolvedToken();
+ status.setTokens((ELInvocationExpression)operand);
+ if(newLastResolvedToken != null) {
+ if(status.getUnresolvedTokens() != null
+ && status.getUnresolvedTokens().getInvocationStartPosition() - status.getUnresolvedTokens().getStartPosition() < var.getElToken().getLength() + suffix.length()) {
+ // Last resolved token is token from "var". Set first token of original EL as last resolved one.
+ status.setLastResolvedToken(null);
+ } else {
+ // Last resolved token is token outside "var" prefix. Correct last resolved token.
+ int oldLastResolvedTokenStart = newLastResolvedToken.getInvocationStartPosition() - var.getElToken().getText().length() - suffix.length() + var.getName().length();
+ if(newLastResolvedToken.getLeft() == null) {
+ //In this case we do not need to take into account difference in length of var and its expression.
+ oldLastResolvedTokenStart = newLastResolvedToken.getInvocationStartPosition();
+ }
+ ELInvocationExpression l = (ELInvocationExpression)operand;
+ while(l != null) {
+ if(l.getInvocationStartPosition() - l.getStartPosition() <= oldLastResolvedTokenStart) {
+ status.setLastResolvedToken(l);
+ break;
+ }
+ l = l.getLeft();
+ }
+ }
+ }
+ }
+
+ if(prefixWasChanged) {
+ var.resolveValue("#{" + var.getElToken().getText() + suffix + "}"); //$NON-NLS-1$ $NON-NLS-2$
+ }
+
+ if(!returnEqualedVariablesOnly && vars!=null) {
+ List<String> varNameProposals = getVarNameProposals(vars, operand.toString());
+ if (varNameProposals != null) {
+ for (String varNameProposal : varNameProposals) {
+ TextProposal proposal = new TextProposal();
+ proposal.setReplacementString(varNameProposal);
+ proposal.setImage(getELProposalImage());
+ status.getProposals().add(proposal);
+ }
+ }
+ }
+ return status;
+ }
+
+
+ /**
+ * Returns MemberInfo for last segment of EL. Null if El is not resolved.
+ * @param seamProject
+ * @param file
+ * @param operand EL without #{}
+ * @return MemberInfo for last segment of EL. Null if El is not resolved.
+ * @throws BadLocationException
+ * @throws StringIndexOutOfBoundsException
+ */
+ public TypeInfoCollector.MemberInfo resolveEL(IFile file, ELExpression operand, boolean varIsUsed) throws BadLocationException, StringIndexOutOfBoundsException {
+ if(!(operand instanceof ELInvocationExpression)) return null;
+ ELOperandResolveStatus status = resolveELOperand(file, operand, true, varIsUsed);
+ return status.getMemberOfResolvedOperand();
+ }
+
+ public ELOperandResolveStatus resolveELOperand(IFile file, ELExpression operand,
+ boolean returnEqualedVariablesOnly, boolean varIsUsed) throws BadLocationException, StringIndexOutOfBoundsException {
+ if(!(operand instanceof ELInvocationExpression) || file == null) {
+ return newELOperandResolveStatus(null);
+ }
+
+ ELInvocationExpression expr = (ELInvocationExpression)operand;
+ boolean isIncomplete = expr.getType() == ELObjectType.EL_PROPERTY_INVOCATION
+ && ((ELPropertyInvocation)expr).getName() == null;
+ boolean isArgument = expr.getType() == ELObjectType.EL_ARGUMENT_INVOCATION;
+
+ ELOperandResolveStatus status = newELOperandResolveStatus(expr);
+ ELInvocationExpression left = expr;
+
+ List<V> resolvedVariables = new ArrayList<V>();
+
+ if (expr.getLeft() != null && isArgument) {
+ left = expr.getLeft();
+ resolvedVariables = resolveVariables(file, left, false,
+ true); // 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);
+ } else {
+ while(left != null) {
+ List<V>resolvedVars = new ArrayList<V>();
+ resolvedVars = resolveVariables(file,
+ left, left == expr,
+ returnEqualedVariablesOnly);
+ if (resolvedVars != null && !resolvedVars.isEmpty()) {
+ resolvedVariables = resolvedVars;
+ status.setLastResolvedToken(left);
+ break;
+ }
+ left = (ELInvocationExpression)left.getLeft();
+ }
+ }
+
+ // Save all resolved variables. It's useful for incremental validation.
+ if(resolvedVariables != null && !resolvedVariables.isEmpty()) {
+ setUsedVariables(status, resolvedVariables);
+ }
+
+ if (status.getResolvedTokens() == null &&
+ !returnEqualedVariablesOnly &&
+ expr != null &&
+ isIncomplete) {
+ // no vars are resolved
+ // the tokens are the part of var name ended with a separator (.)
+ resolvedVariables = resolveVariables(file, expr, true, returnEqualedVariablesOnly);
+ Set<TextProposal> proposals = new TreeSet<TextProposal>(TextProposal.KB_PROPOSAL_ORDER);
+ for (V var : resolvedVariables) {
+ String varName = var.getName();
+ if(varName.startsWith(operand.getText())) {
+ TextProposal proposal = new TextProposal();
+ proposal.setReplacementString(varName.substring(operand.getLength()));
+ setImage(proposal, var);
+ proposals.add(proposal);
+ }
+ }
+ status.setProposals(proposals);
+ return status;
+ }
+
+ // Here we have a list of vars for some part of expression
+ // OK. we'll proceed with members of these vars
+ if (status.getResolvedTokens() == status.getTokens()) {
+ // First segment is the last one
+ Set<TextProposal> proposals = new TreeSet<TextProposal>(TextProposal.KB_PROPOSAL_ORDER);
+ // In some cases there may be a few references to the same variable name.
+ // For example @Factory and @DataModel. We should use @DataModel instead of @Factory
+ // method which returns null.
+ // See https://jira.jboss.org/jira/browse/JBIDE-3694
+ TypeInfoCollector.MemberInfo bijectedAttribute = null;
+ for (V var : resolvedVariables) {
+ if(isSingularAttribute(var)) {
+ bijectedAttribute = getMemberInfoByVariable(var, true);
+ }
+ String varName = var.getName();
+ if(operand.getLength()<=varName.length()) {
+ TextProposal proposal = new TextProposal();
+ proposal.setReplacementString(varName.substring(operand.getLength()));
+ setImage(proposal, var);
+ proposals.add(proposal);
+ } else if(returnEqualedVariablesOnly) {
+ TextProposal proposal = new TextProposal();
+ proposal.setReplacementString(varName);
+ setImage(proposal, var);
+ proposals.add(proposal);
+ }
+ status.setMemberOfResolvedOperand(bijectedAttribute!=null?bijectedAttribute:getMemberInfoByVariable(var, true));
+ }
+ status.setLastResolvedToken(expr);
+ status.setProposals(proposals);
+ return status;
+ }
+
+ // First segment is found - proceed with next tokens
+ List<TypeInfoCollector.MemberInfo> members = new ArrayList<TypeInfoCollector.MemberInfo>();
+ for (V var : resolvedVariables) {
+ TypeInfoCollector.MemberInfo member = getMemberInfoByVariable(var, returnEqualedVariablesOnly);
+ if (member != null && !members.contains(member))
+ members.add(member);
+ }
+ //process segments one by one
+ if(left != null) while(left != expr) {
+ left = (ELInvocationExpression)left.getParent();
+ if (left != expr) { // inside expression
+ if(left instanceof ELArgumentInvocation) {
+ String s = "#{" + left.getLeft().toString() + collectionAdditionForCollectionDataModel + "}"; //$NON-NLS-1$ $NON-NLS-2$
+ ELParser p = getParserFactory().createParser();
+ ELInvocationExpression expr1 = (ELInvocationExpression)p.parse(s).getInstances().get(0).getExpression();
+ members = resolveSegment(expr1.getLeft(), members, status, returnEqualedVariablesOnly, varIsUsed);
+ members = resolveSegment(expr1, members, status, returnEqualedVariablesOnly, varIsUsed);
+ if(status.getLastResolvedToken() == expr1) {
+ status.setLastResolvedToken(left);
+ }
+ } else {
+ members = resolveSegment(left, members, status, returnEqualedVariablesOnly, varIsUsed);
+ }
+ } else { // Last segment
+ resolveLastSegment((ELInvocationExpression)operand, members, status, returnEqualedVariablesOnly, varIsUsed);
+ break;
+ }
+ }
+
+ if(status.getProposals().isEmpty() && status.getUnpairedGettersOrSetters()!=null) {
+ status.clearUnpairedGettersOrSetters();
+ }
+ return status;
+ }
+
+ public List<V> resolveVariables(IFile file, ELInvocationExpression expr, boolean isFinal, boolean onlyEqualNames) {
+ return new ArrayList<V>();
+ }
+
+ protected TypeInfoCollector.MemberInfo getMemberInfoByVariable(V var, boolean onlyEqualNames) {
+ return null;
+ }
+
+ protected void setUsedVariables(ELOperandResolveStatus status, List<V> resolvedVariables) {
+ }
+
+ protected boolean isSingularAttribute(V var) {
+ return false;
+ }
+
+
+ protected List<TypeInfoCollector.MemberInfo> resolveSegment(ELInvocationExpression expr,
+ List<TypeInfoCollector.MemberInfo> members,
+ ELOperandResolveStatus status,
+ boolean returnEqualedVariablesOnly, boolean varIsUsed) {
+ LexicalToken lt = (expr instanceof ELPropertyInvocation)
+ ? ((ELPropertyInvocation)expr).getName()
+ : (expr instanceof ELMethodInvocation)
+ ? ((ELMethodInvocation)expr).getName()
+ : null;
+ String name = lt != null ? lt.getText() : ""; // token.getText(); //$NON-NLS-1$
+ if (expr.getType() == ELObjectType.EL_PROPERTY_INVOCATION) {
+ // Find properties for the token
+ List<TypeInfoCollector.MemberInfo> newMembers = new ArrayList<TypeInfoCollector.MemberInfo>();
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ if (mbr.getMemberType() == null) continue;
+ TypeInfoCollector infos = mbr.getTypeCollector(varIsUsed);
+ if (TypeInfoCollector.isNotParameterizedCollection(mbr) || TypeInfoCollector.isResourceBundle(mbr.getMemberType())) {
+ status.setMapOrCollectionOrBundleAmoungTheTokens();
+ }
+ 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, (propertyName.charAt(0) == 'i' ? 2 : 3));
+ propertyName.setCharAt(0, Character.toLowerCase(propertyName.charAt(0)));
+ }
+ if (name.equals(propertyName.toString())) {
+ newMembers.add(property);
+ }
+ }
+ }
+ members = newMembers;
+ if (members != null && !members.isEmpty())
+ status.setLastResolvedToken(expr);
+ }
+ if (expr.getType() == ELObjectType.EL_METHOD_INVOCATION) {
+ // Find methods for the token
+ if (name.indexOf('(') != -1) {
+ name = name.substring(0, name.indexOf('('));
+ }
+ List<TypeInfoCollector.MemberInfo> newMembers = new ArrayList<TypeInfoCollector.MemberInfo>();
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ if (mbr.getMemberType() == null) continue;
+ TypeInfoCollector infos = mbr.getTypeCollector();
+ if (TypeInfoCollector.isNotParameterizedCollection(mbr) || TypeInfoCollector.isResourceBundle(mbr.getMemberType())) {
+ status.setMapOrCollectionOrBundleAmoungTheTokens();
+ }
+ List<TypeInfoCollector.MemberInfo> methods = infos.getMethods();
+ for (TypeInfoCollector.MemberInfo method : methods) {
+ if (name.equals(method.getName())) {
+ newMembers.add(method);
+ }
+ }
+ }
+ members = newMembers;
+ if (members != null && !members.isEmpty())
+ status.setLastResolvedToken(expr);
+ }
+ return members;
+ }
+
+ protected void resolveLastSegment(ELInvocationExpression expr,
+ List<TypeInfoCollector.MemberInfo> members,
+ ELOperandResolveStatus status,
+ boolean returnEqualedVariablesOnly, boolean varIsUsed) {
+ Set<TextProposal> kbProposals = new TreeSet<TextProposal>(TextProposal.KB_PROPOSAL_ORDER);
+
+ if (expr.getType() == ELObjectType.EL_PROPERTY_INVOCATION && ((ELPropertyInvocation)expr).getName() == null) {
+ // return all the methods + properties
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ if(isSingularMember(mbr)) {
+ processSingularMember(mbr, kbProposals);
+ continue;
+ }
+ if (mbr.getMemberType() == null) {
+ continue;
+ }
+ TypeInfoCollector infos = mbr.getTypeCollector(varIsUsed);
+ if (TypeInfoCollector.isNotParameterizedCollection(mbr) || TypeInfoCollector.isResourceBundle(mbr.getMemberType())) {
+ status.setMapOrCollectionOrBundleAmoungTheTokens();
+ }
+
+ Set<String> methodPresentations =
+ infos.getMethodPresentationStrings();
+ if (methodPresentations != null) {
+ for (String presentation : methodPresentations) {
+ TextProposal proposal = new TextProposal();
+ proposal.setReplacementString(presentation);
+ proposal.setImage(getELProposalImage());
+
+ kbProposals.add(proposal);
+ }
+ }
+ Set<String> propertyPresentations =
+ infos.getPropertyPresentationStrings(status.getUnpairedGettersOrSetters());
+ if (propertyPresentations != null) {
+ for (String presentation : propertyPresentations) {
+ TextProposal proposal = new TextProposal();
+ proposal.setReplacementString(presentation);
+ proposal.setImage(getELProposalImage());
+
+ kbProposals.add(proposal);
+ }
+ }
+ }
+ } else
+ if(expr.getType() != ELObjectType.EL_ARGUMENT_INVOCATION)
+ //actually any case
+// 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
+ Set<TypeInfoCollector.MemberPresentation> proposalsToFilter = new TreeSet<TypeInfoCollector.MemberPresentation>(TypeInfoCollector.MEMBER_PRESENTATION_COMPARATOR);
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ if(isSingularMember(mbr)) {
+ filterSingularMember(mbr, proposalsToFilter);
+ continue;
+ }
+ if (mbr.getMemberType() == null) continue;
+ TypeInfoCollector infos = mbr.getTypeCollector();
+ if (TypeInfoCollector.isNotParameterizedCollection(mbr) || TypeInfoCollector.isResourceBundle(mbr.getMemberType())) {
+ status.setMapOrCollectionOrBundleAmoungTheTokens();
+ }
+ proposalsToFilter.addAll(infos.getMethodPresentations());
+ proposalsToFilter.addAll(infos.getPropertyPresentations(status.getUnpairedGettersOrSetters()));
+ status.setMemberOfResolvedOperand(mbr);
+ }
+ for (TypeInfoCollector.MemberPresentation proposal : proposalsToFilter) {
+ // We do expect nothing but name for method tokens (No round brackets)
+ String filter = expr.getMemberName();
+ if(filter == null) filter = "";
+ if(returnEqualedVariablesOnly) {
+ // This is used for validation.
+ if (proposal.getPresentation().equals(filter)) {
+ TextProposal kbProposal = new TextProposal();
+ kbProposal.setReplacementString(proposal.getPresentation());
+
+ setImage(kbProposal, proposal);
+
+ kbProposals.add(kbProposal);
+
+ status.setMemberOfResolvedOperand(proposal.getMember());
+ if(status.getUnpairedGettersOrSetters()!=null) {
+ TypeInfoCollector.MethodInfo unpirMethod = status.getUnpairedGettersOrSetters().get(filter);
+ status.clearUnpairedGettersOrSetters();
+ if(unpirMethod!=null) {
+ status.getUnpairedGettersOrSetters().put(filter, unpirMethod);
+ }
+ }
+ break;
+ }
+ } else if (proposal.getPresentation().startsWith(filter)) {
+ // This is used for CA.
+ TextProposal kbProposal = new TextProposal();
+ kbProposal.setReplacementString(proposal.getPresentation().substring(filter.length()));
+ kbProposal.setImage(getELProposalImage());
+
+ kbProposals.add(kbProposal);
+ }
+ }
+ } else if(expr.getType() == ELObjectType.EL_ARGUMENT_INVOCATION) {
+ Set<TypeInfoCollector.MemberPresentation> proposalsToFilter = new TreeSet<TypeInfoCollector.MemberPresentation>(TypeInfoCollector.MEMBER_PRESENTATION_COMPARATOR);
+ boolean isMessages = false;
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ if(isSingularMember(mbr)) {
+ isMessages = true;
+ filterSingularMember(mbr, proposalsToFilter);
+ continue;
+ }
+ if (mbr.getMemberType() == null) continue;
+ try {
+ if(TypeInfoCollector.isInstanceofType(mbr.getMemberType(), "java.util.Map")) { //$NON-NLS-1$
+ status.setMapOrCollectionOrBundleAmoungTheTokens();
+ //if map/collection is parameterized, we might return member info for value type.
+ return;
+ }
+ } catch (JavaModelException jme) {
+ //ignore
+ }
+ status.setMemberOfResolvedOperand(mbr);
+ }
+
+ String filter = expr.getMemberName();
+ boolean bSurroundWithQuotes = false;
+ if(filter == null) {
+ filter = "";
+ bSurroundWithQuotes = true;
+ } else {
+ if((filter.startsWith("'") || filter.startsWith("\""))
+ && (filter.endsWith("'") || filter.endsWith("\""))) {
+ filter = filter.substring(1, filter.length() - 1);
+ } else {
+ //Value is set as expression itself, we cannot compute it
+ if(isMessages) status.setMapOrCollectionOrBundleAmoungTheTokens();
+ return;
+ }
+ }
+
+ for (TypeInfoCollector.MemberPresentation proposal : proposalsToFilter) {
+ if(returnEqualedVariablesOnly) {
+ // This is used for validation.
+ if (proposal.getPresentation().equals(filter)) {
+ TextProposal kbProposal = new TextProposal();
+ kbProposal.setReplacementString(proposal.getPresentation());
+
+ setImage(kbProposal, proposal);
+
+ kbProposals.add(kbProposal);
+
+ status.setMemberOfResolvedOperand(proposal.getMember());
+ if(status.getUnpairedGettersOrSetters()!=null) {
+ TypeInfoCollector.MethodInfo unpirMethod = status.getUnpairedGettersOrSetters().get(filter);
+ status.clearUnpairedGettersOrSetters();
+ if(unpirMethod!=null) {
+ status.getUnpairedGettersOrSetters().put(filter, unpirMethod);
+ }
+ }
+ break;
+ }
+ } else if (proposal.getPresentation().startsWith(filter)) {
+ // This is used for CA.
+ TextProposal kbProposal = new TextProposal();
+
+ String replacementString = proposal.getPresentation().substring(filter.length());
+ if (bSurroundWithQuotes) {
+ replacementString = "'" + replacementString + "']";
+ }
+
+ kbProposal.setReplacementString(replacementString);
+ kbProposal.setImage(getELProposalImage());
+
+ kbProposals.add(kbProposal);
+ }
+ }
+ }
+ status.setProposals(kbProposals);
+ if (status.isOK()){
+ status.setLastResolvedToken(expr);
+ }
+ }
+
+ protected boolean isSingularMember(TypeInfoCollector.MemberInfo mbr) {
+ return false;
+ }
+
+ protected void processSingularMember(TypeInfoCollector.MemberInfo mbr, Set<TextProposal> kbProposals) {
+ }
+
+ protected void filterSingularMember(TypeInfoCollector.MemberInfo mbr, Set<TypeInfoCollector.MemberPresentation> proposalsToFilter) {
+ }
+
+ protected void setImage(TextProposal kbProposal, TypeInfoCollector.MemberPresentation proposal) {
+ kbProposal.setImage(getELProposalImage());
+ }
+
+ protected void setImage(TextProposal kbProposal, V var) {
+ kbProposal.setImage(getELProposalImage());
+ }
+
+}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-06-24 21:15:23 UTC (rev 16192)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-06-24 21:20:45 UTC (rev 16193)
@@ -31,8 +31,6 @@
protected Map<IRegion, Map<String, INameSpace>> nameSpaces = new HashMap<IRegion, Map<String, INameSpace>>();
protected IResourceBundle[] bundles;
-
-
/*
* (non-Javadoc)
* @see org.jboss.tools.common.kb.text.PageContext#getLibraries()
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java 2009-06-24 21:15:23 UTC (rev 16192)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java 2009-06-24 21:20:45 UTC (rev 16193)
@@ -115,24 +115,6 @@
* @see org.jboss.tools.jst.web.kb.IProposalProcessor#getProposals(org.jboss.tools.jst.web.kb.KbQuery, org.jboss.tools.jst.web.kb.IPageContext)
*/
public TextProposal[] getProposals(KbQuery query, IPageContext context) {
- List<TextProposal> proposals = null;
-// ELResolver[] resolvers = context.getElResolvers();
-// for (int i = 0; i < resolvers.length; i++) {
-// List<TextProposal> list = resolvers[i].getCompletions(query.getValue(), false, query.getValue().length(), context);
-// if(list == null || list.isEmpty()) continue;
-// if(proposals == null) {
-// proposals = new ArrayList<TextProposal>();
-// }
-// for (TextProposal textProposal : list) {
-// textProposal.setSource(this);
-// proposals.add(textProposal);
-// }
-// }
-// if(proposals == null || proposals.isEmpty()) {
-// return EMPTY_PROPOSAL_LIST;
-// }
-// return proposals.toArray(new TextProposal[proposals.size()]);
- // TODO
return EMPTY_PROPOSAL_LIST;
}
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ActionProposalType.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ActionProposalType.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ActionProposalType.java 2009-06-24 21:20:45 UTC (rev 16193)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.jst.web.kb.internal.taglib;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+import org.jboss.tools.jst.web.project.list.IWebPromptingProvider;
+import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class ActionProposalType extends ModelProposalType {
+
+ private static final String IMAGE_NAME = "JSFActionProposal.gif"; //$NON-NLS-1$
+ private static Image ICON;
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
+ */
+ @Override
+ public TextProposal[] getProposals(KbQuery query) {
+ List<TextProposal> proposals = new ArrayList<TextProposal>();
+ if (!isReadyToUse()) {
+ return EMPTY_PROPOSAL_LIST;
+ }
+ Properties view = new Properties();
+ view.put(IWebPromptingProvider.VIEW_PATH, context.getResource().getLocation());
+ List<Object> sourceList = provider.getList(xModel, WebPromptingProvider.JSF_VIEW_ACTIONS, "", view);
+ if (sourceList != null && !sourceList.isEmpty()) {
+ Set<String> sorted = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+ Iterator<Object> it = sourceList.iterator();
+ while(it.hasNext()) {
+ sorted.add(it.next().toString());
+ }
+ for (String text : sorted) {
+ if (text.trim().length() > 0 && text.toLowerCase().startsWith(query.getValue().toLowerCase())) {
+ TextProposal proposal = new TextProposal();
+ proposal.setLabel(text);
+ proposal.setReplacementString(text);
+ proposal.setPosition(text.length());
+ if(ICON==null) {
+ ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
+ }
+ proposal.setImage(ICON);
+ proposals.add(proposal);
+ }
+ }
+ }
+ return proposals.toArray(new TextProposal[0]);
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ActionProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalType.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalType.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalType.java 2009-06-24 21:20:45 UTC (rev 16193)
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.jst.web.kb.internal.taglib;
+
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.IProposalProcessor;
+import org.jboss.tools.jst.web.kb.KbQuery;
+
+/**
+ * @author Alexey Kazakov
+ */
+public abstract class CustomProposalType implements IProposalProcessor {
+
+ protected Param[] params;
+ protected String type;
+ protected IPageContext context;
+
+ protected abstract void init(IPageContext context);
+
+ /**
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * @return the params
+ */
+ public Param[] getParams() {
+ if(params==null) {
+ params = new Param[0];
+ }
+ return params;
+ }
+
+ /**
+ * @param params the params to set
+ */
+ public void setParams(Param[] params) {
+ this.params = params;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.IProposalProcessor#getProposals(org.jboss.tools.jst.web.kb.KbQuery, org.jboss.tools.jst.web.kb.IPageContext)
+ */
+ public TextProposal[] getProposals(KbQuery query, IPageContext context) {
+ this.context = context;
+ init(context);
+ return getProposals(query);
+ }
+
+ /**
+ * @param name
+ * @return
+ */
+ public String getParamValue(String name) {
+ if(params==null) {
+ return null;
+ }
+ for (int i = 0; i < params.length; i++) {
+ if(name.equals(params[i].getName())) {
+ return params[i].getValue();
+ }
+ }
+ return null;
+ }
+
+ abstract public TextProposal[] getProposals(KbQuery query);
+
+ public static class Param {
+
+ private String name;
+ private String value;
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the value
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * @param value the value to set
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalTypeFactory.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalTypeFactory.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalTypeFactory.java 2009-06-24 21:20:45 UTC (rev 16193)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.jst.web.kb.internal.taglib;
+
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class CustomProposalTypeFactory {
+
+ private static final CustomProposalTypeFactory INSTANCE = new CustomProposalTypeFactory();
+
+ public static final String RESOURCE_BUNDLE_NAME_TYPE = "bundleName"; //$NON-NLS-1$
+ public static final String ACTION_TYPE = "viewActions"; //$NON-NLS-1$
+ public static final String RESOURCE_PATH_TYPE = "file"; //$NON-NLS-1$
+ public static final String ENUMERATION_TYPE = "enumeration"; //$NON-NLS-1$
+ public static final String FACELETS_JSFC_TYPE = "faceletsJsfCTags"; //$NON-NLS-1$
+ public static final String NAME_SPACE_TYPE = "taglib"; //$NON-NLS-1$
+
+ private CustomProposalTypeFactory() {
+ }
+
+ /**
+ * @return an instance of this factory.
+ */
+ public static CustomProposalTypeFactory getInstance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Creates Custom Proposal Type by name
+ * @param type
+ * @return
+ */
+ public CustomProposalType createProposalType(String type) {
+ if(RESOURCE_BUNDLE_NAME_TYPE.equals(type)) {
+ return new ResourceBundleNameProposalType();
+ }
+ if(ACTION_TYPE.equals(type)) {
+ return new ActionProposalType();
+ }
+ if(RESOURCE_PATH_TYPE.equals(type)) {
+ return new ResourcePathProposalType();
+ }
+ if(ENUMERATION_TYPE.equals(type)) {
+ return new EnumerationProposalType();
+ }
+ if(FACELETS_JSFC_TYPE.equals(type)) {
+ return new FaceletsJsfCProposalType();
+ }
+ if(NAME_SPACE_TYPE.equals(type)) {
+ return new NameSpaceProposalType();
+ }
+ WebKbPlugin.getDefault().logError("Unknown proposal type: " + type); //$NON-NLS-1$
+ return null;
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalTypeFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibAttribute.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibAttribute.java 2009-06-24 21:15:23 UTC (rev 16192)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibAttribute.java 2009-06-24 21:20:45 UTC (rev 16193)
@@ -27,7 +27,7 @@
protected boolean extended = true;
protected String defaultValue;
- protected Proposal[] proposals;
+ protected CustomProposalType[] proposals;
protected CustomTagLibComponent parentComponent;
/*
@@ -68,9 +68,9 @@
*/
@Override
public TextProposal[] getProposals(KbQuery query, IPageContext context) {
- Proposal[] prDefs = getProposals();
+ CustomProposalType[] types = getProposals();
List<TextProposal> proposals = new ArrayList<TextProposal>();
- for (int i = 0; i < prDefs.length; i++) {
+ for (int i = 0; i < types.length; i++) {
// TODO
}
return proposals.toArray(new TextProposal[0]);
@@ -79,9 +79,9 @@
/**
* @return the proposals
*/
- public Proposal[] getProposals() {
+ public CustomProposalType[] getProposals() {
if(proposals==null) {
- proposals = new Proposal[0];
+ proposals = new CustomProposalType[0];
}
return proposals;
}
@@ -89,84 +89,10 @@
/**
* @param proposals the proposals to set
*/
- public void setProposals(Proposal[] proposals) {
+ public void setProposals(CustomProposalType[] proposals) {
this.proposals = proposals;
}
- /**
- * @author Alexey Kazakov
- */
- public static class Proposal {
-
- private Param[] params;
- private String type;
-
- /**
- * @return the type
- */
- public String getType() {
- return type;
- }
-
- /**
- * @param type the type to set
- */
- public void setType(String type) {
- this.type = type;
- }
-
- /**
- * @return the params
- */
- public Param[] getParams() {
- if(params==null) {
- params = new Param[0];
- }
- return params;
- }
-
- /**
- * @param params the params to set
- */
- public void setParams(Param[] params) {
- this.params = params;
- }
- }
-
- public static class Param {
-
- private String name;
- private String value;
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return the value
- */
- public String getValue() {
- return value;
- }
-
- /**
- * @param value the value to set
- */
- public void setValue(String value) {
- this.value = value;
- }
- }
-
/*
* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.taglib.IAttribute#getComponent()
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibrary.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibrary.java 2009-06-24 21:15:23 UTC (rev 16192)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibrary.java 2009-06-24 21:20:45 UTC (rev 16193)
@@ -149,32 +149,34 @@
newAttributes.add(newAttribute);
// Extract proposals
- List<CustomTagLibAttribute.Proposal> newProposals = new ArrayList<CustomTagLibAttribute.Proposal>();
+ List<CustomProposalType> newProposals = new ArrayList<CustomProposalType>();
NodeList proposals = attribute.getElementsByTagName(PROPOSAL);
for (int j = 0; j < proposals.getLength(); j++) {
Element proposal = (Element)proposals.item(j);
String type = proposal.getAttribute(TYPE);
- CustomTagLibAttribute.Proposal newProposal = new CustomTagLibAttribute.Proposal();
- newProposal.setType(type);
- newProposals.add(newProposal);
+ CustomProposalType newProposal = CustomProposalTypeFactory.getInstance().createProposalType(type);
+ if(newProposal!=null) {
+ newProposal.setType(type);
+ newProposals.add(newProposal);
- List<CustomTagLibAttribute.Param> newParams = new ArrayList<CustomTagLibAttribute.Param>();
- // Extract params
- NodeList params = proposal.getElementsByTagName(PARAM);
- for (int c = 0; c < params.getLength(); c++) {
- Element param = (Element)params.item(c);
- String paramName = param.getAttribute(NAME);
- String paramValue = param.getAttribute(VALUE);
- CustomTagLibAttribute.Param newParam = new CustomTagLibAttribute.Param();
- if(paramName!=null && paramName.length()>0) {
- newParam.setName(paramName);
+ List<CustomProposalType.Param> newParams = new ArrayList<CustomProposalType.Param>();
+ // Extract params
+ NodeList params = proposal.getElementsByTagName(PARAM);
+ for (int c = 0; c < params.getLength(); c++) {
+ Element param = (Element)params.item(c);
+ String paramName = param.getAttribute(NAME);
+ String paramValue = param.getAttribute(VALUE);
+ CustomProposalType.Param newParam = new CustomProposalType.Param();
+ if(paramName!=null && paramName.length()>0) {
+ newParam.setName(paramName);
+ }
+ newParam.setValue(paramValue);
+ newParams.add(newParam);
}
- newParam.setValue(paramValue);
- newParams.add(newParam);
+ newProposal.setParams(newParams.toArray(new CustomProposalType.Param[0]));
}
- newProposal.setParams(newParams.toArray(new CustomTagLibAttribute.Param[0]));
}
- newAttribute.setProposals(newProposals.toArray(new CustomTagLibAttribute.Proposal[0]));
+ newAttribute.setProposals(newProposals.toArray(new CustomProposalType[0]));
}
}
}
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EnumerationProposalType.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EnumerationProposalType.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EnumerationProposalType.java 2009-06-24 21:20:45 UTC (rev 16193)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.jst.web.kb.internal.taglib;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class EnumerationProposalType extends CustomProposalType {
+
+ private static final String IMAGE_NAME = "EnumerationProposal.gif"; //$NON-NLS-1$
+ private static Image ICON;
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
+ */
+ @Override
+ public TextProposal[] getProposals(KbQuery query) {
+ if(params==null) {
+ return EMPTY_PROPOSAL_LIST;
+ }
+ List<TextProposal> proposals = new ArrayList<TextProposal>();
+ for (int i = 0; i < params.length; i++) {
+ String text = params[i].getValue();
+ TextProposal proposal = new TextProposal();
+ proposal.setLabel(text);
+ proposal.setReplacementString(text);
+ proposal.setPosition(text.length());
+ if(ICON==null) {
+ ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
+ }
+ proposals.add(proposal);
+ }
+ return proposals.toArray(new TextProposal[0]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
+ */
+ @Override
+ protected void init(IPageContext context) {
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EnumerationProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletsJsfCProposalType.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletsJsfCProposalType.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletsJsfCProposalType.java 2009-06-24 21:20:45 UTC (rev 16193)
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.jst.web.kb.internal.taglib;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.PageProcessor;
+import org.jboss.tools.jst.web.kb.taglib.CustomTagLibManager;
+import org.jboss.tools.jst.web.kb.taglib.IComponent;
+import org.jboss.tools.jst.web.kb.taglib.INameSpace;
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class FaceletsJsfCProposalType extends CustomProposalType {
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
+ */
+ @Override
+ public TextProposal[] getProposals(KbQuery query) {
+ // trim first spaces
+ String value = query.getValue();
+ while(true) {
+ if(value.startsWith(" ")) {
+ value = value.substring(1);
+ } else {
+ break;
+ }
+ }
+ KbQuery kbQuery = new KbQuery();
+ kbQuery.setMask(query.isMask());
+ kbQuery.setType(KbQuery.Type.TAG_NAME);
+ kbQuery.setValue(query.getValue());
+ kbQuery.setOffset(query.getOffset());
+
+ IComponent[] components = null;
+ List<TextProposal> proposals = null;
+ components = PageProcessor.getInstance().getComponents(kbQuery, context);
+ if(components.length==0) {
+ return EMPTY_PROPOSAL_LIST;
+ }
+ proposals = new ArrayList<TextProposal>();
+ Map<String, String> prefixes = new HashMap<String, String>();
+ for (int i = 0; i < components.length; i++) {
+ ITagLibrary lib = components[i].getTagLib();
+ if(ignoreTagLib(lib)) {
+ continue;
+ }
+ String prefix = prefixes.get(lib.getURI());
+ if(prefix==null) {
+ prefix = getPrefix(context, components[i], kbQuery);
+ prefixes.put(lib.getURI(), prefix);
+ }
+ TextProposal proposal = getProposal(prefix, components[i]);
+ proposals.add(proposal);
+ }
+ return proposals.toArray(new TextProposal[0]);
+ }
+
+ private boolean ignoreTagLib(ITagLibrary lib) {
+ return CustomTagLibManager.FACELETS_UI_TAG_LIB_URI.equals(lib.getURI()) || CustomTagLibManager.FACELETS_HTML_TAG_LIB_URI.equals(lib.getURI());
+ }
+
+ private TextProposal getProposal(String prefix, IComponent component) {
+ TextProposal proposal = new TextProposal();
+ proposal.setContextInfo(component.getDescription());
+ proposal.setSource(component);
+ StringBuffer label = new StringBuffer();
+ label.append(prefix + KbQuery.PREFIX_SEPARATOR);
+ label.append(component.getName());
+ proposal.setLabel(label.toString());
+ proposal.setReplacementString(proposal.getLabel());
+ int position = proposal.getReplacementString().length();
+ proposal.setPosition(position);
+ return proposal;
+ }
+
+ private String getPrefix(IPageContext context, IComponent component, KbQuery query) {
+ String prefix = null;
+ Map<String, INameSpace> nameSpaces = context.getNameSpaces(query.getOffset());
+ if(nameSpaces!=null) {
+ INameSpace nameSpace = nameSpaces.get(component.getTagLib().getURI());
+ if(nameSpace!=null) {
+ prefix = nameSpace.getPrefix();
+ }
+ }
+ return prefix;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
+ */
+ @Override
+ protected void init(IPageContext context) {
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletsJsfCProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ModelProposalType.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ModelProposalType.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ModelProposalType.java 2009-06-24 21:20:45 UTC (rev 16193)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.jst.web.kb.internal.taglib;
+
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.project.IModelNature;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
+
+/**
+ * @author Alexey Kazakov
+ */
+public abstract class ModelProposalType extends CustomProposalType {
+
+ protected WebPromptingProvider provider;
+ protected XModel xModel;
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
+ */
+ @Override
+ protected void init(IPageContext context) {
+ provider = WebPromptingProvider.getInstance();
+ IModelNature nature = EclipseResourceUtil.getModelNature(context.getResource().getProject());
+ if(nature!=null) {
+ xModel = nature.getModel();
+ }
+ }
+
+ protected boolean isReadyToUse() {
+ return (provider != null && xModel != null);
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ModelProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpaceProposalType.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpaceProposalType.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpaceProposalType.java 2009-06-24 21:20:45 UTC (rev 16193)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.jst.web.kb.internal.taglib;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class NameSpaceProposalType extends ModelProposalType {
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
+ */
+ @Override
+ public TextProposal[] getProposals(KbQuery query) {
+ List<TextProposal> proposals = new ArrayList<TextProposal>();
+ if (!isReadyToUse()) {
+ return EMPTY_PROPOSAL_LIST;
+ }
+ String rQuery = getPassiveQueryPart(query.getValue());
+ Set<String> sorted = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+ List<Object> beanList = provider.getList(xModel, WebPromptingProvider.JSF_GET_TAGLIBS, "", null);
+ Iterator<Object> itr = beanList.iterator();
+ while (itr.hasNext()) {
+ sorted.add(itr.next().toString());
+ }
+ for (String text : sorted) {
+ if(rQuery.length() == 0 || text.startsWith(rQuery)) {
+ TextProposal proposal = new TextProposal();
+ proposal.setLabel(text);
+ proposal.setReplacementString(text);
+ proposals.add(proposal);
+ proposal.setPosition(proposal.getReplacementString().length());
+ }
+ }
+ return proposals.toArray(new TextProposal[0]);
+ }
+
+ private String getPassiveQueryPart(String query) {
+ if (query == null || query.trim().length() == 0) {
+ return "";
+ }
+ return query;
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpaceProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourceBundleNameProposalType.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourceBundleNameProposalType.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourceBundleNameProposalType.java 2009-06-24 21:20:45 UTC (rev 16193)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.jst.web.kb.internal.taglib;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class ResourceBundleNameProposalType extends ModelProposalType {
+
+ private static final String IMAGE_NAME = "MessageBundleProposal.gif"; //$NON-NLS-1$
+ private static Image ICON;
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
+ */
+ @Override
+ public TextProposal[] getProposals(KbQuery query) {
+ List<TextProposal> proposals = new ArrayList<TextProposal>();
+ if (!isReadyToUse()) {
+ return EMPTY_PROPOSAL_LIST;
+ }
+ List<Object> sourceList = provider.getList(xModel, WebPromptingProvider.JSF_BUNDLES, "", null);
+ if (sourceList != null && !sourceList.isEmpty()) {
+ Set<String> sorted = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+ Iterator<Object> it = sourceList.iterator();
+ while(it.hasNext()) {
+ sorted.add(it.next().toString());
+ }
+ for (String text : sorted) {
+ if (text.toLowerCase().startsWith(query.getValue().toLowerCase())) {
+ TextProposal proposal = new TextProposal();
+ proposal.setLabel(text);
+ proposal.setReplacementString(text);
+ proposal.setPosition(text.length());
+ if(ICON==null) {
+ ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
+ }
+ proposal.setImage(ICON);
+ proposals.add(proposal);
+ }
+ }
+ }
+ return proposals.toArray(new TextProposal[0]);
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourceBundleNameProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourcePathProposalType.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourcePathProposalType.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourcePathProposalType.java 2009-06-24 21:20:45 UTC (rev 16193)
@@ -0,0 +1,275 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.jst.web.kb.internal.taglib;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class ResourcePathProposalType extends ModelProposalType {
+
+ private static final String IMAGE_NAME = "ResourcePathProposal.gif"; //$NON-NLS-1$
+ private static Image ICON;
+ private static Set<String> GRAPHIC_FILE_EXTENSIONS = new HashSet<String>();
+ private static Set<String> PAGE_FILE_EXTENSIONS = new HashSet<String>();
+ static {
+ String[] images = {"gif", "jpeg", "jpg", "png", "wbmp", "bmp"};
+ for (int i = 0; i < images.length; i++) {
+ GRAPHIC_FILE_EXTENSIONS.add(images[i]);
+ }
+ String[] pages = {"jsp", "htm", "html", "xhtml", "xml"};
+ for (int i = 0; i < pages.length; i++) {
+ PAGE_FILE_EXTENSIONS.add(pages[i]);
+ }
+ }
+
+ private IContainer webRootResource;
+ private Set<String> extensions;
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.taglib.ModelProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
+ */
+ @Override
+ protected void init(IPageContext context) {
+ super.init(context);
+ if(xModel != null) {
+ XModelObject webInf = FileSystemsHelper.getWebInf(xModel);
+ XModelObject webRoot = FileSystemsHelper.getWebRoot(xModel);
+ if(webInf != null && webRoot != null) {
+ webRootResource = (IContainer)EclipseResourceUtil.getResource(webRoot);
+ }
+ }
+ if(extensions==null) {
+ initExtensions();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
+ */
+ @Override
+ public TextProposal[] getProposals(KbQuery query) {
+ if(!isReadyToUse()) {
+ return EMPTY_PROPOSAL_LIST;
+ }
+ List<TextProposal> proposals = new ArrayList<TextProposal>();
+ ImagePathDescriptor[] images = getImagesFilesPathes(query.getValue());
+ for(int i=0; i<images.length; i++) {
+ TextProposal proposal = new TextProposal();
+ proposal.setLabel(images[i].getQueryPath());
+ String replacementString = images[i].getQueryPath();
+ if(images[i].getResource() instanceof IFolder) {
+ replacementString = replacementString + "/";
+ proposal.setAutoActivationContentAssistantAfterApplication(true);
+ }
+ proposal.setReplacementString(replacementString);
+ proposal.setPosition(replacementString.length());
+ if(ICON==null) {
+ ICON = ImageDescriptor.createFromFile(WebKbPlugin.class, IMAGE_NAME).createImage();
+ }
+ proposal.setImage(ICON);
+ proposals.add(proposal);
+ }
+ return proposals.toArray(new TextProposal[0]);
+ }
+
+ private static final String EXTENSIONS_PARAM_NAME = "extensions"; //$NON-NLS-1$
+ private static final String IMAGE_PARAM_TYPE = "%image%"; //$NON-NLS-1$
+ private static final String PAGE_PARAM_TYPE = "%page%"; //$NON-NLS-1$
+
+ private void initExtensions() {
+ String value = getParamValue(EXTENSIONS_PARAM_NAME);
+ if(value != null && !value.equals("*")) {
+ if(IMAGE_PARAM_TYPE.equals(value)) {
+ this.extensions = GRAPHIC_FILE_EXTENSIONS;
+ } else if("%page%".equals(value)) {
+ this.extensions = PAGE_FILE_EXTENSIONS;
+ } else {
+ StringTokenizer st = new StringTokenizer(value, ",;");
+ if(st.countTokens() > 0) {
+ extensions = new HashSet<String>();
+ while(st.hasMoreTokens()) {
+ String t = st.nextToken().trim();
+ if(t.length() == 0) {
+ continue;
+ }
+ if(IMAGE_PARAM_TYPE.equals(t)) {
+ extensions.addAll(GRAPHIC_FILE_EXTENSIONS);
+ } else if(PAGE_PARAM_TYPE.equals(t)) {
+ extensions.addAll(PAGE_FILE_EXTENSIONS);
+ } else {
+ extensions.add(t);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.internal.taglib.ModelProposalType#isReadyToUse()
+ */
+ protected boolean isReadyToUse() {
+ return webRootResource!=null;
+ }
+
+ private ImagePathDescriptor[] getImagesFilesPathes(String query) {
+ query = query.trim();
+ if(query.indexOf('\\')>-1) {
+ return new ImagePathDescriptor[0];
+ }
+ if(query.length()==0) {
+ query = "/";
+ }
+ int lastSeparator = query.lastIndexOf('/');
+ String name = null;
+ String pathWithoutLastSegment = null;
+ if(lastSeparator>-1) {
+ pathWithoutLastSegment = query.substring(0, lastSeparator);
+ if(lastSeparator+1<query.length()) {
+ name = query.substring(lastSeparator+1, query.length());
+ } else {
+ name = "";
+ }
+ } else {
+ pathWithoutLastSegment = "";
+ name = query;
+ }
+ if(name.equals(".") || name.equals("..")) {
+ if(pathWithoutLastSegment.length()>0) {
+ pathWithoutLastSegment = pathWithoutLastSegment + "/" + name;
+ } else {
+ if(query.startsWith("/")) {
+ pathWithoutLastSegment = "/" + name;
+ } else {
+ pathWithoutLastSegment = name;
+ }
+ }
+ name = "";
+ }
+ if(name==null) {
+ name = "";
+ }
+ IResource resource;
+ String startPath = pathWithoutLastSegment;
+ if(pathWithoutLastSegment.startsWith("/")) {
+ if(pathWithoutLastSegment.length()>1) {
+ startPath = pathWithoutLastSegment.substring(1);
+ } else {
+ startPath = "";
+ }
+ }
+ if(query.startsWith("/")) {
+ resource = webRootResource.findMember(startPath);
+ } else {
+ resource = context.getResource().getParent().findMember(startPath);
+ }
+
+ List<IResource> resources = new ArrayList<IResource>();
+ try {
+ if(resource != null) resource.accept(new ImagesFinder(resources, name, extensions));
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(e);
+ }
+ ImagePathDescriptor[] filesPathes = new ImagePathDescriptor[resources.size()];
+ for(int i=0; i<filesPathes.length; i++) {
+ String prefix = pathWithoutLastSegment.toString();
+ if(!prefix.endsWith("/")) {
+ prefix = prefix + '/';
+ }
+ IResource r = (IResource)resources.get(i);
+ filesPathes[i] = new ImagePathDescriptor(prefix + r.getName(), r);
+ }
+ return filesPathes;
+ }
+
+ private static class ImagePathDescriptor {
+ private String queryPath;
+ private IResource resource;
+
+ public ImagePathDescriptor(String queryPath, IResource resource) {
+ this.queryPath = queryPath;
+ this.resource = resource;
+ }
+
+ public String getQueryPath() {
+ return queryPath;
+ }
+
+ public IResource getResource() {
+ return resource;
+ }
+ }
+
+ private static class ImagesFinder implements IResourceVisitor {
+ private List<IResource> resources;
+ private int count = 0;
+ private String name;
+ Set<String> extensions = null;
+
+ /**
+ * @param resources
+ * @param name
+ * @param extensions
+ */
+ public ImagesFinder(List<IResource> resources, String name, Set<String> extensions) {
+ this.resources = resources;
+ this.name = name;
+ this.extensions = extensions;
+ }
+
+ boolean acceptExtension(String ext) {
+ if(ext != null) {
+ ext = ext.toLowerCase();
+ }
+ return (extensions == null || extensions.contains(ext));
+ }
+
+ public boolean visit(IResource resource) throws CoreException {
+ if(resource instanceof IFile) {
+ IFile file = (IFile)resource;
+ if(resource.getName().startsWith(name) && acceptExtension(file.getFileExtension())) {
+ resources.add(resource);
+ }
+ } else if(resource instanceof IFolder) {
+ if(count==0) {
+ count++;
+ return true;
+ } else if(resource.getName().startsWith(name) && (!resource.getName().equals("WEB-INF")) && (!resource.getName().equals("META-INF"))) {
+ resources.add(resource);
+ }
+ }
+ return false;
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourcePathProposalType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/CustomTagLibManager.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/CustomTagLibManager.java 2009-06-24 21:15:23 UTC (rev 16192)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/CustomTagLibManager.java 2009-06-24 21:20:45 UTC (rev 16193)
@@ -37,6 +37,9 @@
*/
public class CustomTagLibManager {
+ public static final String FACELETS_UI_TAG_LIB_URI = "http://java.sun.com/jsf/facelets";
+ public static final String FACELETS_HTML_TAG_LIB_URI = "http://www.w3.org/1999/xhtml/facelets";
+
private static final CustomTagLibManager INSTANCE = new CustomTagLibManager();
private ICustomTagLibrary[] libs = null;
15 years, 6 months
JBoss Tools SVN: r16192 - in trunk: jst/plugins/org.jboss.tools.jst.jsp and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2009-06-24 17:15:23 -0400 (Wed, 24 Jun 2009)
New Revision: 16192
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFELCompletionEngine.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-2808
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 2009-06-24 20:57:58 UTC (rev 16191)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFELCompletionEngine.java 2009-06-24 21:15:23 UTC (rev 16192)
@@ -27,7 +27,7 @@
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.jsf.JSFModelPlugin;
import org.jboss.tools.jsf.model.pv.JSFPromptingProvider;
-import org.jboss.tools.jst.web.kb.AbstractELCompletionEngine;
+import org.jboss.tools.jst.web.kb.el.AbstractELCompletionEngine;
/**
* Utility class used to collect info for EL
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2009-06-24 20:57:58 UTC (rev 16191)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2009-06-24 21:15:23 UTC (rev 16192)
@@ -422,7 +422,7 @@
<contenttype id="org.eclipse.wst.html.core.htmlsource">
<partitiontype id="org.eclipse.wst.html.HTML_DEFAULT" />
<partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL" />
- <partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL2" /> <!-- Is this forgotten? -->
+ <partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL2" />
</contenttype>
</contentAssistProcessor>
@@ -430,7 +430,7 @@
//added by estherbin
//fix http://jira.jboss.com/jira/browse/JBIDE-1791
-->
- <contentAssistProcessor
+ <!--contentAssistProcessor
class="org.eclipse.wst.css.ui.internal.contentassist.CSSContentAssistProcessor"
id="org.eclipse.wst.css.ui.internal.contentassist.CSSContentAssistProcessor">
<contenttype id="org.eclipse.wst.html.core.htmlsource">
@@ -438,7 +438,6 @@
</contenttype>
</contentAssistProcessor>
- <!--
<contentAssistProcessor
class="org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor"
id="org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor">
@@ -476,8 +475,7 @@
<partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL" />
<partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL2" />
</contenttype>
- </contentAssistProcessor>
- -->
+ </contentAssistProcessor -->
</extension>
<extension
point="org.eclipse.ui.popupMenus">
15 years, 6 months
JBoss Tools SVN: r16191 - in trunk/seam/plugins: org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2009-06-24 16:57:58 -0400 (Wed, 24 Jun 2009)
New Revision: 16191
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamContextVariable.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.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamValidatorConfigurationBlock.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4514 - Fixed
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamContextVariable.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamContextVariable.java 2009-06-24 18:03:05 UTC (rev 16190)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamContextVariable.java 2009-06-24 20:57:58 UTC (rev 16191)
@@ -10,7 +10,7 @@
******************************************************************************/
package org.jboss.tools.seam.core;
-import org.jboss.tools.jst.web.kb.AbstractELCompletionEngine.IVariable;
+import org.jboss.tools.jst.web.kb.el.AbstractELCompletionEngine.IVariable;
/**
* Represents Seam Context Variable.
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 2009-06-24 18:03:05 UTC (rev 16190)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2009-06-24 20:57:58 UTC (rev 16191)
@@ -54,7 +54,7 @@
import org.jboss.tools.common.model.project.ext.event.Change;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.AbstractELCompletionEngine;
+import org.jboss.tools.jst.web.kb.el.AbstractELCompletionEngine;
import org.jboss.tools.seam.core.IBijectedAttribute;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamContextShortVariable;
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java 2009-06-24 18:03:05 UTC (rev 16190)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java 2009-06-24 20:57:58 UTC (rev 16191)
@@ -149,6 +149,7 @@
public static String SeamValidatorConfigurationBlock_pb_elSyntaxError_label;
public static String SeamValidatorConfigurationBlock_pb_unknownElVariableName_label;
public static String SeamValidatorConfigurationBlock_pb_checkVars_label;
+ public static String SeamValidatorConfigurationBlock_pb_revalidateUnresolvedEl_label;
public static String SeamValidatorConfigurationBlock_pb_unknownElVariablePropertyName_label;
public static String SeamValidatorConfigurationBlock_pb_unpairedGetterOrSetter_label;
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties 2009-06-24 18:03:05 UTC (rev 16190)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties 2009-06-24 20:57:58 UTC (rev 16191)
@@ -59,6 +59,7 @@
SeamValidatorConfigurationBlock_pb_elSyntaxError_label=EL Syntax Error
SeamValidatorConfigurationBlock_pb_unknownElVariableName_label=Context variable cannot be resolved:
SeamValidatorConfigurationBlock_pb_checkVars_label=Recognize "var" attributes
+SeamValidatorConfigurationBlock_pb_revalidateUnresolvedEl_label=Revalidate unresolved ELs automatically.
SeamValidatorConfigurationBlock_pb_unknownElVariablePropertyName_label=Property cannot be resolved:
SeamValidatorConfigurationBlock_pb_unpairedGetterOrSetter_label=Unpaired Getter/Setter:
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamValidatorConfigurationBlock.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamValidatorConfigurationBlock.java 2009-06-24 18:03:05 UTC (rev 16190)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamValidatorConfigurationBlock.java 2009-06-24 20:57:58 UTC (rev 16191)
@@ -64,6 +64,7 @@
private static final String SETTINGS_SECTION_NAME = SeamPreferencesMessages.SEAM_VALIDATOR_CONFIGURATION_BLOCK_SEAM_VALIDATOR_CONFIGURATION_BLOCK;
private Button recognizeVarsCheckBox;
+ private Button revalidateUnresolvedElCheckBox;
private Combo elVariablesCombo;
private Combo elPropertiesCombo;
@@ -276,6 +277,9 @@
if(section==SECTION_EL) {
label = SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_checkVars_label;
recognizeVarsCheckBox = addCheckBox(inner, label, getSeamKey(SeamPreferences.CHECK_VARS), enableDisableValues, defaultIndent);
+
+ label = SeamPreferencesMessages.SeamValidatorConfigurationBlock_pb_revalidateUnresolvedEl_label;
+ revalidateUnresolvedElCheckBox = addCheckBox(inner, label, getSeamKey(SeamPreferences.RE_VALIDATE_UNRESOLVED_EL), enableDisableValues, defaultIndent);
}
}
15 years, 6 months
JBoss Tools SVN: r16190 - in trunk: jsf/tests/org.jboss.tools.jsf.vpe.jstl.test/META-INF and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2009-06-24 14:03:05 -0400 (Wed, 24 Jun 2009)
New Revision: 16190
Modified:
trunk/jsf/features/org.jboss.tools.richfaces.feature/feature.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jstl.test/META-INF/MANIFEST.MF
trunk/tests/features/org.jboss.tools.test.feature/feature.xml
Log:
enable JSTL templates and tests in build
Modified: trunk/jsf/features/org.jboss.tools.richfaces.feature/feature.xml
===================================================================
--- trunk/jsf/features/org.jboss.tools.richfaces.feature/feature.xml 2009-06-24 14:51:13 UTC (rev 16189)
+++ trunk/jsf/features/org.jboss.tools.richfaces.feature/feature.xml 2009-06-24 18:03:05 UTC (rev 16190)
@@ -500,4 +500,11 @@
install-size="0"
version="0.0.0"/>
+ <plugin
+ id="org.jboss.tools.jsf.vpe.jstl"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jstl.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jstl.test/META-INF/MANIFEST.MF 2009-06-24 14:51:13 UTC (rev 16189)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jstl.test/META-INF/MANIFEST.MF 2009-06-24 18:03:05 UTC (rev 16190)
@@ -11,3 +11,4 @@
Bundle-ClassPath: vpe-jstl-test.jar
Import-Package: org.jboss.tools.tests,
org.jboss.tools.vpe.ui.test
+Export-Package: org.jboss.tools.jsf.vpe.jstl.test
Modified: trunk/tests/features/org.jboss.tools.test.feature/feature.xml
===================================================================
--- trunk/tests/features/org.jboss.tools.test.feature/feature.xml 2009-06-24 14:51:13 UTC (rev 16189)
+++ trunk/tests/features/org.jboss.tools.test.feature/feature.xml 2009-06-24 18:03:05 UTC (rev 16190)
@@ -437,4 +437,10 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.jboss.tools.jsf.vpe.jstl.test"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"/>
+
</feature>
15 years, 6 months
JBoss Tools SVN: r16189 - trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2009-06-24 10:51:13 -0400 (Wed, 24 Jun 2009)
New Revision: 16189
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_bottom.gif
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_left.gif
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_right.gif
trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_top.gif
Log:
https://jira.jboss.org/jira/browse/JBIDE-4289
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_bottom.gif
===================================================================
(Binary files differ)
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_left.gif
===================================================================
(Binary files differ)
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_right.gif
===================================================================
(Binary files differ)
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/resources/org/jboss/tools/vpe/editor/mozilla/icons/source_top.gif
===================================================================
(Binary files differ)
15 years, 6 months
JBoss Tools SVN: r16188 - trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2009-06-24 10:28:53 -0400 (Wed, 24 Jun 2009)
New Revision: 16188
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/FileTagProposalLoader.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4054
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/FileTagProposalLoader.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/FileTagProposalLoader.java 2009-06-24 13:49:29 UTC (rev 16187)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/FileTagProposalLoader.java 2009-06-24 14:28:53 UTC (rev 16188)
@@ -83,6 +83,13 @@
"include",
new AbsoluteFilePathAttributeValueLoader("src","","")
);
+
+ static TagProposal S_DECORATE = new TagProposal(
+ DropURI.SEAM_URI,
+ "s",
+ "decorate",
+ new AbsoluteFilePathAttributeValueLoader("template","","")
+ );
static TagProposal[] PAGE_TAG_PROPOSALS = new TagProposal[]{
JSP_INCLUDE,
@@ -92,7 +99,8 @@
static TagProposal[] XHTML_PAGE_TAG_PROPOSALS = new TagProposal[]{
JSP_INCLUDE,
JSP_FORWARD,
- UI_INCLUDE
+ UI_INCLUDE,
+ S_DECORATE
};
static {
15 years, 6 months
JBoss Tools SVN: r16187 - in trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt: org/jboss/tools and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: smukhina
Date: 2009-06-24 09:49:29 -0400 (Wed, 24 Jun 2009)
New Revision: 16187
Modified:
trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/com/jboss/tools/common.xsl
trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools/common.xsl
Log:
https://jira.jboss.org/jira/browse/JBDS-741 Feedback form on JBDS and Tools guides is completely implemented, com guides open JBDS jira, org ones open JBIDE jira
Modified: trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/com/jboss/tools/common.xsl
===================================================================
--- trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/com/jboss/tools/common.xsl 2009-06-24 13:08:01 UTC (rev 16186)
+++ trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/com/jboss/tools/common.xsl 2009-06-24 13:49:29 UTC (rev 16187)
@@ -22,7 +22,7 @@
</a>
</h3>
<iframe id='feedback-iFrame' name="feedback-iFrame"><xsl:text> </xsl:text></iframe>
- <form onsubmit="return validate_form()" id="feedback-mailform" method="post" action="https://jira.jboss.org/jira/secure/CreateIssueDetails!init.jspa?pid=12310..." target="feedback-iFrame">
+ <form onsubmit="return validate_form()" id="feedback-mailform" method="post" action="https://jira.jboss.org/jira/secure/CreateIssueDetails!init.jspa?pid=12310..." target="feedback-iFrame">
<input type="hidden" id="priority" name="priority" value="3" />
<input type="hidden" id="components" name="components" value="12311170" />
<input type="hidden" id="versions" name="versions" value="12312451" />
@@ -42,7 +42,7 @@
<label for="feedback-environment">Environment</label>
<textarea id="feedback-environment" name="feedback-environment" title="Describe your environment"><xsl:text> </xsl:text></textarea>
</form>
- <div id="guide_words">This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.</div>
+ <div id="guide_words">This will launch the JBDS Jira page - to complete your feedback please login if needed, and submit the Jira.</div>
<input type="button" id="feedback-submit" value="Proceed to Jira" name="submit" class="feedback-formbutton" title="Proceed to create new issue" onclick="fillForm('feedback-mailform'); submitForm('feedback-mailform', 'feedback-iFrame', 'feedback-submit', 'feedback-maincontainer');"/>
</div>
<div id="feedback-wrapper">
Modified: trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools/common.xsl
===================================================================
--- trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools/common.xsl 2009-06-24 13:08:01 UTC (rev 16186)
+++ trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools/common.xsl 2009-06-24 13:49:29 UTC (rev 16187)
@@ -21,7 +21,7 @@
</a>
</h3>
<iframe id='feedback-iFrame' name="feedback-iFrame"><xsl:text> </xsl:text></iframe>
- <form onsubmit="return validate_form()" id="feedback-mailform" method="post" action="https://jira.jboss.org/jira/secure/CreateIssueDetails!init.jspa?pid=12310..." target="feedback-iFrame">
+ <form onsubmit="return validate_form()" id="feedback-mailform" method="post" action="https://jira.jboss.org/jira/secure/CreateIssueDetails!init.jspa?pid=10020..." target="feedback-iFrame">
<input type="hidden" id="priority" name="priority" value="3" />
<input type="hidden" id="components" name="components" value="12311170" />
<input type="hidden" id="versions" name="versions" value="12312451" />
@@ -41,7 +41,7 @@
<label for="feedback-environment">Environment</label>
<textarea id="feedback-environment" name="feedback-environment" title="Describe your environment"><xsl:text> </xsl:text></textarea>
</form>
- <div id="guide_words">This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.</div>
+ <div id="guide_words">This will launch the Jboss Tools Jira page - to complete your feedback please login if needed, and submit the Jira.</div>
<input type="button" id="feedback-submit" value="Proceed to Jira" name="submit" class="feedback-formbutton" title="Proceed to create new issue" onclick="fillForm('feedback-mailform'); submitForm('feedback-mailform', 'feedback-iFrame', 'feedback-submit', 'feedback-maincontainer');"/>
</div>
<div id="feedback-wrapper">
15 years, 6 months
JBoss Tools SVN: r16186 - in trunk/documentation/guides/GettingStartedGuide/en: modules and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: smukhina
Date: 2009-06-24 09:08:01 -0400 (Wed, 24 Jun 2009)
New Revision: 16186
Added:
trunk/documentation/guides/GettingStartedGuide/en/images/getting_started/update_wizard_1.png
trunk/documentation/guides/GettingStartedGuide/en/images/getting_started/update_wizard_2.png
Modified:
trunk/documentation/guides/GettingStartedGuide/en/modules/getting_started.xml
Log:
https://jira.jboss.org/jira/browse/JBDS-766 JBoss Tools Installation section is updated
Added: trunk/documentation/guides/GettingStartedGuide/en/images/getting_started/update_wizard_1.png
===================================================================
(Binary files differ)
Property changes on: trunk/documentation/guides/GettingStartedGuide/en/images/getting_started/update_wizard_1.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/documentation/guides/GettingStartedGuide/en/images/getting_started/update_wizard_2.png
===================================================================
(Binary files differ)
Property changes on: trunk/documentation/guides/GettingStartedGuide/en/images/getting_started/update_wizard_2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/documentation/guides/GettingStartedGuide/en/modules/getting_started.xml
===================================================================
--- trunk/documentation/guides/GettingStartedGuide/en/modules/getting_started.xml 2009-06-24 12:17:30 UTC (rev 16185)
+++ trunk/documentation/guides/GettingStartedGuide/en/modules/getting_started.xml 2009-06-24 13:08:01 UTC (rev 16186)
@@ -521,7 +521,7 @@
</section>
<section id="JBossToolsInstall">
- <title>JBoss Tools Installation</title>
+ <title>JBoss Tools Installation and Update</title>
<para>Here, let's consider the installation of the <property>JBoss Tools</property>
modules.</para>
<para><property>JBoss Tools</property> is an umbrella project for the JBoss developed plugins
@@ -606,7 +606,31 @@
with eclipse -clean to make sure it starts clean and rereads the new list of plugins.</para>
<para>If you need to install any standalone plug-in from JBoss Tools visit a <ulink url="http://labs.jboss.com/wiki/InstallingJBossTools">JBoss Tools Wiki</ulink> page to read
- about dependencies between standalone plug-ins.</para>
+ about dependencies between standalone plug-ins.</para>
+
+ <para>You can update Jboss Tools and install a new version with the help of "Install" wizard (Help > Install New Software...)</para>
+
+ <figure>
+ <title>Updating Jboss Tools</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/getting_started/update_wizard_1.png"/>
+ </imageobject>
+ </mediaobject>
+ </figure>
+
+ <para>In "Work with" field add the path to the source to update from (e.g. http://download.jboss.org/jbosstools/updates/development), check the necessary software to install, more information about chosen software can be found in "Details" section.</para>
+<para>Follow "Available Software Sites" link to find more site to update from</para>
+
+ <figure>
+ <title>Available Software Sites</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/getting_started/update_wizard_2.png"/>
+ </imageobject>
+ </mediaobject>
+ </figure>
+
</section>
</section>
15 years, 6 months
JBoss Tools SVN: r16185 - in trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor: util and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2009-06-24 08:17:30 -0400 (Wed, 24 Jun 2009)
New Revision: 16185
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java
Log:
Fixing PMD code violations
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2009-06-24 11:46:14 UTC (rev 16184)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualKeyHandler.java 2009-06-24 12:17:30 UTC (rev 16185)
@@ -793,7 +793,7 @@
}
private Node getNextFlatNode (Node node) {
for (Node next = FlatIterator.next(node); next != null; next = FlatIterator.next(next)) {
- if (getVisualNode(next) != null || next.getNodeType() == Node.TEXT_NODE);
+ if (getVisualNode(next) != null || next.getNodeType() == Node.TEXT_NODE)
return next;
}
return null;
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java 2009-06-24 11:46:14 UTC (rev 16184)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java 2009-06-24 12:17:30 UTC (rev 16185)
@@ -18,7 +18,6 @@
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-
import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBuffer;
import org.eclipse.core.filebuffers.ITextFileBufferManager;
@@ -237,7 +236,9 @@
*/
private static String getDoctype(File file) {
String docTypeValue = Constants.EMPTY;
- IDOMDocument document = getDocument(file);
+ IDOMDocument document= null;
+ try {
+ document = getDocument(file);
if (document != null) {
// find "component" element
Element componentElement = FaceletUtil
@@ -274,10 +275,19 @@
docTypeValue = documentType.getSource();
}
}
+ }finally {
+ //added by Max Areshkau, we should always release document
+ if(document!=null) {
+ FileBufferModelManager.getInstance().releaseModel(document.getStructuredDocument());
+ }
+ }
return (docTypeValue != null) ? docTypeValue.trim() : Constants.EMPTY;
}
/**
+ * Maksim Areshkau
+ * After using document model should be always released!
+ *
* get document by {@link File}
*
* @param file
@@ -285,24 +295,6 @@
*/
static private IDOMDocument getDocument(File file) {
- // if (file.exists()) {
- //
- // String content = org.jboss.tools.common.util.FileUtil
- // .readFile(file);
- //
- // IStructuredDocument newStructuredDocument = StructuredDocumentFactory
- // .getNewStructuredDocumentInstance(new JSPSourceParser());
- //
- // newStructuredDocument.set(content);
- //
- // IDOMModel modelForJSP = new DOMModelForJSP();
- // modelForJSP.setStructuredDocument(newStructuredDocument);
- //
- // return modelForJSP.getDocument();
- //
- // }
- // return null;
-
IDOMModel model = null;
ITextFileBufferManager bufferManager = FileBuffers
.getTextFileBufferManager();
@@ -325,7 +317,7 @@
} catch (CoreException e) {
VpePlugin.getPluginLog().logError(e);
}
- return model.getDocument();
+ return model==null?null:model.getDocument();
}
/**
@@ -347,7 +339,10 @@
* @return
*/
public static String getContentInitFile(File initFile) {
- IDOMDocument document = getDocument(initFile);
+ IDOMDocument document = null;
+ String result = Constants.EMPTY;
+ try {
+ document = getDocument(initFile);
if (document != null) {
// for each tag's name
for (String tag : urlTags) {
@@ -372,8 +367,13 @@
}
}
}
- return document.getSource();
+ result = document.getSource();
}
- return Constants.EMPTY;
+ } finally {
+ if(document!=null) {
+ FileBufferModelManager.getInstance().releaseModel(document.getStructuredDocument());
+ }
+ }
+ return result;
}
}
15 years, 6 months